Problem:
How can I read and write using a serial port with RM/COBOL in Windows?
Resolution:
COM port communication uses the normal file access method as demonstrated by the attached sample programs.
The COMTEST sample program writes via an open output; COMREAD is used to get input. You must check the equipment on the other end to make sure it is configured to accept both input and output from the COM port.
Make sure to check any cabling requirements the device may have. This is essential, as there are many types of cables and different pin configurations. There are straight through cables and Null Modem cables, and no doubt many others. You need to be sure that the cable pin-outs are correct for the device. This is not Liant's area of expertise, and we can't advise better on this, but the equipment being used should have a manual that explains how the cable must be configured.
In addition, you must set the port properties on the PC to what is required by the device.
These programs were tested using an old Honeywell dumb terminal connected to COM1 with a 9 to 25 pin cable. Attached is a document showing the port settings that were required by the terminal during the tests.
Note:
Unless the data uses a fixed record size, you may have to define record size of one character, as in the example, and then format the data as it comes across.