NAME

Hex::Record - manipulate intel and srec hex records

SYNOPSIS

use Hex::Parser qw(parse_intel_hex parse_srec_hex);

# get hex object from the parser
my $hex_record = parse_intel_hex( 'intel.hex' );

# get 100 bytes ( hex format ) starting at address 0x100
# every single byte that is not found is returned as undef
my $bytes_ref = $hex->get( 0x100, 10 );

# remove 100 bytes starting at address 0x100
$hex_record->remove( 0x100, 10 );

# write/overwrite 3 bytes starting at address 0x100
$hex_record->write( 0x100, [ 'AA', 'BB', 'CC' ] );

# dump as intel hex ( will use extended linear addresses for offset )
# maximum of 10 bytes in data field
$hex_record->as_intel_hex( 10, $file_handle );

# dump as srec hex ( always tries to use smallest address )
# maximum of 10 bytes in data field
$hex_record->as_screc_hex( 10, $file_handle );

DESCRIPTION

Manipulate intel/srec hex files.

Methods of Hex

get( $from, $count )

Returns $count hex bytes in array reference starting at address $from. If hex byte is not found, undef instead.

[ 'AA', '00', undef, undef, 'BC', undef ]
remove( $from, $count )

Removes $count bytes starting at address $from.

write( $from, $bytes_ref )

(Over)writes bytes starting at address $from with bytes in $bytes_ref.

as_intel_hex( $bytes_hex_a_line, $file_handle )

Writes data as intel hex into file hanlde. Maximum of $hytes_hex_a_line in data field. Extended linear addresses as offset are used if needed. Extended segment addresses are not supported.

as_srec_hex( $bytes_hex_a_line, $file_handle )

Writes data as srec into file hanlde. Maximum of $hytes_hex_a_line in data field. Tries to use the smallest address field.

LICENSE

This is released under the Artistic License.

AUTHOR

spebern <bernhard@specht.net>