forked from ned-kelly/docker-voltronic-homeassistant
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inverter.cpp: avoid mess with simultaneous read/write operations
ned-kelly#77 When many inverter_poller at the same time send commands, the result is undefined. This locks exclusively the configuration file, while the process is running, so that simultaneous instances have to wait until the file is released. For some reason locking the device /dev/hidraw0 does not work for me, I get sometimes the output from previous runs. I suspect that when cInverter::query() does exceed the 2s timeout, it quits, and leaves the response of its commands on the wire. For fd = /dev/hidraw0 tcflush(fd, TCOFLUSH); has no effect. As a matter of fact, on my system I have increased the timeout in cInverter::query() to 15s and now it does always work correctly. Also the program, when called with -1, could exit, while the thread is receiving data, this leaves the next invocation with some ready-data, which it is not expecting.
- Loading branch information
1 parent
d75ab47
commit b0d4b26
Showing
3 changed files
with
20 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters