Serial Receiving from Arduino to Raspberry Pi with PySerial stops after a while

后端 未结 5 829
小蘑菇
小蘑菇 2021-01-04 19:09

I\'m working on a project in which I have to receive some 25 character data at a time in order to process it in Raspberry Pi. Here is the example code that generates some da

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-04 19:29

    I had the same problem and was breaking my head for a good time, try this

    Run

    ps -ef | grep tty
    

    If the output looks anything like

    root      2522     1  0 06:08 ?        00:00:00 /sbin/getty -L ttyAMA0 115200 vt100
    

    Then you need to disable getty from trying to send data to that port

    In order to use the Raspberry Pi’s serial port, we need to disable getty (the program that displays login screen) by find this line in file /etc/inittab

    T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
    

    And comment it out by adding # in front of it

    #T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100)
    

    To prevents the Raspberry Pi from sending out data to the serial ports when it boots, go to file /boot/cmdline.txt and find the line and remove it

    console=ttyAMA0,115200 kgdboc=ttyAMA0,115200
    

    Reboot the Raspberry Pi

    Credit where credit is due: http://blog.oscarliang.net/raspberry-pi-and-arduino-connected-serial-gpio/ helped me figure out how to diable getty

提交回复
热议问题