diff options
author | Scott Murray <scott.murray@konsulko.com> | 2022-06-16 00:28:36 -0400 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2022-06-17 17:44:47 -0400 |
commit | 096908375ecbfc6388d0aec69a35b2a8ffc53d47 (patch) | |
tree | 4f346d772fcdcbfc112d5aba4d379d1db175979a /src/hvac-can-helper.hpp | |
parent | 7f647062d889b299a4dd521148a4970bf6c8e75a (diff) |
Repurpose into VIS clientneedlefish_13.93.0needlefish/13.93.013.93.0
Repurpose repository for a spiritual successor of the previous
binding. The replacement is a daemon that demonstrates servicing
HVAC actuators from the VSS schema via VIS signals from KUKSA.val.
Currently the connection to KUKSA.val is websocket based using the
boost::asio framework, but the plan is to migrate to grpc as that
becomes more robust in KUKSA.val.
Notable changes:
- New code is completely C++, partly to leverage using Boost, but
also to futureproof future work with grpc.
- Switch from CMake to meson for ease of development and some
degree of futureproofing.
- Use with systemd is assumed; behavior follows the systemd
daemon guidelines barring the use of journald logging prefixes,
which may be addressed with future work. A systemd unit is
also installed as part of the build.
- SPDX license headers using SPDX "short identifiers" are used in
source files rather than the full copyright headers used in the
previous codebase. This follows the direction that projects such
as the Linux kernel are going in.
- The JSON configuration file for the LED control files for the
demo platform has been migrated to a INI format configuration
file matching what has been done for the VIS client configuration
in other recent work.
Bug-AGL: SPEC-4409
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: Ic2061bca9670b1e461d6f1e6591471e257fff5b9
Diffstat (limited to 'src/hvac-can-helper.hpp')
-rw-r--r-- | src/hvac-can-helper.hpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/hvac-can-helper.hpp b/src/hvac-can-helper.hpp new file mode 100644 index 0000000..3005d6b --- /dev/null +++ b/src/hvac-can-helper.hpp @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: Apache-2.0 + +#ifndef _HVAC_CAN_HELPER_HPP +#define _HVAC_CAN_HELPER_HPP + +#include <string> +#include <linux/can.h> + +class HvacCanHelper +{ +public: + HvacCanHelper(); + + ~HvacCanHelper(); + + void set_left_temperature(uint8_t temp); + + void set_right_temperature(uint8_t temp); + + void set_fan_speed(uint8_t temp); + +private: + uint8_t convert_temp(uint8_t value) { + int result = ((0xF0 - 0x10) / 15) * (value - 15) + 0x10; + if (result < 0x10) + result = 0x10; + if (result > 0xF0) + result = 0xF0; + + return (uint8_t) result; + } + + void read_config(); + + void can_open(); + + void can_close(); + + void can_update(); + + std::string m_port; + unsigned m_verbose; + bool m_config_valid; + bool m_active; + int m_can_socket; + struct sockaddr_can m_can_addr; + + uint8_t m_temp_left; + uint8_t m_temp_right; + uint8_t m_fan_speed; +}; + +#endif // _HVAC_CAN_HELPER_HPP |