Missing first byte stored in a buffer. Need some help with this.
Don M
Posts: 1,652
I am receiving in some data into a buffer. For some reason I am missing the first byte. It must be the way I have this loop structured but can't figure why it won't work.
I can see the data on the analyzer so I know it's there but somehow my indexing is off by one. The buffer is 32 bytes. The final check byte has 9th bit set so that is the reason for the $1_00 check.
I can see the data on the analyzer so I know it's there but somehow my indexing is off by one. The buffer is 32 bytes. The final check byte has 9th bit set so that is the reason for the $1_00 check.
inx := 0 s := serial.rx_time(20) if s > -1 'inx := 0 chksum := s buffer[inx] := s repeat s := serial.rx_time(5) if (s & $1_00) chksum &= $0_FF if (chksum == (s & $0_FF)) pollack seq++ term.str(string("ID: ",13,10,03)) quit chksum += s buffer[inx] := s inx ++ else term.str(string("No Response to ID",13,10,03)) seq := 4 repeat inx from 0 to 28 term.tx(byte[@buffer][inx]) term.tx(32) term.tx(13)
Comments
What I don't understand is if I can see the first byte from the first term.tx(s) then why isn't this same byte stored to buffer[idx] when idx starts at 0?
I can do term.tx(byte[@buffer][0]) and I see the second byte that is received not the first. Weird....
Nope. Still doesn't show correct first byte from buffer.
Seems as though inx was not being advanced after the first byte stored. See below.