No output, Python serial port communication using RevPi Connect SE

Topics about the Software of Revolution Pi
Post Reply
user123
Posts: 2
Joined: 08 Mar 2024, 08:04
Answers: 0

No output, Python serial port communication using RevPi Connect SE

Post by user123 »

Hey i'am using for first time Python on a RevPi and i got some problem.
The RevPi (simular to Raspberry Pi) is connected via the RS485 serial port to a measurement sensor.

Code:


import serial

def init_serial():
ser = serial.Serial()
ser.baudrate = 9600
ser.port = '/dev/ttyUSB0'
ser.stopbits = serial.STOPBITS_ONE
ser.bytesize = 8
ser.parity = serial.PARITY_NONE
ser.rtscts = 0

return ser

def main():
ser = init_serial()
ser.open()

while True:
mHex = ser.read()
if len(mHex) != 0:
print("Received:", mHex.hex())
else:
print("No data received")
time.sleep(0.1)



i look forward to your support

here is a list of available ports :


python -m serial.tools.list_ports
/dev/ttyAMA0
/dev/ttyUSB0
/dev/ttyUSB1
3 ports found


I also tried this:

~ $ python -m serial.tools.miniterm

--- Available ports:
--- 1: /dev/ttyAMA0 'ttyAMA0'
--- 2: /dev/ttyUSB0 'FT232R USB UART'
--- 3: /dev/ttyUSB1 'FT232R USB UART'
--- Enter port index or full name: 2
--- Miniterm on /dev/ttyUSB0 9600,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---

--- exit ---
Exception in thread rx:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/lib/python2.7/dist-packages/serial/tools/miniterm.py", line 445, in reader
data = self.serial.read(self.serial.in_waiting or 1)
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 501, in read
'device reports readiness to read but returned no data '
SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
ivecontain
Posts: 1
Joined: 10 Apr 2024, 09:27
Answers: 0

Re: No output, Python serial port communication using RevPi Connect SE

Post by ivecontain »

It appears that you've tried listing the available ports using python -m serial.tools.list_ports and python -m serial.tools.miniterm, and you've identified the correct port (/dev/ttyUSB0).geometry dash lite
Post Reply