Menu

#9 When 1st byte in packet is 26, it causes problems.

open
6
2007-01-25
2007-01-25
No

Thats the best way I can word it. It is likely a problem with my Sensor parsing, or its some kind of pointer problem.

What happens is, in Roomba.Get_Packet(), there is a loop to Read bytes from the Serial Port, and add them to the buffer. I then assign the completed buffer to Roomba.Sensors.RawBytes

The reason I have the buffer is because Roomba might not return an entire packet, but splits it up.

However, when the first byte returned back from the serial port is 26 (you can reproduce with left bumper & left wheel dropdown), then what happens is; when Roomba.IO_Buffer is added to, then Roomba.Sensors.RawBytes is ALSO assigned to. It is like they are both pointing to the memory location. However, I am not aware of anywhere in the app that I am doing that.

This would not be noticeable, however, I have code to detect whether the bytes have changed between IO_Buffer & Roomba.Sensors.Raw_Bytes. If both are being assigcned to simultaneously, then the program is fooled into believing that Sensor data has never changed, and they never get parsed.

The IO_Buffer is only cleared when the Sensor Object parses the buffer, so that can't happen, meaning that bytes are infinitely addad to the IO_Buffer & Roomba.Sensors.Raw_Bytes until the program crashes.

As a band-aid, I created another Sensor Property called "Previous Bytes" that I assign a copy of raw_bytes and I do the comparison on that one.

Since this fix works, what this proves is that somewehere, when the first sensor byte is 26, IO_Buffer & Roomba.Sensors.Raw_Bytes then are told to point to the same memory location.

It is also of note that this happens when the Sensor form is open. That for is constantly reading the Sensor packet, it is possible it could be related to the problem.. and possibly Roomba_Poller, who knows....

Discussion


Log in to post a comment.