0

I have an RS-485 Shield that im using but none of the sample code or online guides for this that i can find seem to work. I'm not interested at this stage in doing anything with the data i just want to see a data stream of bits as i want to troubleshoot a network to see if is actually transmitting data.

The baudrate is 19200.

the code im using is as follows from (https://wiki.seeedstudio.com/RS-485_Shield_for_Raspberry_Pi/) with some edits.

#!/usr/bin/env python

import time
import serial
import os
from gpiozero import LED

ser = serial.Serial(port='/dev/serial0',baudrate =19200,timeout=1)
data = ''

Rx_Disable = LED(18)
Rx_Disable.off()

while True:
    str = ser.readall()  
    if str:  
        print str 

Any idea what im doing wrong?

2
  • Do you mean apart from the invalid python which should generate errors. Have you enabled serial?
    – Milliways
    Commented May 2 at 5:31
  • I changed the variable name from str to somthing less likely to casue an issue and put () in the print statement. Its not a syntax issue, the program runs but there is no output even though the RX LED on the shield is flashing. Serial is enabled and the config.txt file confrims this.
    – Elliott
    Commented May 2 at 22:05

0

Browse other questions tagged or ask your own question.