Updated README

This commit is contained in:
Mrna 2024-10-11 17:33:11 +02:00
parent 08c1cc989e
commit f9589f6b28

View File

@ -1,22 +1,22 @@
# Modbus slave RTU library
*(does NOT support ASCII and TCP)*
Simple implementation of Modbus RTU. *(Does NOT support ASCII and TCP)*.
USAGE:
## Usage
1. Implement functions modbus_callback_function() and modbus_uart_transmit_function()
* modbus_uart_transmit_function() sends data via UART
* modbus_callback_function() does the real work: read sensors, set outputs...
1. Implement functions modbus\_callback\_function() and modbus\_uart\_transmit\_function()
* modbus\_uart\_transmit\_function() sends data via UART
* modbus\_callback\_function() does the real work: read sensors, set outputs...
note that when filling buffers (e.g. input_registers[]) user must ensure that all data is big-endian. These functions are implementation-specific.
note that when filling buffers (e.g. input\_registers[]) user must ensure that all data is big-endian. These functions are implementation-specific.
2. Set device address (variable modbus_device_address); you can do this either
* setting modbus_device_address directly (modbus.h needs to be included, duh)
* using modbus_set_device_address(uint8_t address) function
2. Set device address (variable modbus\_device\_address); you can do this either
* setting modbus\_device\_address directly (modbus.h needs to be included, duh)
* using modbus\_set\_device\_address(uint8\_t address) function
Or you can leave address as-is (MODBUS_DEFAULT_SLAVE_ADDRESS) and set it via Modbus during runtime
Or you can leave address as-is (MODBUS\_DEFAULT\_SLAVE\_ADDRESS) and set it via Modbus during runtime
3. Call modbus_process_msg() after message reception; you need to observe Modbus RTU timing:
3. Call modbus\_process\_msg() after message reception; you need to observe Modbus RTU timing:
* pauses between chars in frame are less or equal to 1.5 char
* pauses between frames are at least 3.5 chars (of silence)
@ -26,10 +26,11 @@ Note that byte order is big endian.
## Useful links:
https://www.picotech.com/library/oscilloscopes/modbus-serial-protocol-decoding
* [Picotech article](https://www.picotech.com/library/oscilloscopes/modbus-serial-protocol-decoding)
* [IPC2U article](https://ipc2u.com/articles/knowledge-base/modbus-rtu-made-simple-with-detailed-descriptions-and-examples/)
* [Modbus documentation: modbus over serial line](https://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf)
* [Modbus documentation: modbus application protocol](https://www.modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf)
https://ipc2u.com/articles/knowledge-base/modbus-rtu-made-simple-with-detailed-descriptions-and-examples/
## License
https://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf
https://www.modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.