mirror of
https://github.com/eddyem/BTA_utils.git
synced 2025-12-06 02:35:13 +03:00
fixed bta_meteo_modbus?
This commit is contained in:
parent
d62a4ec59d
commit
a00200af3c
@ -155,8 +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);
|
||||||
int ctr = 15; // max 15 tries
|
int ctr = 50; // max 50 tries
|
||||||
while(ctr--) while(n_bytes){
|
while(ctr--){
|
||||||
FD_ZERO(&set);
|
FD_ZERO(&set);
|
||||||
FD_SET(portfd, &set);
|
FD_SET(portfd, &set);
|
||||||
timeout.tv_sec = 0;
|
timeout.tv_sec = 0;
|
||||||
@ -174,7 +174,8 @@ params_ans check_meteo_params(){
|
|||||||
size += n_bytes;
|
size += n_bytes;
|
||||||
if(n_bytes) continue;
|
if(n_bytes) continue;
|
||||||
}
|
}
|
||||||
if(size > 0 && (res == 0 || size >= MODBUS_MAX_PACKET_SIZE || n_bytes == 0)) {
|
// read all or end of packet
|
||||||
|
if(size > 0 && res == 0 && (size == REQ_LEN || size == ANS_LEN)){
|
||||||
if(crc_check(buffer, size)){
|
if(crc_check(buffer, size)){
|
||||||
if(size == REQ_LEN){
|
if(size == REQ_LEN){
|
||||||
lastpar = buffer[2] << 8 | buffer[3];
|
lastpar = buffer[2] << 8 | buffer[3];
|
||||||
|
|||||||
@ -114,6 +114,7 @@ int main(int argc, char *argv[]){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
params_ans a = check_meteo_params();
|
params_ans a = check_meteo_params();
|
||||||
|
DBG("chk_meteo: %d", a);
|
||||||
if(a == ANS_LOSTCONN){
|
if(a == ANS_LOSTCONN){
|
||||||
LOG("Lost connection with device, reconnect!");
|
LOG("Lost connection with device, reconnect!");
|
||||||
clear_flags();
|
clear_flags();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user