39 typedef struct{ |
39 typedef struct{ |
40 u16 ro_bits [MEM_AREA_SIZE]; |
40 u16 ro_bits [MEM_AREA_SIZE]; |
41 u16 rw_bits [MEM_AREA_SIZE]; |
41 u16 rw_bits [MEM_AREA_SIZE]; |
42 u16 ro_words[MEM_AREA_SIZE]; |
42 u16 ro_words[MEM_AREA_SIZE]; |
43 u16 rw_words[MEM_AREA_SIZE]; |
43 u16 rw_words[MEM_AREA_SIZE]; |
|
44 /* Two flags to count the number of Modbus requests (read and write) we have |
|
45 * successfully received from any remote Modbus master. |
|
46 * Two boolean flags that are set whenever we successfully process a |
|
47 * Modbus request sent from a remote client. |
|
48 * These flags will be mapped onto located variables |
|
49 * so the user's IEC 61131-3 code can check whether we are being |
|
50 * polled by a Modbus master. |
|
51 * The counters will roll over to 0 upon reaching maximum value. |
|
52 * The user will probably periodically reset the boolean flags to false, |
|
53 * and use this as a communication timeout |
|
54 * (when it remains false in two consecutive periods) |
|
55 * |
|
56 * u8 for BOOL variable/flag |
|
57 * u32 for UDINT variable/counter |
|
58 */ |
|
59 u8 flag_write_req_flag; |
|
60 u8 flag_read_req_flag; |
|
61 u32 flag_write_req_counter; |
|
62 u32 flag_read_req_counter; |
44 } server_mem_t; |
63 } server_mem_t; |
45 |
64 |
46 |
65 |
47 /* |
66 /* |
48 * Beremiz has a program to run on the PLC (Beremiz_service.py) |
67 * Beremiz has a program to run on the PLC (Beremiz_service.py) |
87 char str2[MODBUS_PARAM_STRING_SIZE]; |
106 char str2[MODBUS_PARAM_STRING_SIZE]; |
88 u8 slave_id; |
107 u8 slave_id; |
89 node_addr_t node_address; |
108 node_addr_t node_address; |
90 int mb_nd; // modbus library node used for this server |
109 int mb_nd; // modbus library node used for this server |
91 int init_state; // store how far along the server's initialization has progressed |
110 int init_state; // store how far along the server's initialization has progressed |
|
111 /* entries from this point forward are not statically initialized when the variable is declared */ |
|
112 /* they will be initialized by the code itself in the init() function */ |
92 pthread_t thread_id; // thread handling this server |
113 pthread_t thread_id; // thread handling this server |
93 server_mem_t mem_area; |
114 server_mem_t mem_area; |
94 } server_node_t; |
115 } server_node_t; |
95 |
116 |
96 |
117 |