Question

I'm trying to use PySerial on a Raspberry Pi with Arch Linux installed. I've installed pyserial onto python2(.7) since $ python links straight to python3 and python serial isn't really that convenient to use on python 3.x.

I then tried running a really simple Python script that writes to the TX port on the RPi and reads off the RX port

# send
ser = serial.Serial("/dev/ttyAMA0")
ser.write("HI THERE\n")

# receive
read = ser.readline()
print (read)

The script 'runs' but just hangs. When I run it line by line on the Python 2.7 shell it hangs too at ser.write("HI THERE\n"). I ran the same script on the same RPi with a Raspbian OS and it worked perfectly fine. And yes, the TX and RX ports were connected all the time. Anyone has a clue about this?

Was it helpful?

Solution

Just to be sure of what you mean by "installed pyserial onto python2(.7)", you need to install "python2-pyserial" (notice the "2") and not "python-pyserial".

Also, if you specified a path to use the python binary you took good care of using "/bin/python2" right?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top