MIGRATION
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
=============================
Migration from the 2.0 series
=============================
modbus_init_listen_tcp() has been renamed to modbus_slave_listen_tcp() and
requires a new argument, the maximal number of connections:
int modbus_slave_init_tcp(modbus_param_t *mb_param, int nb_connection);
New function modbus_slave_accept_tcp() to etablish a new connection (previously
in modbus_init_listen_tcp()):
int modbus_slave_accept_tcp(modbus_param_t *mb_param, int *socket);
modbus_listen() has been renamed to modbus_slave_receive() and requires a new
argument, the socket file descriptor to listen on. If the sockfd is -1, the
internal fd of modbus_param_t is used:
int modbus_slave_receive(modbus_param_t *mb_param, int sockfd,
uint8_t *query, int *query_length);
If you use the HEADER_LENGTH_ defines, their values have been incremented by 1
to reflect the PDU and ADU of the Modbus protocol and to reduce the CPU
consumption:
- HEADER_LENGTH_RTU 0 -> 1
- HEADER_LENGTH_TCP 6 -> 7
===================================
Migration notes from the 1.2 series
===================================
Init
====
modbus_init_tcp requires a third new argument, the port number.
modbus_init_tcp(modbus_param_t *mb_param, char *ip_address, int port)
Set the port to MODBUS_TCP_DEFAULT_PORT to use the default one
(502). It's convenient to use a port number greater than or equal to
1024 because it's not necessary to be root to use this port number.
Pointers of data
================
The coil and input status are now stored in an array of type uint8_t
(in 1.2.X series, array of type int was used). So now, you need to
pass a pointer of type uint8_t to use read_coil_status(), for example.
The holding and input registers are now stored in an array of type
uint16_t.
These changes reduce the memory consumption.
New functions
=============
report_slave_id
modbus_set_error_handling
modbus_mapping_new
modbus_mapping_free
modbus_init_listen_tcp
modbus_listen
modbus_manage_query
get_slave_query_tcp
set_bits_from_byte
set_bits_from_bytes
get_byte_from_bits
Read modbus.h for more informations.