Skip to content

Commit

Permalink
inverter.cpp: avoid mess in simultaneous read/write operations
Browse files Browse the repository at this point in the history
  • Loading branch information
dilyanpalauzov committed Apr 9, 2022
1 parent d30d7e6 commit a059b86
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sources/inverter-cli/inverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ bool cInverter::query(const char *cmd, int replysize) {
return false;
}

struct flock lock;
memset (&lock, 0, sizeof(struct flock));
lock.l_type = F_WRLCK;
fcntl (fd, F_SETLKW, &lock);

// Once connected, set the baud rate and other serial config (Don't rely on this being correct on the system by default...)
speed_t baud = B2400;
Expand Down

0 comments on commit a059b86

Please sign in to comment.