mirror of
https://github.com/eddyem/BTA_utils.git
synced 2025-12-06 02:35:13 +03:00
fix bug with bad data from modbus: add 15 tries
This commit is contained in:
parent
77ca453860
commit
d62a4ec59d
@ -155,7 +155,8 @@ params_ans check_meteo_params(){
|
|||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
fd_set set;
|
fd_set set;
|
||||||
time_t tstart = time(NULL);
|
time_t tstart = time(NULL);
|
||||||
while(n_bytes){
|
int ctr = 15; // max 15 tries
|
||||||
|
while(ctr--) while(n_bytes){
|
||||||
FD_ZERO(&set);
|
FD_ZERO(&set);
|
||||||
FD_SET(portfd, &set);
|
FD_SET(portfd, &set);
|
||||||
timeout.tv_sec = 0;
|
timeout.tv_sec = 0;
|
||||||
|
|||||||
@ -116,6 +116,7 @@ int main(int argc, char *argv[]){
|
|||||||
params_ans a = check_meteo_params();
|
params_ans a = check_meteo_params();
|
||||||
if(a == ANS_LOSTCONN){
|
if(a == ANS_LOSTCONN){
|
||||||
LOG("Lost connection with device, reconnect!");
|
LOG("Lost connection with device, reconnect!");
|
||||||
|
clear_flags();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(a == ANS_OK){
|
if(a == ANS_OK){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user