# HG changeset patch # User Mario de Sousa # Date 1608589923 0 # Node ID 1215a6b741d569312c94005f3b6d28f74cab0474 # Parent 0b636dc947a2ddc668ef8fa0a4649574860a52b5 Modbus plugin: fix bug - map BOOL flag onto C u8 (was incorrectly mapped onto u16) diff -r 0b636dc947a2 -r 1215a6b741d5 modbus/mb_runtime.h --- a/modbus/mb_runtime.h Mon Dec 21 22:26:36 2020 +0000 +++ b/modbus/mb_runtime.h Mon Dec 21 22:32:03 2020 +0000 @@ -158,19 +158,19 @@ u16 coms_buffer[REQ_BUF_SIZE]; pthread_mutex_t coms_buf_mutex; // mutex to access coms_buffer[] /* boolean flag that will be mapped onto a (BOOL) located variable - * (u16 because IEC 61131-3 BOOL are mapped onto u16 in C code! ) + * (u8 because IEC 61131-3 BOOL are mapped onto u8 in C code! ) * -> allow PLC program to request when to start the MB transaction * -> will be reset once the MB transaction has completed */ - u16 flag_exec_req; + u8 flag_exec_req; /* flag that works in conjunction with flag_exec_req - * (does not really need to be u16 as it is not mapped onto a located variable. ) + * (does not really need to be u8 as it is not mapped onto a located variable. ) * -> used by internal logic to indicate that the client thread * that will be executing the MB transaction * requested by flag exec_req has already been activated. * -> will be reset once the MB transaction has completed */ - u16 flag_exec_started; + u8 flag_exec_started; /* flag that will be mapped onto a (BYTE) located variable * (u8 because the flag is a BYTE! ) * -> will store the result of the last executed MB transaction diff -r 0b636dc947a2 -r 1215a6b741d5 modbus/modbus.py --- a/modbus/modbus.py Mon Dec 21 22:26:36 2020 +0000 +++ b/modbus/modbus.py Mon Dec 21 22:32:03 2020 +0000 @@ -904,7 +904,7 @@ if str(iecvar["NAME"]) not in loc_vars_list: # Add if it is a Execution Request Flag (mapped onto %QXa.b.c.0.0), so last number is a '0' if iecvar["LOC"][4] == 0: - loc_vars.append("u16 *" + str(iecvar["NAME"]) + " = &client_requests[%d].flag_exec_req;" % (client_requestid)) + loc_vars.append("u8 *" + str(iecvar["NAME"]) + " = &client_requests[%d].flag_exec_req;" % (client_requestid)) loc_vars_list.append(str(iecvar["NAME"])) # Add if it is a "Modbus Request Status flag" (mapped onto %QWa.b.c.0.1), so last number is a '1' if iecvar["LOC"][4] == 1: @@ -958,7 +958,7 @@ if str(iecvar["NAME"]) not in loc_vars_list: # Add if it is a Execution Request Flag (mapped onto %QXa.b.c.0.0), so last number is a '0' if iecvar["LOC"][4] == 0: - loc_vars.append("u16 *" + str(iecvar["NAME"]) + " = &client_requests[%d].flag_exec_req;" % (client_requestid)) + loc_vars.append("u8 *" + str(iecvar["NAME"]) + " = &client_requests[%d].flag_exec_req;" % (client_requestid)) loc_vars_list.append(str(iecvar["NAME"])) # Add if it is a "Modbus Request Status flag" (mapped onto %QWa.b.c.0.1), so last number is a '1' if iecvar["LOC"][4] == 1: