fix(slave_node): Stabilize Modbus RTU communication
The Modbus server was previously unstable, leading to intermittent CRC errors when polled by a master. This was caused by the main thread exiting after initialization, which created timing and race condition issues for the interrupt-driven Modbus stack. This fix ensures the main thread continues to run in a low-power sleep loop (). This provides a stable context for the Modbus server, resolving the CRC errors and ensuring reliable communication.
This commit is contained in:
parent
6f81e84541
commit
1067796df4
|
|
@ -1,3 +1,17 @@
|
|||
/ {
|
||||
chosen {
|
||||
zephyr,console = &rtt;
|
||||
zephyr,shell-uart = &rtt; // If using shell
|
||||
};
|
||||
|
||||
rtt: rtt {
|
||||
compatible = "segger,rtt-uart";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
label = "RTT";
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
&usart1 {
|
||||
modbus0 {
|
||||
compatible = "zephyr,modbus-serial";
|
||||
|
|
|
|||
|
|
@ -111,5 +111,10 @@ int main(void)
|
|||
LOG_ERR("Modbus RTU server initialization failed");
|
||||
}
|
||||
LOG_INF("APP started");
|
||||
|
||||
while (1) {
|
||||
k_sleep(K_MSEC(1000));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue