December 2nd, 2012, 01:31 PM
Newbie. Serial Data & COM Ports.
I want to monitor serial ASCI data arriving at a USB port via a RS232 to USB converter.
A number years ago I wrote a QBasic program on a PC with a genuine serial port to perform a similar task and used a command to prepare the port setting baud rate, data bits and timeouts etc
OPEN "com1:9600,N,8,1,cd0,cs0,ds0,op0,rs,tb512,rb512" FOR RANDOM AS #2
and the following would identify the arrival of data at the port and start the decoding subroutine.
ON COM(1) GOSUB READRX
I would like to create a similar program using Python but have not yet been able to find information regarding establishing the coms with external devices. As my pc does not have a 'genuine' serial port the solution must be able to work through the USB port and the RS232 converter.
Using Python on a Windows XP PC
Any help much appeciated.
December 2nd, 2012, 02:59 PM
I liked the abasic play command.
In python, you can try
with inf as open('com1','r'):
[indent]inf.read(4) # read 4 bytes
I don't know how clever you'll need to be to make the code interrupt driven as your qbasic code probably was.
[/code] are essential for python code and Makefiles!