Better docs for platform functions
This commit is contained in:
parent
9d2918b3bb
commit
ac66269cda
14
README.md
14
README.md
@ -101,17 +101,19 @@ client/server instance.
|
|||||||
### Transport read/write
|
### Transport read/write
|
||||||
|
|
||||||
```C
|
```C
|
||||||
int read_byte(uint8_t* b, int32_t, void* arg);
|
int read_byte(uint8_t* b, int32_t timeout_ms, void* arg);
|
||||||
int write_byte(uint8_t b, int32_t, void* arg);
|
int write_byte(uint8_t b, int32_t timeout_ms, void* arg);
|
||||||
```
|
```
|
||||||
|
|
||||||
These are your platform-specific functions that read/write data to/from a serial port or a TCP connection.
|
These are your platform-specific functions that read/write data to/from a serial port or a TCP connection.
|
||||||
Both functions should block until the requested byte is read/written.
|
Both methods should block until either:
|
||||||
If your implementation uses a read/write timeout, and the timeout expires, the function should return 0.
|
- a byte is read/written
|
||||||
Their return values should be:
|
- the timeout, with `timeout_ms >= 0`, expires
|
||||||
|
|
||||||
|
A value `< 0` for `timeout_ms` means no timeout.
|
||||||
|
Their return values should be:
|
||||||
- `1` in case of success
|
- `1` in case of success
|
||||||
- `0` if no data is available immediately or after an internal timeout expiration
|
- `0` if no data is available immediately or after timeout expiration
|
||||||
- `-1` in case of error
|
- `-1` in case of error
|
||||||
|
|
||||||
### Sleep
|
### Sleep
|
||||||
|
|||||||
21
nanomodbus.h
21
nanomodbus.h
@ -106,11 +106,16 @@ typedef enum nmbs_transport {
|
|||||||
* Passed to nmbs_server_create() and nmbs_client_create().
|
* Passed to nmbs_server_create() and nmbs_client_create().
|
||||||
*
|
*
|
||||||
* read_byte() and write_byte() are the platform-specific methods that read/write data to/from a serial port or a TCP connection.
|
* read_byte() and write_byte() are the platform-specific methods that read/write data to/from a serial port or a TCP connection.
|
||||||
* Both methods should block until the requested byte is read/written.
|
*
|
||||||
* If your implementation uses a read/write timeout, and the timeout expires, the methods should return 0.
|
* Both methods should block until either:
|
||||||
|
* - a byte is read/written
|
||||||
|
* - the timeout, with timeout_ms >= 0, expires
|
||||||
|
*
|
||||||
|
* A value < 0 for timeout_ms means no timeout.
|
||||||
|
*
|
||||||
* Their return values should be:
|
* Their return values should be:
|
||||||
* - `1` in case of success
|
* - `1` in case of success
|
||||||
* - `0` if no data is available immediately or after an internal timeout expiration
|
* - `0` if no data is available immediately or after timeout expiration
|
||||||
* - `-1` in case of error
|
* - `-1` in case of error
|
||||||
*
|
*
|
||||||
* sleep() is the platform-specific method to pause for a certain amount of milliseconds.
|
* sleep() is the platform-specific method to pause for a certain amount of milliseconds.
|
||||||
@ -119,11 +124,11 @@ typedef enum nmbs_transport {
|
|||||||
* After the creation of an instance it can be changed with nmbs_set_platform_arg().
|
* After the creation of an instance it can be changed with nmbs_set_platform_arg().
|
||||||
*/
|
*/
|
||||||
typedef struct nmbs_platform_conf {
|
typedef struct nmbs_platform_conf {
|
||||||
nmbs_transport transport; /*!< Transport type */
|
nmbs_transport transport; /*!< Transport type */
|
||||||
int (*read_byte)(uint8_t* b, int32_t, void* arg); /*!< Byte read transport function pointer */
|
int (*read_byte)(uint8_t* b, int32_t timeout_ms, void* arg); /*!< Byte read transport function pointer */
|
||||||
int (*write_byte)(uint8_t b, int32_t, void* arg); /*!< Byte write transport function pointer */
|
int (*write_byte)(uint8_t b, int32_t timeout_ms, void* arg); /*!< Byte write transport function pointer */
|
||||||
void (*sleep)(uint32_t milliseconds, void* arg); /*!< Sleep function pointer */
|
void (*sleep)(uint32_t milliseconds, void* arg); /*!< Sleep function pointer */
|
||||||
void* arg; /*!< User data, will be passed to functions above */
|
void* arg; /*!< User data, will be passed to functions above */
|
||||||
} nmbs_platform_conf;
|
} nmbs_platform_conf;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user