We need to use RS485 to talk to one of our custom tools. We need to use hardware controlled rts/cts. I've read so many articles about this but nobody ever says it works for them with fast timing and hardware controlled.
However, I can't get it working, I think it is being software controlled still because our timings are really long. RTS may be working but its changing weird. We are seeing 250us before and after, but not the values we want of 3.5us before and 1us after.
Here is what I have done:
disabled and removed bluetooth completely.
/boot/config.txtto add the following:
enable_uart=1 init_uart_clock=16000000 gpu_mem=256 dtoverlay=pi3-disable-bt gpio=17=a3 dtoverlay=miniuart-ctsrts
I can then check to see that GPIO17 is in RTS0 mode:
root@raspberrypi:/# raspi-gpio get 17 GPIO 17: level=1 fsel=7 alt=3 func=RTS0
boot/cmdline.txtto the following:
dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=7fa4337c-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
ran this: https://github.com/mholling/rpirtscts
I am using PySerial and working with rs485 in this way PySerial docs:
ser = serial.rs485.RS485( port='/dev/serial0', baudrate=1000000, timeout=0.1, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, xonxoff = False, #enable software flow control rtscts = True, #enable hardware (RTS/CTS) flow control dsrdtr = True, #disable hardware (DSR/DTR) flow control write_timeout=0.1 ) ser.rs485_mode = serial.rs485.RS485Settings( rts_level_for_tx=False, rts_level_for_rx=True, loopback=False, delay_before_tx=0.0000035, delay_before_rx=0.0000001 )
- Here is my serial ports in
root@raspberrypi:/dev# ls -al serial* ttyA* lrwxrwxrwx 1 root root 7 Sep 17 09:47 serial0 -> ttyAMA0 lrwxrwxrwx 1 root root 5 Sep 17 09:47 serial1 -> ttyS0 crw-rw---- 1 root dialout 204, 64 Sep 17 10:15 ttyAMA0
The caveat is that this could be working,but maybe not observing the delays we have in place. I don't know if the Pi 4 hardware is even capable of these very fast times. Looking on an oscilloscope, I can see data but it isn't stopping as quickly as I have specified so that leads me to believe that hardware control isn't working and I am in still in software controlled mode.
A few pictures: