add configuration for serial ports
This commit is contained in:
Родитель
2c71e5bd54
Коммит
7962fad3c3
|
@ -1,75 +1,86 @@
|
||||||
// Copyright (c) Microsoft. All rights reserved.
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
#ifndef MODBUS_READ_COMMON_H
|
#ifndef MODBUS_READ_COMMON_H
|
||||||
#define MODBUS_READ_COMMON_H
|
#define MODBUS_READ_COMMON_H
|
||||||
|
|
||||||
#include "parson.h"
|
#include "parson.h"
|
||||||
#define SOCKET_CLOSED (0)
|
#define SOCKET_CLOSED (0)
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
||||||
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#pragma comment(lib,"ws2_32.lib") //Winsock Library
|
#pragma comment(lib,"ws2_32.lib") //Winsock Library
|
||||||
#define SOCKET_TYPE SOCKET
|
#define SOCKET_TYPE SOCKET
|
||||||
#define FILE_TYPE HANDLE
|
#define FILE_TYPE HANDLE
|
||||||
#define INVALID_FILE INVALID_HANDLE_VALUE
|
#define INVALID_FILE INVALID_HANDLE_VALUE
|
||||||
#define SNPRINTF_S sprintf_s
|
#define SNPRINTF_S sprintf_s
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#define SOCKET_TYPE int
|
#define SOCKET_TYPE int
|
||||||
#define FILE_TYPE int
|
#define FILE_TYPE int
|
||||||
#define SOCKET_ERROR (-1)
|
#define SOCKET_ERROR (-1)
|
||||||
#define INVALID_SOCKET (~0)
|
#define INVALID_SOCKET (~0)
|
||||||
#define INVALID_FILE -1
|
#define INVALID_FILE -1
|
||||||
#define SNPRINTF_S snprintf
|
#define SNPRINTF_S snprintf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct MODBUS_READ_CONFIG_TAG MODBUS_READ_CONFIG;
|
typedef struct MODBUS_READ_CONFIG_TAG MODBUS_READ_CONFIG;
|
||||||
typedef struct MODBUS_READ_OPERATION_TAG MODBUS_READ_OPERATION;
|
typedef struct MODBUS_READ_OPERATION_TAG MODBUS_READ_OPERATION;
|
||||||
|
|
||||||
typedef int(*encode_read_cb_type)(void*, void*, void*);
|
typedef int(*encode_read_cb_type)(void*, void*, void*);
|
||||||
typedef int(*encode_write_cb_type)(void*, void*, unsigned char, unsigned char, unsigned short, unsigned short);
|
typedef int(*encode_write_cb_type)(void*, void*, unsigned char, unsigned char, unsigned short, unsigned short);
|
||||||
typedef int(*decode_response_cb_type)(void*, void*);
|
typedef int(*decode_response_cb_type)(void*, void*);
|
||||||
typedef int(*send_request_cb_type)(MODBUS_READ_CONFIG *, unsigned char*, int, unsigned char*);
|
typedef int(*send_request_cb_type)(MODBUS_READ_CONFIG *, unsigned char*, int, unsigned char*);
|
||||||
typedef void(*close_server_cb_type)(MODBUS_READ_CONFIG *);
|
typedef void(*close_server_cb_type)(MODBUS_READ_CONFIG *);
|
||||||
|
|
||||||
struct MODBUS_READ_OPERATION_TAG
|
//flow control
|
||||||
{
|
#define FLOW_CONTROL_NONE 0
|
||||||
MODBUS_READ_OPERATION * p_next;
|
#define FLOW_CONTROL_XONOFF 1
|
||||||
unsigned char unit_id;
|
#define FLOW_CONTROL_RTSCTS 2
|
||||||
unsigned char function_code;
|
#define FLOW_CONTROL_DSRDTR 3
|
||||||
unsigned short address;
|
|
||||||
unsigned short length;
|
struct MODBUS_READ_OPERATION_TAG
|
||||||
unsigned char read_request[256];
|
{
|
||||||
int read_request_len;
|
MODBUS_READ_OPERATION * p_next;
|
||||||
};
|
unsigned char unit_id;
|
||||||
|
unsigned char function_code;
|
||||||
struct MODBUS_READ_CONFIG_TAG
|
unsigned short address;
|
||||||
{
|
unsigned short length;
|
||||||
MODBUS_READ_CONFIG * p_next;
|
unsigned char read_request[256];
|
||||||
MODBUS_READ_OPERATION * p_operation;
|
int read_request_len;
|
||||||
size_t read_interval;
|
};
|
||||||
char server_str[16];
|
|
||||||
char mac_address[18];
|
struct MODBUS_READ_CONFIG_TAG
|
||||||
char device_type[64];
|
{
|
||||||
int sqlite_enabled;
|
MODBUS_READ_CONFIG * p_next;
|
||||||
SOCKET_TYPE socks;
|
MODBUS_READ_OPERATION * p_operation;
|
||||||
FILE_TYPE files;
|
size_t read_interval;
|
||||||
size_t time_check;
|
char server_str[16];
|
||||||
encode_read_cb_type encode_read_cb;
|
char mac_address[18];
|
||||||
encode_write_cb_type encode_write_cb;
|
char device_type[64];
|
||||||
decode_response_cb_type decode_response_cb;
|
int sqlite_enabled;
|
||||||
send_request_cb_type send_request_cb;
|
SOCKET_TYPE socks;
|
||||||
close_server_cb_type close_server_cb;
|
FILE_TYPE files;
|
||||||
}; /*this needs to be passed to the Module_Create function*/
|
size_t time_check;
|
||||||
|
unsigned int baud_rate;
|
||||||
#endif /*MODBUS_READ_COMMON_H*/
|
unsigned char stop_bits;
|
||||||
|
unsigned char data_bits;
|
||||||
|
unsigned char parity;
|
||||||
|
unsigned char flow_control;
|
||||||
|
encode_read_cb_type encode_read_cb;
|
||||||
|
encode_write_cb_type encode_write_cb;
|
||||||
|
decode_response_cb_type decode_response_cb;
|
||||||
|
send_request_cb_type send_request_cb;
|
||||||
|
close_server_cb_type close_server_cb;
|
||||||
|
}; /*this needs to be passed to the Module_Create function*/
|
||||||
|
|
||||||
|
#endif /*MODBUS_READ_COMMON_H*/
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче