Commit 09b581a538f00992585dae2ccaaf4857c7152c9c
1 parent
cfaa872f
Rename data_dest|src in dest|src to match header
Showing
1 changed file
with
21 additions
and
20 deletions
src/modbus.c
| ... | ... | @@ -855,7 +855,7 @@ int modbus_reply_exception(modbus_t *ctx, const uint8_t *req, |
| 855 | 855 | |
| 856 | 856 | /* Reads IO status */ |
| 857 | 857 | static int read_io_status(modbus_t *ctx, int function, |
| 858 | - int addr, int nb, uint8_t *data_dest) | |
| 858 | + int addr, int nb, uint8_t *dest) | |
| 859 | 859 | { |
| 860 | 860 | int rc; |
| 861 | 861 | int req_length; |
| ... | ... | @@ -883,7 +883,7 @@ static int read_io_status(modbus_t *ctx, int function, |
| 883 | 883 | temp = rsp[i]; |
| 884 | 884 | |
| 885 | 885 | for (bit = 0x01; (bit & 0xff) && (pos < nb);) { |
| 886 | - data_dest[pos++] = (temp & bit) ? TRUE : FALSE; | |
| 886 | + dest[pos++] = (temp & bit) ? TRUE : FALSE; | |
| 887 | 887 | bit = bit << 1; |
| 888 | 888 | } |
| 889 | 889 | |
| ... | ... | @@ -895,7 +895,7 @@ static int read_io_status(modbus_t *ctx, int function, |
| 895 | 895 | |
| 896 | 896 | /* Reads the boolean status of bits and sets the array elements |
| 897 | 897 | in the destination to TRUE or FALSE (single bits). */ |
| 898 | -int modbus_read_bits(modbus_t *ctx, int addr, int nb, uint8_t *data_dest) | |
| 898 | +int modbus_read_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest) | |
| 899 | 899 | { |
| 900 | 900 | int rc; |
| 901 | 901 | |
| ... | ... | @@ -909,7 +909,7 @@ int modbus_read_bits(modbus_t *ctx, int addr, int nb, uint8_t *data_dest) |
| 909 | 909 | return -1; |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | - rc = read_io_status(ctx, _FC_READ_COILS, addr, nb, data_dest); | |
| 912 | + rc = read_io_status(ctx, _FC_READ_COILS, addr, nb, dest); | |
| 913 | 913 | |
| 914 | 914 | if (rc == -1) |
| 915 | 915 | return -1; |
| ... | ... | @@ -919,7 +919,7 @@ int modbus_read_bits(modbus_t *ctx, int addr, int nb, uint8_t *data_dest) |
| 919 | 919 | |
| 920 | 920 | |
| 921 | 921 | /* Same as modbus_read_bits but reads the remote device input table */ |
| 922 | -int modbus_read_input_bits(modbus_t *ctx, int addr, int nb, uint8_t *data_dest) | |
| 922 | +int modbus_read_input_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest) | |
| 923 | 923 | { |
| 924 | 924 | int rc; |
| 925 | 925 | |
| ... | ... | @@ -933,7 +933,7 @@ int modbus_read_input_bits(modbus_t *ctx, int addr, int nb, uint8_t *data_dest) |
| 933 | 933 | return -1; |
| 934 | 934 | } |
| 935 | 935 | |
| 936 | - rc = read_io_status(ctx, _FC_READ_DISCRETE_INPUTS, addr, nb, data_dest); | |
| 936 | + rc = read_io_status(ctx, _FC_READ_DISCRETE_INPUTS, addr, nb, dest); | |
| 937 | 937 | |
| 938 | 938 | if (rc == -1) |
| 939 | 939 | return -1; |
| ... | ... | @@ -943,7 +943,7 @@ int modbus_read_input_bits(modbus_t *ctx, int addr, int nb, uint8_t *data_dest) |
| 943 | 943 | |
| 944 | 944 | /* Reads the data from a remove device and put that data into an array */ |
| 945 | 945 | static int read_registers(modbus_t *ctx, int function, int addr, int nb, |
| 946 | - uint16_t *data_dest) | |
| 946 | + uint16_t *dest) | |
| 947 | 947 | { |
| 948 | 948 | int rc; |
| 949 | 949 | int req_length; |
| ... | ... | @@ -976,7 +976,7 @@ static int read_registers(modbus_t *ctx, int function, int addr, int nb, |
| 976 | 976 | |
| 977 | 977 | for (i = 0; i < rc; i++) { |
| 978 | 978 | /* shift reg hi_byte to temp OR with lo_byte */ |
| 979 | - data_dest[i] = (rsp[offset + 2 + (i << 1)] << 8) | | |
| 979 | + dest[i] = (rsp[offset + 2 + (i << 1)] << 8) | | |
| 980 | 980 | rsp[offset + 3 + (i << 1)]; |
| 981 | 981 | } |
| 982 | 982 | } |
| ... | ... | @@ -986,7 +986,7 @@ static int read_registers(modbus_t *ctx, int function, int addr, int nb, |
| 986 | 986 | |
| 987 | 987 | /* Reads the holding registers of remote device and put the data into an |
| 988 | 988 | array */ |
| 989 | -int modbus_read_registers(modbus_t *ctx, int addr, int nb, uint16_t *data_dest) | |
| 989 | +int modbus_read_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest) | |
| 990 | 990 | { |
| 991 | 991 | int status; |
| 992 | 992 | |
| ... | ... | @@ -1001,13 +1001,13 @@ int modbus_read_registers(modbus_t *ctx, int addr, int nb, uint16_t *data_dest) |
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | 1003 | status = read_registers(ctx, _FC_READ_HOLDING_REGISTERS, |
| 1004 | - addr, nb, data_dest); | |
| 1004 | + addr, nb, dest); | |
| 1005 | 1005 | return status; |
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | /* Reads the input registers of remote device and put the data into an array */ |
| 1009 | 1009 | int modbus_read_input_registers(modbus_t *ctx, int addr, int nb, |
| 1010 | - uint16_t *data_dest) | |
| 1010 | + uint16_t *dest) | |
| 1011 | 1011 | { |
| 1012 | 1012 | int status; |
| 1013 | 1013 | |
| ... | ... | @@ -1020,7 +1020,7 @@ int modbus_read_input_registers(modbus_t *ctx, int addr, int nb, |
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | 1022 | status = read_registers(ctx, _FC_READ_INPUT_REGISTERS, |
| 1023 | - addr, nb, data_dest); | |
| 1023 | + addr, nb, dest); | |
| 1024 | 1024 | |
| 1025 | 1025 | return status; |
| 1026 | 1026 | } |
| ... | ... | @@ -1069,7 +1069,7 @@ int modbus_write_register(modbus_t *ctx, int addr, int value) |
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | 1071 | /* Write the bits of the array in the remote device */ |
| 1072 | -int modbus_write_bits(modbus_t *ctx, int addr, int nb, const uint8_t *data_src) | |
| 1072 | +int modbus_write_bits(modbus_t *ctx, int addr, int nb, const uint8_t *src) | |
| 1073 | 1073 | { |
| 1074 | 1074 | int rc; |
| 1075 | 1075 | int i; |
| ... | ... | @@ -1089,7 +1089,8 @@ int modbus_write_bits(modbus_t *ctx, int addr, int nb, const uint8_t *data_src) |
| 1089 | 1089 | return -1; |
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | - req_length = ctx->backend->build_request_basis(ctx, _FC_WRITE_MULTIPLE_COILS, | |
| 1092 | + req_length = ctx->backend->build_request_basis(ctx, | |
| 1093 | + _FC_WRITE_MULTIPLE_COILS, | |
| 1093 | 1094 | addr, nb, req); |
| 1094 | 1095 | byte_count = (nb / 8) + ((nb % 8) ? 1 : 0); |
| 1095 | 1096 | req[req_length++] = byte_count; |
| ... | ... | @@ -1101,7 +1102,7 @@ int modbus_write_bits(modbus_t *ctx, int addr, int nb, const uint8_t *data_src) |
| 1101 | 1102 | req[req_length] = 0; |
| 1102 | 1103 | |
| 1103 | 1104 | while ((bit & 0xFF) && (bit_check++ < nb)) { |
| 1104 | - if (data_src[pos++]) | |
| 1105 | + if (src[pos++]) | |
| 1105 | 1106 | req[req_length] |= bit; |
| 1106 | 1107 | else |
| 1107 | 1108 | req[req_length] &=~ bit; |
| ... | ... | @@ -1122,7 +1123,7 @@ int modbus_write_bits(modbus_t *ctx, int addr, int nb, const uint8_t *data_src) |
| 1122 | 1123 | } |
| 1123 | 1124 | |
| 1124 | 1125 | /* Write the values from the array to the registers of the remote device */ |
| 1125 | -int modbus_write_registers(modbus_t *ctx, int addr, int nb, const uint16_t *data_src) | |
| 1126 | +int modbus_write_registers(modbus_t *ctx, int addr, int nb, const uint16_t *src) | |
| 1126 | 1127 | { |
| 1127 | 1128 | int rc; |
| 1128 | 1129 | int i; |
| ... | ... | @@ -1148,8 +1149,8 @@ int modbus_write_registers(modbus_t *ctx, int addr, int nb, const uint16_t *data |
| 1148 | 1149 | req[req_length++] = byte_count; |
| 1149 | 1150 | |
| 1150 | 1151 | for (i = 0; i < nb; i++) { |
| 1151 | - req[req_length++] = data_src[i] >> 8; | |
| 1152 | - req[req_length++] = data_src[i] & 0x00FF; | |
| 1152 | + req[req_length++] = src[i] >> 8; | |
| 1153 | + req[req_length++] = src[i] & 0x00FF; | |
| 1153 | 1154 | } |
| 1154 | 1155 | |
| 1155 | 1156 | rc = send_msg(ctx, req, req_length); |
| ... | ... | @@ -1229,7 +1230,7 @@ int modbus_read_and_write_registers(modbus_t *ctx, |
| 1229 | 1230 | |
| 1230 | 1231 | /* Send a request to get the slave ID of the device (only available in serial |
| 1231 | 1232 | communication). */ |
| 1232 | -int modbus_report_slave_id(modbus_t *ctx, uint8_t *data_dest) | |
| 1233 | +int modbus_report_slave_id(modbus_t *ctx, uint8_t *dest) | |
| 1233 | 1234 | { |
| 1234 | 1235 | int rc; |
| 1235 | 1236 | int req_length; |
| ... | ... | @@ -1256,7 +1257,7 @@ int modbus_report_slave_id(modbus_t *ctx, uint8_t *data_dest) |
| 1256 | 1257 | offset = ctx->backend->header_length + 2; |
| 1257 | 1258 | |
| 1258 | 1259 | for (i=0; i < rc; i++) { |
| 1259 | - data_dest[i] = rsp[offset + i]; | |
| 1260 | + dest[i] = rsp[offset + i]; | |
| 1260 | 1261 | } |
| 1261 | 1262 | } |
| 1262 | 1263 | ... | ... |