Serial port Input/Output conflicts
James Keen
jwk at mrao.cam.ac.uk
Thu Feb 7 10:29:35 EST 2002
I have been trying to write software to control a device via the
serial port on a Linux machine. I can send data sucessfully but when I
send a status request (a command line that asks my hardware to send
back some information) it disables my ability to send anything else.
The status data gets sent to the port from my Hardware, which I can
read, but the serial port refuses to send any more commands to my
hardware until I close and then reopen the port.
Any ideas?
If you're interested I've included the pertenent bits of my code...
import sys,os, fcntl, FCNTL, termios, TERMIOS
serial = os.open('/dev/ttyS1', FCNTL.O_RDWR|os.O_NDELAY,0)
def SendToMotor(axis, message):
global serial
os.write(serial,str(axis)+' '+message+'\n')
def ReadMotor():
global serial
a=''
while (a != '\n'):
a=os.read(serial,1)
print '['+a+']'
def quit(self):
os.close(serial)
Thanks in advance
James Keen
More information about the Python-list
mailing list