pikapython/package/modbus/agile_modbus_tcp.h

88 lines
1.7 KiB
C
Raw Normal View History

/**
* @file agile_modbus_tcp.h
* @brief Agile Modbus TCP
* @author (2544047213@qq.com)
* @date 2021-12-02
*
* @attention
*
* <h2><center>&copy; Copyright (c) 2021 Ma Longwei.
* All rights reserved.</center></h2>
*
*/
#ifndef __PKG_AGILE_MODBUS_TCP_H
#define __PKG_AGILE_MODBUS_TCP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
/** @addtogroup TCP
* @{
*/
/** @defgroup TCP_Exported_Constants TCP Exported Constants
* @{
*/
2023-07-09 23:50:40 +08:00
#define AGILE_MODBUS_TCP_HEADER_LENGTH 7
#define AGILE_MODBUS_TCP_PRESET_REQ_LENGTH 12
#define AGILE_MODBUS_TCP_PRESET_RSP_LENGTH 8
#define AGILE_MODBUS_TCP_CHECKSUM_LENGTH 0
/**
@verbatim
Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5
TCP MODBUS ADU = 253 bytes + MBAP (7 bytes) = 260 bytes
@endverbatim
*/
#define AGILE_MODBUS_TCP_MAX_ADU_LENGTH 260
/**
* @}
*/
/** @defgroup TCP_Exported_Types TCP Exported Types
* @{
*/
/**
* @brief TCP
*/
typedef struct agile_modbus_tcp {
agile_modbus_t _ctx; /**< modbus 句柄 */
2023-07-09 23:50:40 +08:00
uint16_t t_id; /**< Extract from MODBUS Messaging on TCP/IP Implementation
Guide V1.0b (page 23/46): The transaction identifier is used
to associate the future response with the request. This
identifier is unique on each TCP connection. */
} agile_modbus_tcp_t;
/**
* @}
*/
/** @addtogroup TCP_Exported_Functions
* @{
*/
2023-07-09 23:50:40 +08:00
int agile_modbus_tcp_init(agile_modbus_tcp_t* ctx,
uint8_t* send_buf,
int send_bufsz,
uint8_t* read_buf,
int read_bufsz);
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif