Reading com port with ReadLn>COM1:,1,line

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Reading com port with ReadLn>COM1:,1,line

Post by rullbandspelare » Fri Apr 25, 2008 6:41 am

I want to catch the input on COM1 and tried to read the COM1 port as suggested. (instead of the way I am doing now, with hyperterminal and a complicated GUI manipulation)

Code: Select all

Label>start
ReadLn>COM1:,1,line
Message>%line%
goto>start

If I use hyperterminal on the other "end" typing manualy, the receiving computer catches the text OK. But when a "transfer" with a lot of data I am able to read the first 2 or three incoming lines but then i get:
%line%:
##ERR## - Code : 5

and

MS dialog:
---------------------------
I/O error 995.
---------------------------


I guess that this is XP error codes but if not, what could they be?
And what connection parameters will COM1: use? If I look in Device manager and compare with the c:\>mode com1: they are not the same? I have changed to use Xon/Xoff everywhere

Thanks!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Apr 25, 2008 7:34 am

5: Access Denied

995: The I/O operation has been aborted because of either a thread exit or an application request.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Post by rullbandspelare » Wed Apr 30, 2008 8:37 am

I am trying a new approach.
I use port.dll to read the com1 and the dll gives me the ASCII codes comming.

Is there a simple MS way to translate the ASCII to character like the MS ASCII> command combined with the WriteLN> or chr()
Thanks!

Code: Select all

Let>count=0
Let>WLN_NOCRLF=1
LibLoad>C:\PORT.DLL,port
Let>open=COM1:2400,8,N,1
LibFunc>port,OPENCOM,T,open
Label>loop
//Read COM1
LibFunc>port,READBYTE,byte
message>%byte%
wait>.1
If>byte=-1,loop
// Write ASCII code to dll_dos.ps
writeln>dll_dos.ps,x,%byte%
Let>count=%count%+1
If>%count%=5,,loop
LibFunc>port,CLOSECOM,T

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Apr 30, 2008 8:43 am

Yes, just use VBScript's Chr function:

VBEval>chr(%byte%),character
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts