Writing to COM ports, again (AREV Specific)
At 29 DEC 2000 12:18:34PM David Cooksley wrote:
I've been searching these discussions on writing to COM ports, and realize I don't have documentation handy for V123/V124 calls. Can someone email me those docs?
I have a Rev 2.12 application running in a DOS session under Win9x (and probably W2K within a year). The application needs to write a text string with embedded binary commands to a label printer on the COM1 port. At first, I was going to use a utility provided by the labeler mfg (DYMO) which accepts a DOS file as input and writes the contents to the COM port. The utility works from a DOS window directly, however it hangs when called from Rev. It doesn't seem to matter whether I shell with SUSPEND, PC, or PCPERFORM, so I figure there is something in the Rev environment that is the problem. Either I need to initialize the COM port for Rev, or write my own routine with OUT or V123/124. Any insight will be appreciated.
Thanks for your help.
David Cooksley, SAIC
At 29 DEC 2000 01:26PM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:
David,
You may have problems initializing commdrv.ibm in the Windows
environment, or on faster UARTS (it was designed to work with
the 8250 chip - older serial ports, not the 16550 chip on later
faster serial ports). This device driver also has timing loops,
which means that a 486 class machine may behave better than a
Pentium in this case.
The basic Sprezzatura docs are at:
http://www.sprezzatura.com/V1I9A14.HTM
http://www.sprezzatura.com/V1I9A15.HTM
And AREV's utility.doc file V124.TEXT record contents appear as follows:
<code>
V124 - Communications Interface subroutineIntroduction
V124 is an assembler routine in the VERBS file. It is used to interface R/BASIC and the communications (serial, asynchronous) port.
V124 can be called from within R/BASIC to read and write information to any serial port. V124 in turn interfaces with a device driver loaded in the CONFIG.SYS file. The device driver (COMMDRV.IBM) is provided in the UTILITY.DOS file on the utility diskette.
(For information on loading the communications device driver, see the documentation under TERM in the Technical Reference manual.)
Calling V124
V124 is called with this syntax:
CALL V124(ACTION,HANDLE,VAR,BYTES,FLAG)where ACTION:
=OP' to open the device handle =CI' for an IOCTL read. =CO' for an IOCTL write. =TB' when testing for the break key. =RD' to read from the handle =WR' to write to the handle =CL' to close the handle =EX' to expand message and compute checksum for RCOMM =CP' to compress and compute checksum for RCOMM HANDLE =dos handle for the device FLAG =0 if action finished O.K. =1 if action did not finish O.K.Specifics about the ACTION argument
CI ("Control In") is used to read the current settings (baud rate, etc.) for the port.
CALL V124(ACTION,HANDLE,VAR,BYTES,FLAG) CALL V124('CI', HANDLE,VAR,7, FLAG)Where VAR will contain the present setting of the PORT.
VAR =variable read/written for actions CI and CO. BYTES =number of bytes to input for action CI. FLAG =0 if action CI finished O.K. =1 if action CI did not finish O.K.The VAR returns a string where each byte equals a setting. FLAG is empty when it is able to return VAR. 7 is the number to bytes to return.
1234567 VAR=####### ||||||| 1 Rate code----+|||||| 2 Stop bits-----+||||| 3 Num Bits-------+|||| 4 Parity----------+||| 5 Protocol-(Low)---+|| 6 Protocol-(High)---+| 7 Break Count--------+RATE.CODE =SEQ(VAR1,1) Returns a code where all possible baud rates are numbered.STOP.BITS =SEQ(VAR2,1) Returns the number of stop bitsNUMBER.OF.BITS=SEQ(VAR3,1) The number of data bitsPARITY =SEQ(VAR4,1) Parity checking mode.PROTOCOL =SEQ(VAR6,1)*256+SEQ(VAR5,1)PROTOCOL contains bit wise data1111111 6543210987654321 PROTOCOL= ################ | | 16. Strip--------------+ | 4. XOFF-----------------+STRIP=BITAND(PROTOCOL,16) XOFF =BITAND(PROTOCOL, 4)BREAK.COUNT =SEQ(VAR7,1)
CO ("Control Out") is used to set the parameters for the port.
CALL V124('CO',HANDLE,VAR)Where VAR contains the setting for the PORT. See Action 'CI' for the meaning of the 7th byte you need to set.
CL ("Close") is used to close the file handle returned by an earlier OP call.
CALL V124('CL',HANDLE)ALWAYS CLOSE THE HANDLE WHEN DONE. Note that this differs from normal Revelation file I/O, but is similar to the protocol required for OSBREAD and OSBWRITE. Failure to do so can result in file corruption at the next I/O function!
If you are developing software, and your program breaks before the handle gets closed, it is a good idea to go out and close the handle by another means. One way to do this is by going into TERM or PORT.
OP ("Open") opens the communications port and assigns it a file handle. All subsequent I/O activity will make use of this handle. Note! You MUST close this file handle (with a CL call) before you exit your program.
FLUSH CALL V124('OP',HANDLE,'COMM$':CHAR(0),'',FLAG)FLAG =0 if the driver was OPened OK =1 if it failed to open the driver (chances are the commdrv.IBM was not loaded by the config.sys)Be sure to FLUSH before opening the communications driver. If you do not, the first attempt to access the port will work, but the attempts afterward likely will not.
Opening more than one port simultaneously
You can load and access more than one communications device driver at once. This enables you to open more than one, and perform I/O to more than one from within a single R/BASIC program.
To do this, you will need to copy the COMMDRV.IBM program, and make changes to the object code. Follow these instructions:
1. Copy the COMMDRV.IBM to COMMDRV.TWO so you have one to modify.
2. Modify the internal label of the second driver. It is 8 characters long and looks like this: 'COMM$ '. You will need to edit this file with an editor that will not be "confused" by low-order ASCII characters (The Sprezzatura Group[/url]
World Leaders in all things RevSoft
At 29 DEC 2000 01:55PM Captn Kirk wrote:
The Suppliers site has a download for printer drivers for Windows. With this loaded you should be able to send your output directly to the Labeler.
Captn Kirk
At 02 JAN 2001 08:53PM David Cooksley wrote:
Thanks for your suggestions. One more question: what are the parameters to commdrv.ibm (as in Device=COMMDRV.IBM 4000,1)?
At 11 JAN 2001 04:35PM Leon Shaffer wrote:
Just FYI
A very very good utility program to print to COM ports (including UART 16550 ports) - works directly with AREV as well -
Willies Computer Software Co (wcsc)
Information on the products is there.