dn_device.h
Go to the documentation of this file.
1 #ifndef DN_DEVICE_H_
2 #define DN_DEVICE_H_
3 
36 #ifndef _DN_EXP_DEVICE
37 #define _DN_EXP_DEVICE
38 #endif /* _DN_EXP_DEVICE */
39 
54 #if defined(_USE_WIN_API)
55 #define DNGetLastError() GetLastError()
56 #define OSSUCCEEDED(ret) ((ret) != 0)
57 #define OSFAILED(ret) ((ret) == 0)
58 #else
59 #if defined(_USE_LINUX_API)
60 #define DNGetLastError() errno
61 #define OSSUCCEEDED(ret) ((ret) == 0)
62 #define OSFAILED(ret) ((ret) == -1)
63 #endif
64 
69 #define NOPARITY (0)
70 
75 #define ODDPARITY (1)
76 
81 #define EVENPARITY (2)
82 
87 #define ONESTOPBIT (0)
88 
93 #define TWOSTOPBITS (2)
94 
95 #endif
96 
101 #define DEV_BUF_MAX ((uint16_t)-1)
102 
107 #define E_INVALIDPACKET _HRESULT_TYPEDEF_(0x80010000L)
108 
114 {
115  CHECK_TYPE_TCP = 0x0001,
116  CHECK_TYPE_UDP = 0x0002,
117  CHECK_TYPE_COM = 0x0004,
118  CHECK_TYPE_ALL = 0x00FF,
119  CHECK_FUNC_OPEN = 0x0100,
120  CHECK_FUNC_CLOSE = 0x0200,
121  CHECK_FUNC_SEND = 0x0400,
122  CHECK_FUNC_RECV = 0x0800,
124  CHECK_FUNC_CLEAR = 0x2000,
125  CHECK_FUNC_ALL = 0xFF00,
126 };
127 
133 {
137 };
138 
145 {
150 };
151 
157 {
158  int port;
160  char parity;
161  char data_bits;
162  char stop_bits;
163  char flow;
164 };
165 
171 {
172  int sock;
173  int type;
175  void *arg;
176  HRESULT (*dn_open)(void *param, int *sock);
177  HRESULT (*dn_close)(int *sock);
178  HRESULT (*dn_send)(int sock, const char *buf, uint32_t len_buf, void *arg);
179  HRESULT (*dn_recv)(int sock, char *buf, uint32_t len_buf, uint32_t *len_recved,
180  uint32_t timeout, void *arg);
181  HRESULT (*dn_set_timeout)(int sock, uint32_t timeout);
182  HRESULT (*dn_clear)(int sock, uint32_t timeout);
183 };
184 
185 #ifdef __cplusplus
186 extern "C"
187 {
188 #endif
189 
195  _DN_EXP_DEVICE int
196  parse_conn_type(const char *opt);
197 
207  parse_conn_param_ether(const char *opt, struct CONN_PARAM_ETH *param);
208 
223  parse_conn_param_serial(const char *opt, struct CONN_PARAM_COM *param);
224 
232  check_timeout(int sock, uint32_t timeout);
233 
241  check_conn_param(const struct CONN_PARAM_COMMON *device, int flag);
242 
250  _DN_EXP_DEVICE void
251  memcpy_le(void *dst, const void *src, uint32_t len);
252 
260  _DN_EXP_DEVICE void
261  memcpy_be(void *dst, const void *src, uint32_t len);
262 
263 #ifdef __cplusplus
264 }
265 #endif
266 
267 #endif /* DN_DEVICE_H_ */
unsigned uint32_t
Definition: stdint.h:43
uint32_t timeout
Definition: dn_device.h:174
CONN_TYPE
Connection type.
Definition: dn_device.h:132
unsigned short uint16_t
Definition: stdint.h:41
_DN_EXP_DEVICE HRESULT parse_conn_param_serial(const char *opt, struct CONN_PARAM_COM *param)
Parses serial connection parameters.
Definition: dn_device.c:235
int32_t HRESULT
Definition: dn_common.h:61
uint32_t src_addr
Definition: dn_device.h:148
uint16_t src_port
Definition: dn_device.h:149
A type definition for Ethernet connection parameters.
Definition: dn_device.h:144
_DN_EXP_DEVICE void memcpy_be(void *dst, const void *src, uint32_t len)
Orders to big endian.
Definition: dn_device.c:495
A type definition for common communication parameters.
Definition: dn_device.h:170
uint32_t baud_rate
Definition: dn_device.h:159
_DN_EXP_DEVICE void memcpy_le(void *dst, const void *src, uint32_t len)
Orders to little endian.
Definition: dn_device.c:469
uint16_t dst_port
Definition: dn_device.h:147
_DN_EXP_DEVICE int parse_conn_type(const char *opt)
Parses and returns the connection type.
Definition: dn_device.c:93
CONN_PARAM_CHECK_FLAG
Definitions for check_conn_param function.
Definition: dn_device.h:113
A type definition for serial connection parameters.
Definition: dn_device.h:156
_DN_EXP_DEVICE HRESULT check_timeout(int sock, uint32_t timeout)
Checks the communication timeout.
Definition: dn_device.c:385
#define _DN_EXP_DEVICE
Definition: dn_device.h:37
_DN_EXP_DEVICE HRESULT check_conn_param(const struct CONN_PARAM_COMMON *device, int flag)
Checks the communication parameters.
Definition: dn_device.c:419
uint32_t dst_addr
Definition: dn_device.h:146
_DN_EXP_DEVICE HRESULT parse_conn_param_ether(const char *opt, struct CONN_PARAM_ETH *param)
Parses Ethernet connection parameters.
Definition: dn_device.c:121


bcap_core
Author(s): DENSO WAVE INCORPORATED
autogenerated on Mon Jun 10 2019 13:12:20