nanoMODBUS
Data Fields
nmbs_platform_conf Struct Reference

#include <nanomodbus.h>

Data Fields

nmbs_transport transport
 
int32_t(* read )(uint8_t *buf, uint16_t count, int32_t byte_timeout_ms, void *arg)
 
int32_t(* write )(const uint8_t *buf, uint16_t count, int32_t byte_timeout_ms, void *arg)
 
uint16_t(* crc_calc )(const uint8_t *data, uint32_t length, void *arg)
 
void * arg
 
uint32_t initialized
 

Detailed Description

nanoMODBUS platform configuration struct. Passed to nmbs_server_create() and nmbs_client_create().

read() and write() are the platform-specific methods that read/write data to/from a serial port or a TCP connection.

Both methods should block until either:

A value < 0 for byte_timeout_ms means no timeout.

Their return value should be the number of bytes actually read/written, or < 0 in case of error. A return value between 0 and count - 1 will be treated as if a timeout occurred on the transport side. All other values will be treated as transport errors.

Additionally, an optional crc_calc() function can be defined to override the default nanoMODBUS CRC calculation function.

These methods accept a pointer to arbitrary user-data, which is the arg member of this struct. After the creation of an instance it can be changed with nmbs_set_platform_arg().

Field Documentation

◆ arg

void* nmbs_platform_conf::arg

User data, will be passed to functions above

◆ crc_calc

uint16_t(* nmbs_platform_conf::crc_calc) (const uint8_t *data, uint32_t length, void *arg)

CRC calculation function pointer. Optional

◆ initialized

uint32_t nmbs_platform_conf::initialized

Reserved, workaround for older user code not calling nmbs_platform_conf_create()

◆ read

int32_t(* nmbs_platform_conf::read) (uint8_t *buf, uint16_t count, int32_t byte_timeout_ms, void *arg)

Bytes read transport function pointer

◆ transport

nmbs_transport nmbs_platform_conf::transport

Transport type

◆ write

int32_t(* nmbs_platform_conf::write) (const uint8_t *buf, uint16_t count, int32_t byte_timeout_ms, void *arg)

Bytes write transport function pointer


The documentation for this struct was generated from the following file: