mirror of
https://github.com/eddyem/stm32samples.git
synced 2026-10-01 22:30:32 +03:00
fixed coils read
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user