kk7ds / pynx584

Python library and server for talking to NX584/NX8E interfaces
GNU General Public License v3.0
29 stars 26 forks source link

Question/Query - losing connection after a few hours #86

Closed cordenr closed 10 months ago

cordenr commented 10 months ago

Hi,

There's only a slim chance that this is going to be due to something in pynx584 directly - but I hope you don't mind me picking your brain a bit.

The TL;DR; version is that pynx584 loses connection with the NX584 after working initially.

I have my NX584 connected to a Raspberry PI with a serial gender changer followed by a serial to USB converter and then a 15m USB active extension cable. Everything worked great initially and there was a few days where all activity was reported back to the client and also to HomeAssistant.

Unfortunately after about 3 days, the connection between pynx584 and NX584 was lost.

After disconnecting and reconnecting the USB cable and restarting the daemon, the connection came back up however, it lasted less time. Each time it feels like it loses the connection sooner - and today, after testing with the binary protocol, the connection was lost after just an hour.

Is this something that you've come across before?

I have run the server with --debug and after a while there is no response from the heartbeat:

2024-01-06 19:18:56,949 controller INFO No activity for a while, heartbeating
2024-01-06 19:18:57,201 controller DEBUG Sending queued [40]
2024-01-06 19:18:57,225 controller DEBUG Received: 8 System Status (data [11, 0, 0, 0, 0, 66, 0, 0, 0, 1, 59])
2024-01-06 19:18:57,225 controller DEBUG System status received (panel id 0x0b)
--
2024-01-06 19:28:00,906 controller INFO No activity for a while, heartbeating
2024-01-06 19:28:01,157 controller DEBUG Sending queued [40]
2024-01-06 19:28:01,181 controller DEBUG Received: 8 System Status (data [11, 0, 0, 0, 0, 66, 0, 0, 0, 1, 59])
2024-01-06 19:28:01,181 controller DEBUG System status received (panel id 0x0b)
--
2024-01-06 19:34:27,465 controller INFO No activity for a while, heartbeating
2024-01-06 19:34:27,716 controller DEBUG Sending queued [40]
--
2024-01-06 19:39:27,546 controller INFO No activity for a while, heartbeating
2024-01-06 19:39:27,797 controller DEBUG Sending queued [40]
--
2024-01-06 19:44:27,633 controller INFO No activity for a while, heartbeating
2024-01-06 19:44:27,885 controller DEBUG Sending queued [40]

I didn't store it - but when I was doing the same thing in ASCII, the first line after the queued [40] was a long string which started to return with different text, then it got shorter and the nothing.

Could this be due to too much power being used by the USB cable? ie. over time something on the board stops being able to send/receive? Is that possible?

The USB cable does have an optional power supply which I've ordered and hope to get early next week.

Is there anything else I can/should test?

Again, thank you very much for any help you can provide.

Best Regards,

Richard

kk7ds commented 10 months ago

No, I have mine run for months (maybe more than a year) on end with no problems. For reference, I use a SOL adapter near the panel itself and run the daemon on a server elsewhere in the house which accesses it over ethernet.

I would say, however, USB is not meant to run long distances, but serial (especially at low baud rates) will go much longer without any trouble. If it were me, I'd run the serial line for the 15m distance and use a much less complicated/shorter USB setup only at the point at which you need it. You might see some evidence of USB troubles in dmesg if you look, but not guaranteed. I'd do that regardless, but if it continues to be a problem in that configuration, I'd also try a different USB-to-serial adapter, ideally something based on the FTDI chip if not already. Many USB-to-serial devices these days are absolutely terrible.

But yeah, other than that, I don't think it's a pynx584 problem, especially if you have to physically cycle the USB to get it working again.

Hope that helps!

cordenr commented 10 months ago

Hi Dan,

Many thanks for the quick response.

I have taken your advice and switched to a long serial cable. Thinking about it - it seems obvious given that:

This all seems to "fit" - so I'm closing this as not a problem!

Thanks for your help on this and also for the project in general! And the very best for 2024.

cordenr commented 9 months ago

Just to confirm - it's now 5 days since I switched to the long serial cable and so far so good.

Again thanks for your help.

kk7ds commented 9 months ago

Cool, glad to hear it :)