helix@bucc2.UUCP (05/23/88)
A couple of weeks ago, I had started to program a Bulliten Board System for my ST. I have, however, run into a few problems with the I/O routines for my RS-232 port. First, I tried to open files to "aux:" and use feof() to see if any characters were in the buffer, but that did not seem to work properly. Then, I just changed the routines and used some GDOS functions like Cauxin, Cauxout, Cauxis, and Cauxos. These seem to work fine, but they do not use buffers. I would like to write this BBS so that it doesn't use too many system dependent functions. Is there any way I can access the RS-232 port with the standard I/O functions or do I have to stick with GDOS?? Also, I am using the right approach?? Any help would be deeply appreciated....
singer@XN.LL.MIT.EDU (Matthew R. Singer) (05/26/88)
In article <56200002@bucc2>, helix@bucc2.UUCP writes: > > > > > A couple of weeks ago, I had started to program a Bulliten > Board System for my ST. I have, however, run into a few problems > with the I/O routines for my RS-232 port. > First, I tried to open files to "aux:" and use feof() to see > if any characters were in the buffer, but that did not seem to work > properly. Then, I just changed the routines and used some GDOS functions > like Cauxin, Cauxout, Cauxis, and Cauxos. These seem to work fine, but > they do not use buffers. I would like to write this BBS so that it doesn't > use too many system dependent functions. Is there any way I can access the > RS-232 port with the standard I/O functions or do I have to stick with > GDOS?? Also, I am using the right approach?? > > > Any help would be deeply appreciated.... Your best bet is to use Bconin, Bconout and Bconstat. Route all of your RS232 out to a small set of routines which can be written for any machine you want to run it on. This is what is done for FoReM ST and FoReM PC. The ST version uses the TOS RS232 driver (although fiddling with the buffers) and FoReM PC uses the Greenleaf Communications library. Other than that, the codes is 99.99% the same. Matt Singer Commnet Systems
Thomas_E_Zerucha@cup.portal.com (05/29/88)
>See if any characters are in the buffers...
I don't know of any completely portable way to do this, so I would suggest
isolation to a subroutine. On the ST, the standard way is to use the XBios
function Iorec to get the address of the input and output buffers for the
RS 232 drivers and compare the head and tail pointers to see if there is
anything in the buffer.
david@bdt.UUCP (David Beckemeyer) (06/01/88)
In article <56200002@bucc2> helix@bucc2.UUCP writes: > A couple of weeks ago, I had started to program a Bulliten >Board System for my ST. I have, however, run into a few problems >with the I/O routines for my RS-232 port. > First, I tried to open files to "aux:" and use feof() to see >if any characters were in the buffer, but that did not seem to work >properly. Then, I just changed the routines and used some GDOS functions >like Cauxin, Cauxout, Cauxis, and Cauxos. These seem to work fine, but >they do not use buffers. I would like to write this BBS so that it doesn't >use too many system dependent functions. Is there any way I can access the >RS-232 port with the standard I/O functions or do I have to stick with >GDOS?? Also, I am using the right approach?? I'll give my recommendations, but remember as with everything else, there is always more than one way to do it, and this is nothing more than an opinion. The safest way to solve portability is to NOT assume UNIX style TTY I/O exists and provide your own TTY interface ("glue") routines. For example, create a set of routines as follows: open_line read_line write_line ctrl_line ...etc... Make the library provide the fundmental functionality necessary for your application. Then put the system dependencies in one place, isolated from the rest of the application code. The reason I recommend this instead of assuming UNIX style TTY I/O is two fold: 1) you may want to port to a non-UNIX system where the UNIX calls don't work someday, and 2) the TTY I/O control calls aren't the same even between the various flavors and versions of UNIX. Now for the Atari ST specific stuff... Depending on the level of control needed, the BIOS calls may actually be preferable to BDOS (GEMDOS) calls. If you need more control than these provide, you may have to write your own interrupt and RS-232 device handlers (e.g. to toggle RS-232 control lines). Another reason BIOS calls might be better are performance; they're slightly faster than the BDOS (Caux?? calls use the BIOS Bcon?? calls eventually). The disadvantage to using the BIOS calls is that the software then becomes more hardware dependent because it is assuming hardware device 1 is the RS-232, and there is nothing else connectted there (e.g. a MUX or network). With RTX, the cleanest way to get both BIOS level speed and flexibility and BDOS device selection flexibiloity is to open the device by name, using a run-time selectable device name, and then use the RTX Ftype call to get the BIOS level device number at run-time. This also means that custom device drivers can be installed supporting the device control operations (e.g. toggling RS-232 control lines) at the driver level. So in summary, you define a device independent I/O library. Then you use ST calls (probably BIOS, maybe BDOS) to write a ST specific version of the library. When you port to another system, you simply write a new "glue" module, using that system's best RS-232 calls. Hope this is somewhat informative. -- David Beckemeyer | "Reckon the Ball's plumb open now, Beckemeyer Development Tools | and it's `swing partner'!" 478 Santa Clara Ave, Oakland, CA 94610 | - Unnamed Cowboy, upon seeing UUCP: ...!ihnp4!hoptoad!bdt!david | heap many Indians approaching
wes@obie.UUCP (06/01/88)
In article <56200002@bucc2>, helix@bucc2.UUCP writes: > ......... Then, I just changed the routines and used some GDOS functions > like Cauxin, Cauxout, Cauxis, and Cauxos. These seem to work fine, but > they do not use buffers. Yes, the BIOS aux: port routines are buffered. The default buffers are quite small, about 700 bytes if I remember correctly, but adequate for 1200 baud. You'll probably want more like 2K if you're going to use 2400 baud a lot. The function to change the buffers is Iorec (on page 350 of the 2.1.7 manual). Remember to save the old buffer information and restore it before your program exits. I wrote a simple vt52 emulator that sets up 8K input and output buffers, it runs fine at 19200 baud. > .................. I would like to write this BBS so that it doesn't > use too many system dependent functions. Is there any way I can access the > RS-232 port with the standard I/O functions or do I have to stick with > GDOS?? Also, I am using the right approach?? The way to do this, as always, is to ISOLATE the machine-dependant functions. Write a series of functions for talking to the serial port, like 'getichar', 'putochar', etc. Handle EOF in any manner that seems reasonable. Then when you move your BBS to another system, just re-write 'getichar', 'putochar', etc. -- /|\ Barnacle Wes @ Great Salt Lake Yacht Club, north branch / | \ @ J/22 #49, _d_J_i_n_n_i /__|__\ ___|____ "If I could just be sick, I'd be fine." ( / -- Joe Housely, owner of _E_p_i_d_e_m_i_c -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~