-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mbusd stops responding and goes into spin shortly after being started #41
Comments
Hmm, interesting. Is mbusd the only master on the RS485 bus? Looks like mbusd is receiving some unexpected data from the bus while it's in idle state. Nevertheless, it shouldn't go into infinite loop in this case. I'll take a look into the code. |
Yes, it is the only master. There are three slaves: two energy meters and one HVAC system. I'll try to watch the interface to see if there is something unexpected being received on it.. |
I did some fixes in serial port initialization code, please rebuild mbusd with the updated code and check is something changed or not. |
I investigated a bit further, it seems my device (FT232R USB UART) is being reset now and then, for yet unknown reasons. Anyway, output from updated code below: $ sudo ./mbusd -d -v 9 -p /dev/ttyPort0 -s 9600 -t |
Indeed looks like hardware problem. I've added serial port reinitialization to avoid a "tty: read 0 bytes" message endless loop, but anyway this situation isn't seem normal to me. Could you please to try run your setup with the updated code? |
Yes, there is definitely a problem with the RS485 USB interface. After detecting the EOF it takes a while for it to re-appear. Tried the updated code, but mbusd still goes into spin: $ sudo ./mbusd -d -v 9 -p /dev/ttyPort0 -s 9600 -t |
@fredriklj I've implemented a more robust serial port reconnect algorithm in b5e3c53, please test. |
Nice. It has been running smoothly now for about half an hour: 04 Jan 2019 19:07:06 conn_loop(): select() returns 1 |
Great, did you find the cause of the adapter resets? Is it mbusd related, or it's also observed with other software? |
I can observe EOF by just "sudo od -x < /dev/ttyPort0", so that part does not seem mbusd related. I will investigate further to see if it is the USB-RS485 misbehaving, or something at the bus. |
Currently I suspect the error to have been a bad USB cable which picked up electro-magnetic interference from the environment. After having replaced it the re-connection errors seem to have gone away! |
That's great! Glad you sorted this out. Thank you for the participation, I'll close this issue, feel free to reopen it or create new one in case of further problems. |
Just started playing with mbusd to have a tcp interface to my modbus devices the RS485 bus (there is currently three devices on the bus). Maybe I'm doing something fundamental wrong, but I can't make much out of the debugging output.
Shortly, at least within a few minutes after being started, mbusd stops responding. When I run in the the foreground with debugging enabled I get the output below. Have played around with the timeout parameters (-T and -W respectively but can't get any difference). What could be the issue?
$ sudo ./mbusd -d -v 9 -p /dev/ttyPort0 -s 9600 -t
01 Jan 2019 17:11:14 mbusd-0.3.1 started...
01 Jan 2019 17:11:14 tty: state now is TTY_PAUSE
01 Jan 2019 17:11:14 conn_loop(): select(): max_sd = 4, t_out = 000000:100000
01 Jan 2019 17:11:14 conn_loop(): select() returns 0
01 Jan 2019 17:11:14 tty: state now is TTY_READY
01 Jan 2019 17:11:14 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:16 conn_loop(): select() returns 1
01 Jan 2019 17:11:16 conn_open(): accepting connection from 127.0.0.1
01 Jan 2019 17:11:16 queue_new_elem(): length now is 1
01 Jan 2019 17:11:16 conn[127.0.0.1]: state now is CONN_HEADER
01 Jan 2019 17:11:16 conn_loop(): select(): max_sd = 5, t_out = 000060:000000
01 Jan 2019 17:11:16 conn_loop(): select() returns 1
01 Jan 2019 17:11:16 conn[127.0.0.1]: state now is CONN_RQST_FUNC
01 Jan 2019 17:11:16 conn[127.0.0.1]: read request fc 3
01 Jan 2019 17:11:16 conn[127.0.0.1]: state now is CONN_RQST_TAIL
01 Jan 2019 17:11:16 conn[127.0.0.1]: request: [03][03][00][2b][00][01]
01 Jan 2019 17:11:16 conn[127.0.0.1]: state now is CONN_TTY
01 Jan 2019 17:11:16 tty: state now is TTY_RQST
01 Jan 2019 17:11:16 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:16 conn_loop(): select() returns 1
01 Jan 2019 17:11:16 tty: written 8 bytes
01 Jan 2019 17:11:16 tty: request written (total 8 bytes)
01 Jan 2019 17:11:16 tty: state now is TTY_RESP
01 Jan 2019 17:11:16 tty: estimated 7 bytes, waiting 515624 usec
01 Jan 2019 17:11:16 conn_loop(): select(): max_sd = 4, t_out = 000000:515624
01 Jan 2019 17:11:16 conn_loop(): select() returns 1
01 Jan 2019 17:11:16 tty: read 7 bytes
01 Jan 2019 17:11:16 tty: rx offset is 0
01 Jan 2019 17:11:16 tty: read 7 bytes of 7, offset 0
01 Jan 2019 17:11:16 tty: state now is TTY_PROC
01 Jan 2019 17:11:16 tty: response read (total 7 bytes, offset 0 bytes)
01 Jan 2019 17:11:16 tty: response is correct
01 Jan 2019 17:11:16 tty: response: [03][03][02][00][01][00][44]
01 Jan 2019 17:11:16 conn[127.0.0.1]: state now is CONN_RESP
01 Jan 2019 17:11:16 tty: state now is TTY_PAUSE
01 Jan 2019 17:11:16 conn_loop(): select(): max_sd = 5, t_out = 000000:100000
01 Jan 2019 17:11:16 conn_loop(): select() returns 1
01 Jan 2019 17:11:16 conn[127.0.0.1]: state now is CONN_HEADER
01 Jan 2019 17:11:16 conn_loop(): select(): max_sd = 5, t_out = 000000:099508
01 Jan 2019 17:11:16 conn_loop(): select() returns 1
01 Jan 2019 17:11:16 conn_close(): closing connection from 127.0.0.1
01 Jan 2019 17:11:16 queue_delete_elem(): length now is 0
01 Jan 2019 17:11:16 conn_loop(): select(): max_sd = 4, t_out = 000000:098566
01 Jan 2019 17:11:16 conn_loop(): select() returns 0
01 Jan 2019 17:11:16 tty: state now is TTY_READY
01 Jan 2019 17:11:16 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped 0 bytes
01 Jan 2019 17:11:23 conn_loop(): select(): max_sd = 4, t_out = 000060:000000
01 Jan 2019 17:11:23 conn_loop(): select() returns 1
01 Jan 2019 17:11:23 tty: dropped
The text was updated successfully, but these errors were encountered: