>> I have figured out that the MS Comm object won't work over TS, as it returns an error.
>
>Could you post the error returned, some repro code and settings you used on the MSCOmm object and what event caused the error?
>
>Was it "PortOpen" or was it something else?
>
>Bernard
The error occurred in the MSComm object initialization. Said the port was being used by another application and to quit both applications and restart. No other application was open. The same application returns no errors when run from a PC.
I did find a workaround for this:
First we made sure the port was mapped in RDC settings. We also made sure that serial ports were allowed to be mapped on the TS. Once we logged in to TS, we ran the CHANGE PORTS command to display which ports were available and how they were mapped.
In the application, I disabled the initialization of the MSComm object. I then used code I found on UT to make a file with STRTOFILE() and then used a shell command to RUN PRINT /D:COM:1 test.txt
Here is a code snippet:
#DEFINE SOH CHR(1)
#DEFINE STX CHR(2)
#DEFINE ETX CHR(3)
#DEFINE EOT CHR(4)
lcFR = '11999'
lcStr = STX + '?:' + lcFR + ETX
STRTOFILE(lcStr, "test.txt")
lcStr = STX + ;
ALLTRIM(Block.Serial_Number) + ;
SOH
STRTOFILE(lcStr, "test.txt", 1)
STRTOFILE(EOT,"test.txt",1)
run print /D:com1 test.txt
ERASE test.txt
If anyone has a cleaner way of running this, I'm open to it. Hope this can help someone else who may be trying to print out to a serial port on Terminal Server.
Duty is ours, the results are God's - John Quincy Adams