I have a DNC type app that I wrote back in '92 that sends CNC files to punch press controllers and it uses only the FP provided low level functions. Has worked great all these years... Now I'm having to redo it for NT, but that's another thread (shortly)!
On the 7 PCs (5 Win95 - 2 DOS) that I have this running on, I set an environment variable with the proper comm parameters in the Autoexec.bat file and call mode there also:
:: **** GMAN section - Don't screw with this section ****
SET PORTCFG=COM2:4800,E,7,1
mode %portcfg%
:: **** End GMAN section ****
In my PRG I have something like:
M.comset=GETENV('PORTCFG')
M.comset=IIF(LEN(M.comset) < 15,'COM1:4800,E,7,1',M.comset)
! MODE &M.comset >NUL
...
M.cport=LEFT(M.comset,4)
chandl=FOPEN(M.cport,12)
IF chandl < 0
WAIT WINDOW 'CAN NOT OPEN COM PORT !! 'NOWAIT
CANCEL
ENDIF
...
The user types in the filename of the CNC file to download and I do a few other things, then I eventually get to a hard loop that waits to for an XON char(17) from the controller. This is all from memory but it's something like:
ON ESCAPE DO whatever
DO WHILE PATIENT
OK=Fread(chandl,1)
PATIENT=IIF(ok=chr(17),.F.,.T.)
ENDDO
Once I got through the loop I just started sending the file line by line with FPUTS. A final FPUTS(chandl,'%') tells this controller I'm through. This may seem very crude, but I've never had any buffer overruns on the controllers.
GMAN [sig][/sig]