minimal changes
This commit is contained in:
parent
adc6275c55
commit
5ab33e3a7b
|
|
@ -4,8 +4,7 @@
|
|||
#include <zephyr/modbus/modbus.h>
|
||||
#include <zephyr/logging/log.h>
|
||||
|
||||
// LOG_MODULE_REGISTER(mbc, CONFIG_LOG_DEFAULT_LEVEL);
|
||||
LOG_MODULE_REGISTER(mbc, 4); // Set log level to 4 (Debug)
|
||||
LOG_MODULE_REGISTER(mbc, CONFIG_LOG_DEFAULT_LEVEL);
|
||||
|
||||
#define MODBUS_NODE DT_COMPAT_GET_ANY_STATUS_OKAY(zephyr_modbus_serial)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
/* Testing MODBUS functionality
|
||||
This code initializes a Modbus client, sets minimum and maximum water levels,
|
||||
reads the current water level, and logs the results.
|
||||
You can set the zero point and the 2m point for water level in lines 32 and 38.
|
||||
This code initializes a Modbus client, sets the zero point and the 2m point for water level,
|
||||
and reads the water level in both meters and millimeters.
|
||||
It uses the Zephyr RTOS and its Modbus library to communicate with a Modbus server.
|
||||
*/
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
|
|
@ -56,8 +57,7 @@ int main(void)
|
|||
LOG_INF("Water zero point is set to: %dmm", water_level_min_mm);
|
||||
LOG_INF("Water 2m point is set to: %dmm", water_level_max_mm);
|
||||
|
||||
while (1)
|
||||
{ /* Read water level */
|
||||
/* Read water level */
|
||||
rc = mb_read_water_level(&water_level);
|
||||
if (rc < 0)
|
||||
{
|
||||
|
|
@ -73,9 +73,6 @@ int main(void)
|
|||
LOG_INF("Water level: %.3fm", water_level);
|
||||
LOG_INF("Water level: %dmm", water_level_mm);
|
||||
LOG_INF("Modbus test completed successfully");
|
||||
return 0;
|
||||
k_sleep(K_SECONDS(1));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue