Question

could not open port /dev/ttyAMA0: [Errno 2] No such file or directory: '/dev/ttyAMA0'

I am using cp2102 usb to uart bridge which is installed on linux kernel 3.x.x

>>> import serial
>>> port = serial.Serial("/dev/ttyAMA0", baudrate=115200, timeout=3.0)

it gives the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 260, in __init__
    self.open()
  File "/usr/lib/python2.7/dist-packages/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/ttyAMA0: [Errno 2] No such file or directory: '/dev/ttyAMA0'
Was it helpful?

Solution

The solution was logging in /dev/ and seeing what's listed there and probably u'll find a directory called serial The code for this

ls /dev/serial/by-id/

and replace the name of the device by ttyAM0 for me it become

 serial.Serial("/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0", baudrate=115200, timeout=3.0)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top