Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/31/00 06:05
Read: times


 
#4817 - RE: C code fine for hex
Hi Martin,

here is it.
You must only divide the data into pieces of 1 to 255 bytes (len = 1 ... 255). Since hex records limited to max 255 bytes. But most programs accept only 16 bytes.
To write the end record, call it with len = 0.


Peter


following the code:

typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long int ulong;

int writehex( FILE *fp, ulong adr, uchar *data, int len )
{
if( len ){
int pruef;
fprintf( fp, ":%02X%04lX00", len, adr );
pruef = len + (adr & 0xFF) + (adr >> 8);
for(; len--; data++){
fprintf( fp, "%02X", *data );
pruef += *data;
}
fprintf( fp, "%02Xrn", -pruef & 0xFF );
return 1;
}
fputs( ":00000001FFrn", fp );
return 1;
}



List of 2 messages in thread
TopicAuthorDate
C code fine for hex            01/01/70 00:00      
RE: C code fine for hex            01/01/70 00:00      

Back to Subject List