3cky / mbusd

Open-source Modbus TCP to Modbus RTU (RS-232/485) gateway.
BSD 3-Clause "New" or "Revised" License
575 stars 219 forks source link

Help with usb to RS485 - SH-U11 #93

Open jjhdtv opened 1 year ago

jjhdtv commented 1 year ago

I'm attempting to run mbusd on a openwrt device using a SH-U11 usb to RS485. I have tested the SH-U11 with a windows machine and it works.

The goal is to get the RS485 data from my Solar Inverter served up by mbusd on the openwrt machine and accessed by a different machine running home assistant. I have stumbled on others doing a similar setup and it seems to be a good fit in what I want to accomplish.

The log below shows my start up parameters, running mbusb, and a connection being made by the HA machine (local address 192.168.1.40). It is unclear to me if mbusd is working. Hopefully the log will tell the story to someone who understands it. I'm not receiving data on the HA machine. I have also been unsuccessful trying to connect with windows (running modpoll). I have also notice that when connected, the SH-U11 does not have blinking data LEDs for RX/TX. I believe it did when using windows/modpoll.

Appreciate the suggestions,

log below:

root@OpenWrt:~# mbusd -L/tmp/mbusd.log -s 9600 -T 1000 -P 502 -d -v9

02 Apr 2023 06:31:44 mbusd-0.5.0 started... 02 Apr 2023 06:31:44 tty: trying to open /dev/ttyS0 (speed 9600 mode 8N1) 02 Apr 2023 06:31:44 tty: state now is TTY_PAUSE 02 Apr 2023 06:31:44 conn_loop(): select(): max_sd = 4, t_out = 217673204:000000 02 Apr 2023 06:31:44 conn_loop(): select() returns 0 02 Apr 2023 06:31:44 tty: state now is TTY_READY 02 Apr 2023 06:31:44 conn_loop(): select(): max_sd = 4, t_out = 243484302:000000 02 Apr 2023 06:32:00 conn_loop(): select() returns 1 02 Apr 2023 06:32:00 conn_open(): accepting connection from 192.168.1.40 02 Apr 2023 06:32:00 queue_new_elem(): length now is 1 02 Apr 2023 06:32:00 conn[192.168.1.40]: state now is CONN_HEADER 02 Apr 2023 06:32:00 conn_loop(): select(): max_sd = 5, t_out = 14618308:000000 02 Apr 2023 06:32:00 conn_loop(): select() returns 1 02 Apr 2023 06:32:00 conn[192.168.1.40]: state now is CONN_RQST_FUNC 02 Apr 2023 06:32:00 conn_loop(): select(): max_sd = 5, t_out = 15173046:000000 02 Apr 2023 06:32:00 conn_loop(): select() returns 1 02 Apr 2023 06:32:00 conn[192.168.1.40]: read request fc 3 02 Apr 2023 06:32:00 conn[192.168.1.40]: state now is CONN_RQST_TAIL 02 Apr 2023 06:32:00 conn[192.168.1.40]: request: [01][03][00][03][00][05] 02 Apr 2023 06:32:00 conn[192.168.1.40]: state now is CONN_TTY 02 Apr 2023 06:32:00 tty: state now is TTY_RQST 02 Apr 2023 06:32:00 conn_loop(): select(): max_sd = 4, t_out = 17534273:000000 02 Apr 2023 06:32:00 conn_loop(): select() returns 1 02 Apr 2023 06:32:00 tty: written 8 bytes 02 Apr 2023 06:32:00 tty: request written (total 8 bytes) 02 Apr 2023 06:32:00 tty: state now is TTY_RESP 02 Apr 2023 06:32:00 tty: estimated 15 bytes, waiting 523958 usec 02 Apr 2023 06:32:00 conn_loop(): select(): max_sd = 4, t_out = 19122927:000000 02 Apr 2023 06:32:00 conn_loop(): select() returns 0 02 Apr 2023 06:32:00 tty: response timeout 02 Apr 2023 06:32:00 tty: attempt to retry request (1 of 3) 02 Apr 2023 06:32:00 tty: state now is TTY_RQST 02 Apr 2023 06:32:00 tty: written 8 bytes 02 Apr 2023 06:32:00 tty: request written (total 8 bytes) 02 Apr 2023 06:32:00 tty: state now is TTY_RESP 02 Apr 2023 06:32:00 tty: estimated 15 bytes, waiting 523958 usec 02 Apr 2023 06:32:00 conn_loop(): select(): max_sd = 4, t_out = 152089299:000000 02 Apr 2023 06:32:01 conn_loop(): select() returns 0 02 Apr 2023 06:32:01 tty: response timeout 02 Apr 2023 06:32:01 tty: attempt to retry request (2 of 3) 02 Apr 2023 06:32:01 tty: state now is TTY_RQST 02 Apr 2023 06:32:01 tty: written 8 bytes 02 Apr 2023 06:32:01 tty: request written (total 8 bytes) 02 Apr 2023 06:32:01 tty: state now is TTY_RESP 02 Apr 2023 06:32:01 tty: estimated 15 bytes, waiting 523958 usec 02 Apr 2023 06:32:01 conn_loop(): select(): max_sd = 4, t_out = 35013825:000000 02 Apr 2023 06:32:01 conn_loop(): select() returns 0 02 Apr 2023 06:32:01 tty: response timeout 02 Apr 2023 06:32:01 tty: attempt to retry request (3 of 3) 02 Apr 2023 06:32:01 tty: state now is TTY_RQST 02 Apr 2023 06:32:01 tty: written 8 bytes 02 Apr 2023 06:32:01 tty: request written (total 8 bytes) 02 Apr 2023 06:32:01 tty: state now is TTY_RESP 02 Apr 2023 06:32:01 tty: estimated 15 bytes, waiting 523958 usec 02 Apr 2023 06:32:01 conn_loop(): select(): max_sd = 4, t_out = 168449085:000000 ^C02 Apr 2023 06:32:02 conn_loop(): select() returns -1 02 Apr 2023 06:32:02 conn_loop(): error in select() (Invalid argument) 02 Apr 2023 06:32:02 conn_open(): error in accept() (Resource temporarily unavailable) 02 Apr 2023 06:32:02 tty: error in read() (Resource temporarily unavailable) 02 Apr 2023 06:32:02 trying to re-open tty... 02 Apr 2023 06:32:02 tty re-opening... 02 Apr 2023 06:32:02 tty: trying to open /dev/ttyS0 (speed 9600 mode 8N1) 02 Apr 2023 06:32:02 tty: state now is TTY_PAUSE 02 Apr 2023 06:32:02 tty re-opened. 02 Apr 2023 06:32:02 tty: read -1 bytes 02 Apr 2023 06:32:02 tty: read 255 bytes of 15, offset 0 02 Apr 2023 06:32:02 Terminated by signal: SIGINT root@OpenWrt:~#

jjhdtv commented 1 year ago

I was able to get it going by installing kmod-usb-serial-ftdi. Now my U11 has a ttyUSB0 address and things are working.