Commit a20d39d36c7052281294e648c65e39db8b33182f
1 parent
3948142c
Write the values in force_multiple_coils and preset_multiple_registers (SLAVE)
Showing
1 changed file
with
10 additions
and
0 deletions
modbus/modbus.c
| ... | ... | @@ -873,6 +873,9 @@ void manage_query(modbus_param_t *mb_param, uint8_t *query, |
| 873 | 873 | resp_length = response_exception(mb_param, &sft, |
| 874 | 874 | ILLEGAL_DATA_ADDRESS, response); |
| 875 | 875 | } else { |
| 876 | + /* 6 = byte count, 7 = first byte of data */ | |
| 877 | + set_bits_from_bytes(mb_mapping->tab_coil_status, address, nb, &query[offset + 7]); | |
| 878 | + | |
| 876 | 879 | resp_length = build_response_basis(mb_param, &sft, response); |
| 877 | 880 | /* 4 to copy the coil address (2) and the quantity of coils */ |
| 878 | 881 | memcpy(response + resp_length, query + resp_length, 4); |
| ... | ... | @@ -889,6 +892,13 @@ void manage_query(modbus_param_t *mb_param, uint8_t *query, |
| 889 | 892 | resp_length = response_exception(mb_param, &sft, |
| 890 | 893 | ILLEGAL_DATA_ADDRESS, response); |
| 891 | 894 | } else { |
| 895 | + int i, j; | |
| 896 | + for (i = address, j = 0; i < address + nb; i++, j += 2) { | |
| 897 | + /* 6 = byte count, 7 and 8 = first value */ | |
| 898 | + mb_mapping->tab_holding_registers[i] = | |
| 899 | + (query[offset + 7 + j] << 8) + query[offset + 8 + j]; | |
| 900 | + } | |
| 901 | + | |
| 892 | 902 | resp_length = build_response_basis(mb_param, &sft, response); |
| 893 | 903 | /* 4 to copy the address (2) and the no. of registers */ |
| 894 | 904 | memcpy(response + resp_length, query + resp_length, 4); | ... | ... |