4

I want to communicate with my serial port in python. I installed pyserial and uspp for linux:

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 <module>
 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'
GEOCHET
21.3k15 gold badges78 silver badges99 bronze badges
asked Oct 28, 2010 at 5:48
1

1 Answer 1

6

if you are working with linux, generally, serial ports are named /dev/tty* ; just replace the * with s and the number of the port like /dev/ttyS1. I work with a arduino that communicates via usb-serial, and it's /dev/ttyUSB0.

Coding Mash
3,3465 gold badges26 silver badges45 bronze badges
answered Aug 20, 2011 at 0:21
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.