How to empty serial buffer on RiscPC and older
Andy S (2979) 504 posts |
I knocked together some code to interface with a game in real time via RS232 (Quite a fun project; all will be revealed in time if I can finish it). My problem is given the FIFO nature of the serial reads, if the game is paused the buffer can fill with old data that is no longer wanted. I’m using OS_SerialOp calls and I couldn’t seem to find any way to either empty the serial buffer, discarding all data, or alternatively to access the last byte in the buffer directly. Is there any way to do this that will work with all RiscPC and older hardware? Any way other than what I’m currently doing which is just reading all the data in byte by byte and ignoring it? Is the buffer something I can address directly? I appreciate this isn’t really what a serial device was designed for. : ) |
Jon Abbott (1421) 2651 posts | |
Andy S (2979) 504 posts |
Thanks Jon. I’ve not got my code in front of me but I seem to remember my attempts to flush the buffers not seeming to solve the problem; subsequent reads were still pulling in old data. Maybe the data was being buffered at the transmission side as well. I started writing a rudimentary protocol to keep the data synchronized at which point I thought I was maybe missing something obvious. Wasn’t there an RS232 joystick for the Archie or did I dream that? I’d be interested to see how that was coded. |