controlling a qbasic program on a windows98 or example of rs-232 commanded through python

Peter Hansen peter at engcorp.com
Sat Feb 19 20:38:18 EST 2005


serpent17 at gmail.com wrote:
> Can python be installed on a win98 system ? 

Yes.  The Windows version of Python works on most versions of Windows
including Win98.

> if so, how do I control a qbasic program from python ?

Given the rest of your posting, I would say "don't bother".

> the qbasic program controls input to an RS-232 so I am enclined to
> follow the win98 system + qbasic route in order to be quick, or I guess
> the question could be, can I control a device through rs-232 from a
> newer version of windows using python (actually for the last part of
> the question I know this is feasible, but I 'd like to see an example,
> any pointers ?)

Download PySerial and you'll easily be able to do this.  There
are doubtless numerous examples you could find easily with
Google, but if you really want to look at an example of one
that is too complex to be of much use for basic learning purposes,
check this out: http://web.engcorp.com/main/projects/CavroCom .

There's a lot more here than just the serial port stuff, but it
*is* an example of working code that is in actual use, so
perhaps it's better in some ways than some snippets you might
find.  Still, PySerial is pretty darn easy to use, so don't
waste too much time looking at the above project.  The following
shows how to send data to a device using PySerial and receive
a reply:

 >>> import serial
 >>> s = serial.Serial('COM1')
 >>> s.timeout = 1
 >>> s.write('some command\r\n')
 >>> s.read(50)
'some reply\r\n'
 >>>

It's about that easy...

-Peter



More information about the Python-list mailing list