Home > Software engineering >  VC realize the HEX capture
VC realize the HEX capture

Time:10-09

In the use of VC 6.0 in a signal generator of the project, read the big broadcast the data in the table to the binary data blocks, and then send to signal generator, the output waveform, according to a great table control command to:
: DATA: DAC16 VOLATILE, END, # 532768 & lt; Binary - block - data>
The size table of data to be read & lt; Binary - block - data> , the data range 0000 ~ 3 FFF,
Command given to always prompt error, don't know what was wrong with specific, so want to capture a distributed on the table data, see if the problem there,
But do not know how to realize the capture, according to the effect of the picture below to view:

Please give help, experienced player specific points, strives for the code, thank you

CodePudding user response:

 # include & lt; Stdio. H> 
# include & lt; String. H>
Void HexDumpToBuf (char * sbuf, char * buf, int len, int addr) {
Int I, j, k, L;
Char binstr [80].

L=0;
For (I=0; iIf (0==16) (I %) {
Sprintf (binstr, "% x - 08", I + addr);
Sprintf (binstr, "% s % 02 x", binstr, buf (unsigned char) [I]);
} else if (15==16) (I %) {
Sprintf (binstr, "% s % 02 x", binstr, buf (unsigned char) [I]);
Sprintf (binstr, "% s", binstr);
For (j=I - 15; j<=I; J++) {
Sprintf (binstr, "% s % c," binstr, ('! '& lt; Buf [j] & amp; & Buf [j] <='~')? Buf [j] : '. ');
}
L +=sprintf (sbuf + L, "% s \ n", binstr);
If (L>=10000) return;
} else {
Sprintf (binstr, "% s % 02 x", binstr, buf (unsigned char) [I]);
}
}
If (0! 16)=(I %) {
16 k=16 - (I %);
For (j=0; jSprintf (binstr, "% s", binstr);
}
Sprintf (binstr, "% s", binstr);
K=16 - k;
For (j=I - k; jSprintf (binstr, "% s % c," binstr, ('! '& lt; Buf [j] & amp; & Buf [j] <='~')? Buf [j] : '. ');
}
L +=sprintf (sbuf + L, "% s \ n", binstr);
If (L>=10000) return;
}
}
Int main () {
Char STR [1024].
Char buf [10240].
Int flag=1;
Int datalen=3;
The int data [3]={1, 2, 3};
Int I, L;
L=sprintf (STR, "DATA: VOLETILE % d, % d", flag, datalen);
For (I=0; iHexDumpToBuf (buf, STR, L + 3 * sizeof (int), 0).
Printf (" % s ", buf);
return 0;
}
//00000000-44 41 54 56 4 f and 3 a 4 c 45 to 54 49 4 c and 2 c 45 33 DATA: VOLETILE1, 3
//00000010-01 00 00 00 00 00 00 02 03 00 00 00...
//

CodePudding user response:

Is the data in BYTE array to print one by one, when printing in hexadecimal display, etc
  • Related