dn_device.h
Go to the documentation of this file.
00001 #ifndef DN_DEVICE_H_
00002 #define DN_DEVICE_H_
00003 
00036 #ifndef _DN_EXP_DEVICE
00037 #define _DN_EXP_DEVICE
00038 #endif /* _DN_EXP_DEVICE */
00039 
00054 #if defined(_USE_WIN_API)
00055 #define DNGetLastError() GetLastError()
00056 #define OSSUCCEEDED(ret) ((ret) != 0)
00057 #define OSFAILED(ret)  ((ret) == 0)
00058 #else
00059 #if defined(_USE_LINUX_API)
00060 #define DNGetLastError() errno
00061 #define OSSUCCEEDED(ret) ((ret) ==  0)
00062 #define OSFAILED(ret)  ((ret) == -1)
00063 #endif
00064 
00069 #define NOPARITY (0)
00070 
00075 #define ODDPARITY (1)
00076 
00081 #define EVENPARITY (2)
00082 
00087 #define ONESTOPBIT (0)
00088 
00093 #define TWOSTOPBITS (2)
00094 
00095 #endif
00096 
00101 #define DEV_BUF_MAX ((uint16_t)-1)
00102 
00107 #define E_INVALIDPACKET _HRESULT_TYPEDEF_(0x80010000L)
00108 
00113 enum CONN_PARAM_CHECK_FLAG
00114 {
00115   CHECK_TYPE_TCP = 0x0001,     
00116   CHECK_TYPE_UDP = 0x0002,     
00117   CHECK_TYPE_COM = 0x0004,     
00118   CHECK_TYPE_ALL = 0x00FF,     
00119   CHECK_FUNC_OPEN = 0x0100,    
00120   CHECK_FUNC_CLOSE = 0x0200,   
00121   CHECK_FUNC_SEND = 0x0400,    
00122   CHECK_FUNC_RECV = 0x0800,    
00123   CHECK_FUNC_TIMEOUT = 0x1000, 
00124   CHECK_FUNC_CLEAR = 0x2000,   
00125   CHECK_FUNC_ALL = 0xFF00,     
00126 };
00127 
00132 enum CONN_TYPE
00133 {
00134   CONN_TCP = CHECK_TYPE_TCP, 
00135   CONN_UDP = CHECK_TYPE_UDP, 
00136   CONN_COM = CHECK_TYPE_COM, 
00137 };
00138 
00144 struct CONN_PARAM_ETH
00145 {
00146   uint32_t dst_addr; 
00147   uint16_t dst_port; 
00148   uint32_t src_addr; 
00149   uint16_t src_port; 
00150 };
00151 
00156 struct CONN_PARAM_COM
00157 {
00158   int port;           
00159   uint32_t baud_rate; 
00160   char parity;        
00161   char data_bits;     
00162   char stop_bits;     
00163   char flow;          
00164 };
00165 
00170 struct CONN_PARAM_COMMON
00171 {
00172   int sock;         
00173   int type;         
00174   uint32_t timeout; 
00175   void *arg;        
00176   HRESULT (*dn_open)(void *param, int *sock);
00177   HRESULT (*dn_close)(int *sock);
00178   HRESULT (*dn_send)(int sock, const char *buf, uint32_t len_buf, void *arg);
00179   HRESULT (*dn_recv)(int sock, char *buf, uint32_t len_buf, uint32_t *len_recved,
00180       uint32_t timeout, void *arg);
00181   HRESULT (*dn_set_timeout)(int sock, uint32_t timeout);
00182   HRESULT (*dn_clear)(int sock, uint32_t timeout);
00183 };
00184 
00185 #ifdef __cplusplus
00186 extern "C"
00187 {
00188 #endif
00189 
00195   _DN_EXP_DEVICE int
00196   parse_conn_type(const char *opt);
00197 
00206   _DN_EXP_DEVICE HRESULT
00207   parse_conn_param_ether(const char *opt, struct CONN_PARAM_ETH *param);
00208 
00222   _DN_EXP_DEVICE HRESULT
00223   parse_conn_param_serial(const char *opt, struct CONN_PARAM_COM *param);
00224 
00231   _DN_EXP_DEVICE HRESULT
00232   check_timeout(int sock, uint32_t timeout);
00233 
00240   _DN_EXP_DEVICE HRESULT
00241   check_conn_param(const struct CONN_PARAM_COMMON *device, int flag);
00242 
00250   _DN_EXP_DEVICE void
00251   memcpy_le(void *dst, const void *src, uint32_t len);
00252 
00260   _DN_EXP_DEVICE void
00261   memcpy_be(void *dst, const void *src, uint32_t len);
00262 
00263 #ifdef __cplusplus
00264 }
00265 #endif
00266 
00267 #endif /* DN_DEVICE_H_ */


bcap_core
Author(s): DENSO WAVE INCORPORATED
autogenerated on Thu Jun 6 2019 21:00:02