-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmb_addr.h
91 lines (64 loc) · 2.39 KB
/
mb_addr.h
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
78
79
80
81
82
83
/*
* Copyright (c) 2002,2016 Mario de Sousa ([email protected])
*
* This file is part of the Modbus library for Beremiz and matiec.
*
* This Modbus library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this Modbus library. If not, see <http://www.gnu.org/licenses/>.
*
* This code is made available on the understanding that it will not be
* used in safety-critical situations without a full and competent review.
*/
#ifndef MODBUS_LAYER2_H
#define MODBUS_LAYER2_H
#include <time.h> /* struct timespec data type */
//#include <sys/socket.h>
//#include <netinet/in.h>
#include <netinet/ip.h> /* superset of previous */ // Required for INADDR_ANY
/* Library Error codes */
#define PORT_FAILURE -101
#define INTERNAL_ERROR -102
#define TIMEOUT -103
#define INVALID_FRAME -104
#define MODBUS_ERROR -105
/* NOTE: Modbus error codes are defined in mb_util.h */
typedef enum {optimize_speed, optimize_size} optimization_t;
typedef enum {
naf_ascii,
naf_rtu,
naf_tcp,
} node_addr_family_t;
typedef struct {
const char *host;
const char *service;
int close_on_silence;
} node_addr_tcp_t;
typedef struct {
const char *device;
int baud; /* plain baud rate, eg 2400; zero for the default 9600 */
int parity; /* 0 for none, 1 for odd, 2 for even */
int data_bits;
int stop_bits;
int ignore_echo; /* 1 => ignore echo; 0 => do not ignore echo */
} node_addr_rtu_t;
typedef node_addr_rtu_t node_addr_ascii_t;
typedef union {
node_addr_ascii_t ascii;
node_addr_rtu_t rtu;
node_addr_tcp_t tcp;
} node_addr_common_t;
typedef struct {
node_addr_family_t naf;
node_addr_common_t addr;
} node_addr_t;
#endif /* MODBUS_LAYER2_H */