mirror of
https://github.com/korneliuszo/lumiax-controller.git
synced 2026-08-06 08:53:36 +02:00
Read some holding reg (WIP)
This commit is contained in:
@@ -12,6 +12,7 @@ CONFIG_BT_GATT_CLIENT=y
|
||||
|
||||
CONFIG_MODBUS=y
|
||||
CONFIG_MODBUS_ROLE_CLIENT=y
|
||||
CONFIG_MODBUS_FP_EXTENSIONS=n
|
||||
|
||||
CONFIG_DEBUG_THREAD_INFO=y
|
||||
CONFIG_EXTRA_EXCEPTION_INFO=y
|
||||
|
||||
+11
-1
@@ -78,6 +78,7 @@ void display_thread(void*,void*,void*)
|
||||
{
|
||||
auto l = display.lock();
|
||||
display.print_chr(0,0,spinner[spinner_idx++]);
|
||||
display.print_str(16,0,cached.on ? " ON":"OFF");
|
||||
char buff[13];
|
||||
snprintf(buff,13,"Bat %6.2u%%",cached.b_soc);
|
||||
display.print_str(0,16,buff);
|
||||
@@ -140,9 +141,17 @@ int main(void)
|
||||
if(modbus_read_input_regs(client_iface, 1, 0x3045, holding_reg,
|
||||
ARRAY_SIZE(holding_reg))!=0)
|
||||
{
|
||||
printt("Read fail");
|
||||
printt("Read fail1");
|
||||
continue;
|
||||
}
|
||||
|
||||
uint16_t onoff;
|
||||
if(modbus_read_holding_regs(client_iface, 1, 0x902C, &onoff,1)!=0)
|
||||
{
|
||||
printt("Read fail3");
|
||||
continue;
|
||||
}
|
||||
printt("%d", onoff);
|
||||
k_mutex_lock(®_data.mut, K_FOREVER);
|
||||
reg_data.d.b_soc = holding_reg[0];
|
||||
reg_data.d.b_v = holding_reg[1];
|
||||
@@ -151,6 +160,7 @@ int main(void)
|
||||
reg_data.d.l_a = holding_reg[6];
|
||||
reg_data.d.s_v = holding_reg[9];
|
||||
reg_data.d.s_a = holding_reg[10];
|
||||
reg_data.d.on = onoff == 0;
|
||||
k_mutex_unlock(®_data.mut);
|
||||
k_sem_give(®_data.new_sample);
|
||||
printt("Read ok");
|
||||
|
||||
@@ -23,6 +23,7 @@ struct Reg_data {
|
||||
uint16_t l_a;
|
||||
uint16_t s_v;
|
||||
uint16_t s_a;
|
||||
bool on;
|
||||
} d;
|
||||
k_mutex mut;
|
||||
k_sem new_sample;
|
||||
|
||||
Reference in New Issue
Block a user