correct pattern for I/O in GEM app?

GFA, ASM, STOS, ...

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

tschak909
Atari maniac
Atari maniac
Posts: 79
Joined: Mon Mar 26, 2018 9:29 pm

correct pattern for I/O in GEM app?

Postby tschak909 » Sat Aug 25, 2018 6:31 am

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

User avatar
MiggyMog
Atari Super Hero
Atari Super Hero
Posts: 833
Joined: Sun Oct 30, 2005 4:43 pm
Location: Scotland

Re: correct pattern for I/O in GEM app?

Postby MiggyMog » Sat Aug 25, 2018 8:50 am

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.
('< o o o o |''| STM,2xSTFM,2xSTE+HD,C-Lab Falcon MK2+HD,Satandisk,Ultrasatandisk,Ethernat.

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 762
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: correct pattern for I/O in GEM app?

Postby mfro » Sat Aug 25, 2018 9:44 am

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.

tschak909
Atari maniac
Atari maniac
Posts: 79
Joined: Mon Mar 26, 2018 9:29 pm

Re: correct pattern for I/O in GEM app?

Postby tschak909 » Sat Aug 25, 2018 3:52 pm

Thanks. that's kind of what I figured. I'm going to set my timers to zero, for now, and go from there...

-Thom


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 3 guests

cron