27/02/2018, 09:19
Salve a tutti, ho necessità di usare il porta seriale con il Raspberry 3.
Per fare cio' mi sono avvalso della guida su pyserial per capire come gestire la seriale.
Il problema arriva subito con la prime 2/3 righe.
Da guida :
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 265, in open
self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/ttyUSB0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
ser=serial.Serial('/dev/ttyUSB0')
File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 236, in __init__
self.open()
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 268, in open
raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyUSB0: [Errno 2] No such file or directory: '/dev/ttyUSB0'
Se io scrivo invece, un suggerimento preso da un post di Zeed di qualche tempo fa :
Ottengo il seguente errore :
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 265, in open
self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
PermissionError: [Errno 13] Permission denied: '/dev/serial0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
ser=serial.Serial('/dev/serial0')
File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 236, in __init__
self.open()
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 268, in open
raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 13] could not open port /dev/serial0: [Errno 13] Permission denied: '/dev/serial0'
Sono quindi a chiedere, cosa NON ho impostato nel Raspberry ??
Grazie
Per fare cio' mi sono avvalso della guida su pyserial per capire come gestire la seriale.
Il problema arriva subito con la prime 2/3 righe.
Da guida :
Codice:
import serial
ser = serial.Serial ('/dev/ttyUSB0') # gia' questo da un errore
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 265, in open
self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/ttyUSB0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
ser=serial.Serial('/dev/ttyUSB0')
File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 236, in __init__
self.open()
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 268, in open
raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyUSB0: [Errno 2] No such file or directory: '/dev/ttyUSB0'
Se io scrivo invece, un suggerimento preso da un post di Zeed di qualche tempo fa :
Codice:
import serial
ser = serial.Serial('/dev/serial0')
Ottengo il seguente errore :
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 265, in open
self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
PermissionError: [Errno 13] Permission denied: '/dev/serial0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
ser=serial.Serial('/dev/serial0')
File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 236, in __init__
self.open()
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 268, in open
raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 13] could not open port /dev/serial0: [Errno 13] Permission denied: '/dev/serial0'
Sono quindi a chiedere, cosa NON ho impostato nel Raspberry ??
Grazie
Alberto