I have a webcam that I would like to be able to steer in X and Y way. To that I'm going to use two engines and some Lego. The two engines are connected to a microprocessor which is connected to the COM-port attached to my laptop.
So I thought it would be easy to use Python, acctually I'm not well-known with Python though I've used PHP. So I installed pyserial and just tried to open the serial port like this (as said in the short introduction at
http://pyserial.sourceforge.net/):CODE
>>> import serial
>>> ser = serial.Serial(0)
>>> print ser.portstr
>>> ser.write("hello")
>>> ser.close()
Though I get an error message:
CODE
[root@localhost xiph]# python test.py
Traceback (most recent call last):
File "test.py", line 2, in <module>
ser = serial.Serial(0);
File "/usr/lib/python2.5/site-packages/serial/serialutil.py", line 156, in __init__
self.open()
File "/usr/lib/python2.5/site-packages/serial/serialposix.py", line 144, in open
self._reconfigurePort()
File "/usr/lib/python2.5/site-packages/serial/serialposix.py", line 158, in _reconfigurePort
raise SerialException("Could not configure port: %s" % msg)
serial.serialutil.SerialException: Could not configure port: (5, 'Input/output error')
Anyone who can help me out here?
EDIT: It seems that I haven't located the serial port properly. I'll be back with more info.
EDIT2: Got it working, just had to specify the serial port like this instead:
CODE
ser = serial.Serial('/dev/pts/2', 19200, timeout=1)
instead of this:
CODE
ser = serial.Serial(0)
This post has been edited by Xiph: 20 Apr, 2008 - 05:57 PM