Manipulate bytes in arduino -
void setup() { // open serial communications , wait port open: serial.begin(2400); } void loop() { while(!serial.available()); // wait character int incomingbyte = serial.read(); serial.print(incomingbyte,hex); serial.print(' ');` }
i using code above "train of bytes" in arduino, each pulse of bytes give me this: 3 packets 1),2) , 3)
------a-------------b-------------- c-------d----------e-----------f
1) aa 55 || 01 03 05 07 09 || 05 || 0a 02 || 02 22 22 || b3 d0
2) aa 55 || 01 03 05 07 09 || 05 || 0a 07 || 03 33 33 || 2e 80
3) aa 55 || 01 03 05 07 09 || 05 || 0a 0c || 04 44 44 || fa b3
- a => first 2 bytes (aa 55) means beginning of each packet.
- b => 5 next bytes (01 03 05 07 09) identificator.
- c => number of bytes of d + e (is equal 05 in example above)
- d => kind of measuring (0a 02, 0a 07 or 0a 0c)
- e => data, number of measuring, example: 02 22 22 means 22.222 w
- f => crc
i need separate each part , show message this:
for packet 1)
for bytes : beggins here
for b bytes: identificator xyz
for c bytes: number of bytes k
for d bytes: kind of measure m
for e bytes: value of measure 22.222
for f bytes: crc j
this messages must packets 2) , 3) too. have show messages repeatedly, while sending data arduino serial.
thanks me, sorry if have english erros.
Comments
Post a Comment