I want to communicate with my serial port in python. I installed pyserial, and uspp for linux. Still, when I run the following code:
import serial
ser = serial.Serial('/dev/pts/1', 19200, timeout=1)
print ser.portstr #check which port was really used
ser.write("hello") #write a string
ser.close() #
it gives the following error:
Traceback (most recent call last):
File "poi.py", line 5, in ser.open()
File "/usr/local/lib/python2.6/dist-packages/pyserial-2.5-py2.6.egg/serial/serialposix.py",
line 276,
in open raise SerialException("could not open port %s: %s" % (self._port, msg)) serial.serialutil.SerialException:
could not open port /dev/tyUSB1: [Errno 2] No such file or directory: '/dev/tyUSB1'
What should I do?
Daenyth
37.8k15 gold badges92 silver badges131 bronze badges
asked Oct 29, 2010 at 12:34
user489712
911 gold badge2 silver badges6 bronze badges
-
3How do you get an error about /dev/tyUSB1 when you requested an open of /dev/pts/1?KevinDTimm– KevinDTimm2010年10月29日 15:28:48 +00:00Commented Oct 29, 2010 at 15:28
-
possible duplicate of python serial portOded– Oded2011年10月29日 11:58:34 +00:00Commented Oct 29, 2011 at 11:58
2 Answers 2
/dev/tyUSB1 looks like a typo. Device nodes are normally called /dev/ttyXXX
answered Oct 29, 2010 at 12:40
Sign up to request clarification or add additional context in comments.
Comments
If you want to open your second USB serial port, you want /dev/ttyUSB1 instead of /dev/tyUSB1.
answered Oct 29, 2010 at 12:41
Frédéric Hamidi
264k42 gold badges497 silver badges486 bronze badges
Comments
lang-py