简体   繁体   中英

Why when I upgrade glibc to 2.29 then i try set serial port, function return "Input/output error"?

I am writing a simple program to open the serial port /dev/ttyS0 which is visible in /dev.

The code opens the serial port no problems when i use glibc-2.28 on raspberry pi 4 but when i upgrade glibc to 2.29, the error happened, because some reason that i have to upgrade glibc to 2.29.

Here is my python code, do anyone know how to solve it? thanks

    #RS485
    def RS485_initial(self):
        MODE = 0 #mode = 0 is full-guto, mode = 1 is half-auto
        if MODE == 1:
            EN_485 =  4
            GPIO.setmode(GPIO.BCM)
            GPIO.setup(EN_485,GPIO.OUT)
            GPIO.output(EN_485,GPIO.HIGH)
        self.ser = serial.Serial("/dev/ttyS0",115200,timeout=1)     

    #RS232
    def RS232_initial(self):
        self.ser = serial.Serial("/dev/ttyS0", 9600, timeout=1) #port, baudrate

在此处输入图像描述

I got error code as below

File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 240, in __init__
    self.open()
  File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 272, in open
    self._reconfigure_port(force_update=True)
  File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 326, in _reconfigure_port
    raise SerialException("Could not configure port: {}".format(msg))
serial.serialutil.SerialException: Could not configure port: (5, 'Input/output error')

I want to solve this problem, and run it on glibc-2.29

在此处输入图像描述

I find solution, when i update glibc to version 2.29 serial0 from ttyS0 to ttyAMA0, so i change

在此处输入图像描述 and it work!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM