Debian Codegraph @

src/modbus-private.h

raw symbols SCIP
1 /*
2 * Copyright © Stéphane Raimbault <[email protected]>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6
7 #ifndef MODBUS_PRIVATE_H
8 #define MODBUS_PRIVATE_Hcxx . . $ `src/modbus-private.h:8:9`!
9
10 // clang-format off
11 #ifndef _MSC_VER
12 # include <stdint.h>
13 # include <sys/time.h>
14 #else
15 # include "stdint.h"
16 # include <time.h>
17 typedef int ssize_t;
18 #endif
19 // clang-format on
20 #include <config.h>cxx . . $ `<file>/config.h`/
21 #include <sys/types.h>
22
23 #include "modbus.h"cxx . . $ `<file>/src/modbus.h`/
24
25 MODBUS_BEGIN_DECLScxx . . $ `src/modbus.h:39:10`!
26
27 /* It's not really the minimal length (the real one is report slave ID
28 * in RTU (4 bytes)) but it's a convenient size to use in RTU or TCP
29 * communications to read many values or write a single one.
30 * Maximum between :
31 * - HEADER_LENGTH_TCP (7) + function (1) + address (2) + number (2)
32 * - HEADER_LENGTH_RTU (1) + function (1) + address (2) + number (2) + CRC (2)
33 */
34 #define _MIN_REQ_LENGTHcxx . . $ `src/modbus-private.h:34:9`! 12
35
36 #define _REPORT_SLAVE_IDcxx . . $ `src/modbus-private.h:36:9`! 180
37
38 #define _MODBUS_EXCEPTION_RSP_LENGTHcxx . . $ `src/modbus-private.h:38:9`! 5
39
40 /* Timeouts in microsecond (0.5 s) */
41 #define _RESPONSE_TIMEOUTcxx . . $ `src/modbus-private.h:41:9`! 500000
42 #define _BYTE_TIMEOUTcxx . . $ `src/modbus-private.h:42:9`! 500000
43
44 typedef enumcxx . . $ $anonymous_type_d6cbf21b53db91ce_0# {
45 _MODBUS_BACKEND_TYPE_RTUcxx . . $ _MODBUS_BACKEND_TYPE_RTU. = 0,
46 _MODBUS_BACKEND_TYPE_TCPcxx . . $ _MODBUS_BACKEND_TYPE_TCP.
47 } modbus_backend_type_tcxx . . $ modbus_backend_type_t#;
48
49 /*
50 * ---------- Request Indication ----------
51 * | Client | ---------------------->| Server |
52 * ---------- Confirmation Response ----------
53 */
54 typedef enumcxx . . $ $anonymous_type_d6cbf21b53db91ce_1# {
55 /* Request message on the server side */
56 MSG_INDICATIONcxx . . $ MSG_INDICATION.,
57 /* Request message on the client side */
58 MSG_CONFIRMATIONcxx . . $ MSG_CONFIRMATION.
59 } msg_type_tcxx . . $ msg_type_t#;
60
61 /* This structure reduces the number of params in functions and so
62 * optimizes the speed of execution (~ 37%). */
63 typedef struct _sftcxx . . $ _sft# {
64 int slavecxx . . $ _sft#slave.;
65 int functioncxx . . $ _sft#function.;
66 int t_idcxx . . $ _sft#t_id.;
67 } sft_tcxx . . $ sft_t#;
68
69 typedef struct _modbus_backendcxx . . $ _modbus_backend# {
70 unsigned int backend_typecxx . . $ _modbus_backend#backend_type.;
71 unsigned int header_lengthcxx . . $ _modbus_backend#header_length.;
72 unsigned int checksum_lengthcxx . . $ _modbus_backend#checksum_length.;
73 unsigned int max_adu_lengthcxx . . $ _modbus_backend#max_adu_length.;
74 int (*set_slavecxx . . $ _modbus_backend#set_slave.)(modbus_tcxx . . $ modbus_t# *ctx, int slave);
75 int (*build_request_basiscxx . . $ _modbus_backend#build_request_basis.)(
76 modbus_tcxx . . $ modbus_t# *ctx, int function, int addr, int nb, uint8_tcxx . . $ uint8_t# *req);
77 int (*build_response_basiscxx . . $ _modbus_backend#build_response_basis.)(sft_tcxx . . $ sft_t# *sft, uint8_tcxx . . $ uint8_t# *rsp);
78 int (*get_response_tidcxx . . $ _modbus_backend#get_response_tid.)(const uint8_tcxx . . $ uint8_t# *req);
79 int (*send_msg_precxx . . $ _modbus_backend#send_msg_pre.)(uint8_tcxx . . $ uint8_t# *req, int req_length);
80 ssize_tcxx . . $ ssize_t# (*sendcxx . . $ _modbus_backend#send.)(modbus_tcxx . . $ modbus_t# *ctx, const uint8_tcxx . . $ uint8_t# *req, int req_length);
81 int (*receivecxx . . $ _modbus_backend#receive.)(modbus_tcxx . . $ modbus_t# *ctx, uint8_tcxx . . $ uint8_t# *req);
82 ssize_tcxx . . $ ssize_t# (*recvcxx . . $ _modbus_backend#recv.)(modbus_tcxx . . $ modbus_t# *ctx, uint8_tcxx . . $ uint8_t# *rsp, int rsp_length);
83 int (*check_integritycxx . . $ _modbus_backend#check_integrity.)(modbus_tcxx . . $ modbus_t# *ctx, uint8_tcxx . . $ uint8_t# *msg, const int msg_length);
84 int (*pre_check_confirmationcxx . . $ _modbus_backend#pre_check_confirmation.)(modbus_tcxx . . $ modbus_t# *ctx,
85 const uint8_tcxx . . $ uint8_t# *req,
86 const uint8_tcxx . . $ uint8_t# *rsp,
87 int rsp_length);
88 int (*connectcxx . . $ _modbus_backend#connect.)(modbus_tcxx . . $ modbus_t# *ctx);
89 unsigned int (*is_connectedcxx . . $ _modbus_backend#is_connected.)(modbus_tcxx . . $ modbus_t# *ctx);
90 void (*closecxx . . $ _modbus_backend#close.)(modbus_tcxx . . $ modbus_t# *ctx);
91 int (*flushcxx . . $ _modbus_backend#flush.)(modbus_tcxx . . $ modbus_t# *ctx);
92 int (*selectcxx . . $ _modbus_backend#select.)(modbus_tcxx . . $ modbus_t# *ctx, fd_setcxx . . $ fd_set# *rset, struct timevalcxx . . $ timeval# *tv, int msg_length);
93 void (*freecxx . . $ _modbus_backend#free.)(modbus_tcxx . . $ modbus_t# *ctx);
94 } modbus_backend_tcxx . . $ modbus_backend_t#;
95
96 struct _modbuscxx . . $ _modbus# {
97 /* Slave address */
98 int slavecxx . . $ _modbus#slave.;
99 /* Socket or file descriptor */
100 int scxx . . $ _modbus#s.;
101 int debugcxx . . $ _modbus#debug.;
102 int error_recoverycxx . . $ _modbus#error_recovery.;
103 int quirkscxx . . $ _modbus#quirks.;
104 struct timevalcxx . . $ timeval# response_timeoutcxx . . $ _modbus#response_timeout.;
105 struct timevalcxx . . $ timeval# byte_timeoutcxx . . $ _modbus#byte_timeout.;
106 struct timevalcxx . . $ timeval# indication_timeoutcxx . . $ _modbus#indication_timeout.;
107 const modbus_backend_tcxx . . $ modbus_backend_t# *backendcxx . . $ _modbus#backend.;
108 void *backend_datacxx . . $ _modbus#backend_data.;
109 };
110
111 void _modbus_init_commoncxx . . $ _modbus_init_common(24b4870c26038e9).(modbus_tcxx . . $ modbus_t# *ctx);
112 void _error_printcxx . . $ _error_print(4795e48ec6eb13cd).(modbus_tcxx . . $ modbus_t# *ctx, const char *context);
113 int _modbus_receive_msgcxx . . $ _modbus_receive_msg(85c522f07fbdeb64).(modbus_tcxx . . $ modbus_t# *ctx, uint8_tcxx . . $ uint8_t# *msg, msg_type_tcxx . . $ msg_type_t# msg_type);
114
115 #ifndef HAVE_STRLCPYcxx . . $ `./../config.h:98:9`!
116 size_t strlcpy(char *dest, const char *src, size_t dest_size);
117 #endif
118
119 MODBUS_END_DECLScxx . . $ `src/modbus.h:40:10`!
120
121 #endif /* MODBUS_PRIVATE_H */