Hi.
For a project I need to access /dev/ttyACM0 from python on an APP LAB app.
By accessing the board via SSH I'm able to see correctly the device (a usb serial barcode scanner) but when the code is executed it seems that the "app container" can't interact with /dev*
[main] Activating python virtual environment
[main] Requirements already installed.
[main] Using Python 3.13.9 environment at: .cache/.venv
[main] Audited 1 package in 334ms
[main] Clearing cache at: .cache/uv
[main] Removed 6 files (1.1KiB)
[main] Traceback (most recent call last):
[main] File "/app/.cache/.venv/lib/python3.13/site-packages/serial/serialposix.py", line 322, in open
[main] self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
[main] ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[main] FileNotFoundError: [Errno 2] No such file or directory: '/dev/ttyACM0'
[main]
[main] During handling of the above exception, another exception occurred:
[main]
[main] Traceback (most recent call last):
[main] File "/app/python/main.py", line 23, in <module>
[main] main()
[main] ~~~~^^
[main] File "/app/python/main.py", line 7, in main
[main] ser = serial.Serial(PORT, BAUD, timeout=1)
[main] File "/app/.cache/.venv/lib/python3.13/site-packages/serial/serialutil.py", line 244, in __init__
[main] self.open()
[main] ~~~~~~~~~^^
[main] File "/app/.cache/.venv/lib/python3.13/site-packages/serial/serialposix.py", line 325, in open
[main] raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
[main] serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'
This is my simple code that I want to run:
import serial
PORT = "/dev/ttyACM0"
BAUD = 115200
def main():
ser = serial.Serial(PORT, BAUD, timeout=1)
buffer = b""
print("Pronto, in attesa di scansioni...")
while True:
b = ser.read(1)
if not b:
continue
if b in b"\r\n":
if buffer:
code = buffer.decode("ascii", errors="ignore")
print("Letto:", code, flush=True)
buffer = b""
else:
buffer += b
if __name__ == "__main__":
main()