Common device API file. More...
Go to the source code of this file.
Classes | |
struct | CONN_PARAM_COM |
A type definition for serial connection parameters. More... | |
struct | CONN_PARAM_COMMON |
A type definition for common communication parameters. More... | |
struct | CONN_PARAM_ETH |
A type definition for Ethernet connection parameters. More... | |
Macros | |
#define | _DN_EXP_DEVICE |
#define | DEV_BUF_MAX ((uint16_t)-1) |
The maximum buffer size of a packet. More... | |
#define | E_INVALIDPACKET _HRESULT_TYPEDEF_(0x80010000L) |
Failed because the packet is invalid. More... | |
#define | EVENPARITY (2) |
A definition for serial communication setting. More... | |
#define | NOPARITY (0) |
A definition for serial communication setting. More... | |
#define | ODDPARITY (1) |
A definition for serial communication setting. More... | |
#define | ONESTOPBIT (0) |
A definition for serial communication setting. More... | |
#define | TWOSTOPBITS (2) |
A definition for serial communication setting. More... | |
Enumerations | |
enum | CONN_PARAM_CHECK_FLAG { CHECK_TYPE_TCP = 0x0001, CHECK_TYPE_UDP = 0x0002, CHECK_TYPE_COM = 0x0004, CHECK_TYPE_ALL = 0x00FF, CHECK_FUNC_OPEN = 0x0100, CHECK_FUNC_CLOSE = 0x0200, CHECK_FUNC_SEND = 0x0400, CHECK_FUNC_RECV = 0x0800, CHECK_FUNC_TIMEOUT = 0x1000, CHECK_FUNC_CLEAR = 0x2000, CHECK_FUNC_ALL = 0xFF00 } |
Definitions for check_conn_param function. More... | |
enum | CONN_TYPE { CONN_TCP = CHECK_TYPE_TCP, CONN_UDP = CHECK_TYPE_UDP, CONN_COM = CHECK_TYPE_COM } |
Connection type. More... | |
Functions | |
_DN_EXP_DEVICE HRESULT | check_conn_param (const struct CONN_PARAM_COMMON *device, int flag) |
Checks the communication parameters. More... | |
_DN_EXP_DEVICE HRESULT | check_timeout (int sock, uint32_t timeout) |
Checks the communication timeout. More... | |
_DN_EXP_DEVICE void | memcpy_be (void *dst, const void *src, uint32_t len) |
Orders to big endian. More... | |
_DN_EXP_DEVICE void | memcpy_le (void *dst, const void *src, uint32_t len) |
Orders to little endian. More... | |
_DN_EXP_DEVICE HRESULT | parse_conn_param_ether (const char *opt, struct CONN_PARAM_ETH *param) |
Parses Ethernet connection parameters. More... | |
_DN_EXP_DEVICE HRESULT | parse_conn_param_serial (const char *opt, struct CONN_PARAM_COM *param) |
Parses serial connection parameters. More... | |
_DN_EXP_DEVICE int | parse_conn_type (const char *opt) |
Parses and returns the connection type. More... | |
Common device API file.
Defines common device APIs.
Software License Agreement (MIT License)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Definition in file dn_device.h.
#define _DN_EXP_DEVICE |
Definition at line 37 of file dn_device.h.
#define DEV_BUF_MAX ((uint16_t)-1) |
The maximum buffer size of a packet.
Definition at line 101 of file dn_device.h.
#define E_INVALIDPACKET _HRESULT_TYPEDEF_(0x80010000L) |
Failed because the packet is invalid.
Definition at line 107 of file dn_device.h.
#define EVENPARITY (2) |
A definition for serial communication setting.
Definition at line 81 of file dn_device.h.
#define NOPARITY (0) |
A definition for serial communication setting.
Definition at line 69 of file dn_device.h.
#define ODDPARITY (1) |
A definition for serial communication setting.
Definition at line 75 of file dn_device.h.
#define ONESTOPBIT (0) |
A definition for serial communication setting.
Definition at line 87 of file dn_device.h.
#define TWOSTOPBITS (2) |
A definition for serial communication setting.
Definition at line 93 of file dn_device.h.
Definitions for check_conn_param function.
Definition at line 113 of file dn_device.h.
enum CONN_TYPE |
Connection type.
Enumerator | |
---|---|
CONN_TCP |
TCP connection. |
CONN_UDP |
UDP connection. |
CONN_COM |
Serial connection. |
Definition at line 132 of file dn_device.h.
HRESULT check_conn_param | ( | const struct CONN_PARAM_COMMON * | device, |
int | flag | ||
) |
Checks the communication parameters.
[in] | device | Communication parameters to be checked. |
[in] | flag | Flags to be checked with CONN_PARAM_CHECK_FLAG. |
Definition at line 419 of file dn_device.c.
Checks the communication timeout.
[in] | sock | File descriptor to be checked. |
[in] | timeout | Timeout value. |
Definition at line 385 of file dn_device.c.
void memcpy_be | ( | void * | dst, |
const void * | src, | ||
uint32_t | len | ||
) |
Orders to big endian.
[out] | dst | The pointer of ordered variable. |
[in] | src | The pointer of variable to be ordered. |
[in] | len | The number of buffers to be ordered. |
Definition at line 495 of file dn_device.c.
void memcpy_le | ( | void * | dst, |
const void * | src, | ||
uint32_t | len | ||
) |
Orders to little endian.
[out] | dst | The pointer of ordered variable. |
[in] | src | The pointer of variable to be ordered. |
[in] | len | The number of buffers to be ordered. |
Definition at line 469 of file dn_device.c.
HRESULT parse_conn_param_ether | ( | const char * | opt, |
struct CONN_PARAM_ETH * | param | ||
) |
Parses Ethernet connection parameters.
[in] | opt | Connection option string. |
[out] | param | Parsed Ethernet connection parameters. |
Definition at line 121 of file dn_device.c.
HRESULT parse_conn_param_serial | ( | const char * | opt, |
struct CONN_PARAM_COM * | param | ||
) |
Parses serial connection parameters.
[in] | opt | Connection option string. |
[out] | param | Parsed serial connection parameters. |
Definition at line 235 of file dn_device.c.
int parse_conn_type | ( | const char * | opt | ) |
Parses and returns the connection type.
[in] | opt | Connection option string. |
Definition at line 93 of file dn_device.c.