modbus-rtu-private.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2001-2011 Stéphane Raimbault <stephane.raimbault@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef _MODBUS_RTU_PRIVATE_H_
20 #define _MODBUS_RTU_PRIVATE_H_
21 
22 #ifndef _MSC_VER
23 #include <stdint.h>
24 #else
25 #include "stdint.h"
26 #endif
27 
28 #if defined(_WIN32)
29 #include <windows.h>
30 #else
31 #include <termios.h>
32 #endif
33 
34 #define _MODBUS_RTU_HEADER_LENGTH 1
35 #define _MODBUS_RTU_PRESET_REQ_LENGTH 6
36 #define _MODBUS_RTU_PRESET_RSP_LENGTH 2
37 
38 #define _MODBUS_RTU_CHECKSUM_LENGTH 2
39 
40 #if defined(_WIN32)
41 #define ENOTSUP WSAEOPNOTSUPP
42 
43 /* WIN32: struct containing serial handle and a receive buffer */
44 #define PY_BUF_SIZE 512
45 struct win32_ser {
46  /* File handle */
47  HANDLE fd;
48  /* Receive buffer */
49  uint8_t buf[PY_BUF_SIZE];
50  /* Received chars */
51  DWORD n_bytes;
52 };
53 #endif /* _WIN32 */
54 
55 typedef struct _modbus_rtu {
56  /* Device: "/dev/ttyS0", "/dev/ttyUSB0" or "/dev/tty.USA19*" on Mac OS X for
57  KeySpan USB<->Serial adapters this string had to be made bigger on OS X
58  as the directory+file name was bigger than 19 bytes. Making it 67 bytes
59  for now, but OS X does support 256 byte file names. May become a problem
60  in the future. */
61 #if defined(__APPLE_CC__)
62  char device[64];
63 #else
64  char device[16];
65 #endif
66  /* Bauds: 9600, 19200, 57600, 115200, etc */
67  int baud;
68  /* Data bit */
69  uint8_t data_bit;
70  /* Stop bit */
71  uint8_t stop_bit;
72  /* Parity: 'N', 'O', 'E' */
73  char parity;
74 #if defined(_WIN32)
75  struct win32_ser w_ser;
76  DCB old_dcb;
77 #else
78  /* Save old termios settings */
79  struct termios old_tios;
80 #endif
81 #if HAVE_DECL_TIOCSRS485
82  int serial_mode;
83 #endif
84 } modbus_rtu_t;
85 
86 #endif /* _MODBUS_RTU_PRIVATE_H_ */
struct _modbus_rtu modbus_rtu_t


libmodbus
Author(s):
autogenerated on Sat Nov 21 2020 03:17:32