alejoseb / Modbus-STM32-HAL-FreeRTOS

Modbus TCP and RTU, Master and Slave for STM32 using Cube HAL and FreeRTOS
GNU Lesser General Public License v2.1
519 stars 182 forks source link

How can I detect and signalize for incoming packets? #58

Closed dolence closed 1 year ago

dolence commented 2 years ago

This isn't an issue, I just want some clarification and didn't know who to ask for.

Examples show how to set a pin after receiving a determined value on the registers. This isn't exactly what I wanna do. How could I signalize (using a LED or drawing on a display) everytime a package is received on my device (slave)?

Thank you in advance.

alejoseb commented 2 years ago

Hi, You need to modify the library according to your needs. For example , you can add the code to handle the led here: https://github.com/alejoseb/Modbus-STM32-HAL-FreeRTOS/blob/742f6c8d3cc56bcbcf8245c626e2f4517ebf102b/MODBUS-LIB/Src/Modbus.c#L732

That line is just before processing the package that was received, or you can add your code after processing the package. You can figure out reading the code around the cited code line.