7 #ifndef ZRTOS_VFS_MODULE_MODBUS_RTU_H 8 #define ZRTOS_VFS_MODULE_MODBUS_RTU_H 22 #ifndef ZRTOS_VFS_MODULE_MODBUS_RTU__CFG_RESPONSE_TIMEOUT_US 23 # define ZRTOS_VFS_MODULE_MODBUS_RTU__CFG_RESPONSE_TIMEOUT_US 1000000 44 uint16_t *crc_ptr =
ZRTOS_CAST(uint16_t*,callback_args);
45 uint16_t crc = *crc_ptr;
49 for(
size_t i = 8; i--;){
50 bool tmp = (crc & 0x0001) != 0;
61 uint16_t crc = 0xffff;
91 if(cbuffer_length > 0){
92 if(cbuffer_length >= 4){
93 uint16_t crc = 0xffff;
200 ,char_transmission_us*3+char_transmission_us/2
321 ret = rtos_vfs_module_modbus_rtu__on_send(mod);
371 zrtos_vfs_module_modbus_rtu_ioctl_t
zrtos_error_t zrtos_vfs_module_modbus_rtu__on_read(zrtos_vfs_file_t *thiz, char *path, void *buf, size_t len, zrtos_vfs_offset_t offset, size_t *out)
#define ZRTOS_CAST(type, value)
bool zrtos_cbuffer__is_empty(zrtos_cbuffer_t *thiz)
zrtos_msg_queue_t * zrtos_vfs_module_modbus_rtu_inode__get_msg_queue_out(zrtos_vfs_module_modbus_rtu_inode_t *thiz)
zrtos_msg_queue_t * zrtos_vfs_module_modbus_rtu_inode__get_msg_queue_in(zrtos_vfs_module_modbus_rtu_inode_t *thiz)
#define ZRTOS_VFS_PLUGIN__3_ON_UMOUNT_DEFAULT()
void zrtos_msg_queue__start_write_transaction(zrtos_msg_queue_t *thiz, zrtos_msg_queue_write_transaction_t *txn)
zrtos_error_t zrtos_msg_queue__pipe_next_message_to_cbuffer(zrtos_msg_queue_t *thiz, zrtos_cbuffer_t *dest, size_t len, size_t *outlen)
#define ZRTOS_CAST__REINTERPRET(type, value)
static uint16_t zrtos_vfs_module_modbus_rtu__crc_str(uint8_t *data, size_t len)
zrtos_error_t zrtos_vfs_module_modbus_rtu__on_recv(void *callback_data)
zrtos_error_t zrtos_msg_queue__put_length(zrtos_msg_queue_t *thiz, size_t len)
zrtos_error_t zrtos_vfs_fd__open(char *path, zrtos_vfs_fd_t *thiz, void *file_ctx)
size_t zrtos_vfs_offset_t
#define ZRTOS_VFS_PLUGIN__0_ON_OPEN_DEFAULT()
zrtos_error_t zrtos_vfs_fd__close(zrtos_vfs_fd_t thiz)
zrtos_vfs_module_uart_callback_t on_send
zrtos_cbuffer_t * zrtos_vfs_module_uart_inode__get_cbuffer_in(zrtos_vfs_module_uart_inode_t *thiz)
zrtos_error_t zrtos_cbuffer__get_ex(zrtos_cbuffer_t *thiz, void *data, size_t len, size_t *outlen)
zrtos_error_t zrtos_vfs_module_modbus_rtu__cmp_crc(uint16_t crc, uint16_t crc_msg)
struct _zrtos_vfs_module_modbus_rtu_inode_t zrtos_vfs_module_modbus_rtu_inode_t
void zrtos_arch__delay_microseconds(uint16_t us)
zrtos_error_t zrtos_msg_queue__put_data(zrtos_msg_queue_t *thiz, void *data, size_t len)
zrtos_error_t zrtos_error_count__add(zrtos_error_count_t *thiz, zrtos_error_t err)
#define ZRTOS_VFS_PLUGIN__8_ON_SEEK_DEFAULT()
bool zrtos_vfs_module_modbus_rtu_inode__init(zrtos_vfs_module_modbus_rtu_inode_t *thiz, zrtos_vfs_module_uart_inode_t *uart, char *timeout_path)
#define ZRTOS_VFS_PLUGIN__1_ON_CLOSE_DEFAULT()
zrtos_vfs_fd_t timeout_fd
void zrtos_vfs_module_modbus_rtu__on_recv_timeout(void *thiz)
zrtos_error_t zrtos_vfs_fd__ioctl(zrtos_vfs_fd_t thiz, char *path, int request,...)
bool zrtos_error_count__init(zrtos_error_count_t *thiz)
zrtos_error_t zrtos_vfs_module_modbus_rtu__on_send(void *callback_data)
zrtos_error_count_t rx_error_count
#define ZRTOS_TYPES__SIZE_MAX
zrtos_msg_queue_t msg_queue_in
#define ZRTOS_VFS_PLUGIN__4_ON_READ(callback)
#define ZRTOS_VFS_PLUGIN__6_ON_CAN_READ(callback)
#define ZRTOS_VFS_PLUGIN__5_ON_WRITE(callback)
zrtos_error_t zrtos_vfs_module_modbus_rtu__on_can_write(zrtos_vfs_file_t *thiz, char *path)
bool zrtos_msg_queue__is_empty(zrtos_msg_queue_t *thiz)
void * zrtos_vfs_file__get_inode_data(zrtos_vfs_file_t *thiz)
bool zrtos_error__is_success(zrtos_error_t thiz)
#define ZRTOS_TYPES__MIN(a, b)
zrtos_vfs_module_uart_callback_t on_recv
size_t zrtos_cbuffer__get_length(zrtos_cbuffer_t *thiz)
#define ZRTOS_VFS_PLUGIN__9_ON_IOCTL(callback)
Successful program execution status.
zrtos_msg_queue_t msg_queue_out
zrtos_cbuffer_t cbuffer_out
void zrtos_msg_queue__rollback_write_transaction(zrtos_msg_queue_t *thiz, zrtos_msg_queue_write_transaction_t *txn)
zrtos_vfs_module_timeout_microseconds_t timeout_frame_us
zrtos_vfs_module_timeout_microseconds_t timeout_response_us
static void zrtos_vfs_module_modbus_rtu__crc(void *callback_args, uint8_t ch)
zrtos_vfs_module_uart_inode_t * uart
zrtos_error_t zrtos_msg_queue__put_cbuffer_data(zrtos_msg_queue_t *thiz, zrtos_cbuffer_t *data, size_t length)
zrtos_error_count_t tx_error_count
uint16_t zrtos_vfs_module_timeout_microseconds_t
#define ZRTOS_VFS_PLUGIN__7_ON_CAN_WRITE(callback)
#define ZRTOS_VFS_MODULE_MODBUS_RTU__CFG_RESPONSE_TIMEOUT_US
zrtos_vfs_module_modbus_rtu_ioctl_t
ZRTOS_VFS_PLUGIN__INIT(modbus_rtu, ZRTOS_VFS_PLUGIN__0_ON_OPEN_DEFAULT() ZRTOS_VFS_PLUGIN__1_ON_CLOSE_DEFAULT() ZRTOS_VFS_PLUGIN__2_ON_MOUNT_DEFAULT() ZRTOS_VFS_PLUGIN__3_ON_UMOUNT_DEFAULT() ZRTOS_VFS_PLUGIN__4_ON_READ(zrtos_vfs_module_modbus_rtu__on_read) ZRTOS_VFS_PLUGIN__5_ON_WRITE(zrtos_vfs_module_modbus_rtu__on_write) ZRTOS_VFS_PLUGIN__6_ON_CAN_READ(zrtos_vfs_module_modbus_rtu__on_can_read) ZRTOS_VFS_PLUGIN__7_ON_CAN_WRITE(zrtos_vfs_module_modbus_rtu__on_can_write) ZRTOS_VFS_PLUGIN__8_ON_SEEK_DEFAULT() ZRTOS_VFS_PLUGIN__9_ON_IOCTL(zrtos_vfs_module_modbus_rtu__on_ioctl))
zrtos_error_t zrtos_vfs_module_modbus_rtu__on_ioctl(zrtos_vfs_file_t *thiz, char *path, int request, va_list args)
zrtos_error_t zrtos_msg_queue__put_end(zrtos_msg_queue_t *thiz)
zrtos_error_t zrtos_vfs_module_modbus_rtu__on_can_read(zrtos_vfs_file_t *thiz, char *path)
void zrtos_error_count__deinit(zrtos_error_count_t *thiz)
zrtos_error_t zrtos_msg_queue__get(zrtos_msg_queue_t *thiz, void *data, size_t len, size_t *outlen)
zrtos_vfs_module_timeout_microseconds_t zrtos_vfs_module_uart__get_char_transmission_time(zrtos_vfs_module_uart_inode_t *thiz)
zrtos_error_t zrtos_vfs_module_modbus_rtu__on_write(zrtos_vfs_file_t *thiz, char *path, void *buf, size_t len, zrtos_vfs_offset_t offset, size_t *out)
#define zrtos_va__arg(ap, type)
zrtos_error_t zrtos_cbuffer__hash(zrtos_cbuffer_t *thiz, size_t length, void(*callback)(void *callback_args, uint8_t ch), void *callback_args)
#define ZRTOS_VFS_PLUGIN__2_ON_MOUNT_DEFAULT()