fixed coils read

This commit is contained in:
2026-10-01 17:36:49 +03:00
parent a2cb827a76
commit fe5989497f
5 changed files with 9 additions and 6 deletions

View File

@@ -45,13 +45,12 @@ TRUE_INLINE void readcoil(modbus_request *r){
return;
}
uint8_t bytes[OUTMAXBYTES] = {0};
int curidx = OUTMAXBYTES;
int vals = get_relay(OUTMAX+1);
for(int i = 0; i < amount; ++i){
bytes[i] = vals & 0xff;
vals >>= 8;
}
modbus_response resp = {.Fcode = r->Fcode, .ID = the_conf.modbusID, .data = bytes+curidx, .datalen = amount};
modbus_response resp = {.Fcode = r->Fcode, .ID = the_conf.modbusID, .data = bytes, .datalen = amount};
modbus_send_response(&resp);
}