Srecord file parsing

hi.. i have an s-record file as:
S315080001100060A0E30070A0E30080A0E30090A0E3E5

where S3: Type, 15: # of bytes, then 4 byte address and rest is data

i want to write something to automatically parse this file, and maybe do some operations, such as replace the S3 with something else, and then write all that into an output file.
how do i do that? Thanks..
As far as i know, the best method is to use a struct and binary file I/O:
1
2
3
4
5
6
7
8
9
struct data{
char type[2]; //s3
char byte_count[2];
char address[4]; 
char data[50]; 
}dat;
FILE *fp=fopen("file.bin","rb");
fread(&dat,sizeof(dat),1,fp);
// do what you want here 

hope this helps.
Last edited on
You may want to look into libGIS:

http://dev.frozeneskimo.com/software_projects:libgis
Topic archived. No new replies allowed.