What is the correct pattern to e.g. check for I/O from the RS232 port in a GEM application? Do I add a call for it in my main runloop, do I synthesize timer events, or?
-Thom
correct pattern for I/O in GEM app?
Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team
Re: correct pattern for I/O in GEM app?
Try here https://www.dev-docs.org/docs/.
My vague recollection is that you have to first initialize the protocol to match the device you are connecting to. They should both have the same baud rate, number of start and stop bits , error correction (xon/xoff etc) to allow a handshake.
Once that is set you open a port to the device. From there you can read and write packets of data to /from the device when ready. Once finished you close port.
There is more to it but that is simplistic view of it.
My vague recollection is that you have to first initialize the protocol to match the device you are connecting to. They should both have the same baud rate, number of start and stop bits , error correction (xon/xoff etc) to allow a handshake.
Once that is set you open a port to the device. From there you can read and write packets of data to /from the device when ready. Once finished you close port.
There is more to it but that is simplistic view of it.
('< o o o o |''| STM,2xSTFM,2xSTE+HD,C-Lab Falcon MK2+HD,Satandisk,Ultrasatandisk,Ethernat.
Re: correct pattern for I/O in GEM app?
If you want to avoid ugly redraw lags in your GEM application, you will need to add timer events to your event loop at a reasonable frequency. The handler would then check if there is something to do using Bconstat().
Due to the nature of this call (you can only check if the receive buffer contains *any* data, not how much), you'll need to read byte by byte (using Bconin()) and check again in between, otherwise Bconin() may block. If you want to make your reads more performant, have a look into Iorec() which will give you direct access to the BIOS buffers.
Nice, AES-multitasking friendly applications do an evnt_timer(0) during lengthy operations anyway to give other applications/accessories a chance to do their stuff as well.
Due to the nature of this call (you can only check if the receive buffer contains *any* data, not how much), you'll need to read byte by byte (using Bconin()) and check again in between, otherwise Bconin() may block. If you want to make your reads more performant, have a look into Iorec() which will give you direct access to the BIOS buffers.
Nice, AES-multitasking friendly applications do an evnt_timer(0) during lengthy operations anyway to give other applications/accessories a chance to do their stuff as well.
Re: correct pattern for I/O in GEM app?
Thanks. that's kind of what I figured. I'm going to set my timers to zero, for now, and go from there...
-Thom
-Thom