Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
Signed-off-by: Cornelius Claussen <[email protected]>
  • Loading branch information
corneliusclaussen committed Oct 2, 2024
1 parent 7b29183 commit f17afe4
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ void ev_board_support_extendedImpl::init() {

mod->serial.signal_keep_alive.connect([this](KeepAlive k) {
types::ev_board_support_extended::KeepAliveData data;
data.timestamp = k.time_stamp; // will get converted to signed unfortunatly
data.timestamp = k.time_stamp; // will get converted to signed unfortunatly
data.hw_revision_minor = k.hw_revision_minor; // will get converted to signed unfortunatly
data.sw_version = k.sw_version_string;
switch (k.hw_revision_major)
{
switch (k.hw_revision_major) {
case ConfigHardwareRevisionMajor_HW_MAJOR_REV_A:
data.hw_revision_major = types::ev_board_support_extended::Hw_revision_major::Rev_A;
break;

default:
data.hw_revision_major = types::ev_board_support_extended::Hw_revision_major::UNKNOWN;
break;
Expand All @@ -27,11 +26,11 @@ void ev_board_support_extendedImpl::init() {
});

mod->serial.signal_ac_meas_instant.connect([this](ACMeasInstant d) {
types::ev_board_support_extended::ACVoltageData data;
data.Ua = d.Ua;
data.Ub = d.Ub;
data.Uc = d.Uc;
publish_ac_voltage_event(data);
types::ev_board_support_extended::ACVoltageData data;
data.Ua = d.Ua;
data.Ub = d.Ub;
data.Uc = d.Uc;
publish_ac_voltage_event(data);
});

mod->serial.signal_ac_stats.connect([this](ACMeasStats d) {
Expand All @@ -47,7 +46,7 @@ void ev_board_support_extendedImpl::init() {
data.Uc.min = d.Uc.min;
data.Uc.max = d.Uc.max;
data.Uc.average = d.Uc.avg;

publish_ac_statistics_event(data);
});
}
Expand All @@ -61,11 +60,10 @@ bool ev_board_support_extendedImpl::handle_set_status_led(bool& state) {
return true;
}

void ev_board_support_extendedImpl::handle_reset(bool& soft_reset)
{
//EVLOG_info << "Resetting " << (soft_reset ? "SOFT" : "HARD");
if(soft_reset) {
if(!mod->serial.soft_reset())
void ev_board_support_extendedImpl::handle_reset(bool& soft_reset) {
// EVLOG_info << "Resetting " << (soft_reset ? "SOFT" : "HARD");
if (soft_reset) {
if (!mod->serial.soft_reset())
EVLOG_error << "Could not soft reset";
else
EVLOG_info << "Sent soft resetting packet to MCU.";
Expand All @@ -74,22 +72,19 @@ void ev_board_support_extendedImpl::handle_reset(bool& soft_reset)
}
}

void ev_board_support_extendedImpl::handle_get_ac_data_instant()
{
if(!mod->serial.get_ac_data_instant())
void ev_board_support_extendedImpl::handle_get_ac_data_instant() {
if (!mod->serial.get_ac_data_instant())
EVLOG_error << "Could not send measurement request packet.";
else
EVLOG_info << "Sent AC instant measurement request packet.";
}

void ev_board_support_extendedImpl::handle_get_ac_statistics()
{
if(!mod->serial.get_ac_statistic())
void ev_board_support_extendedImpl::handle_get_ac_statistics() {
if (!mod->serial.get_ac_statistic())
EVLOG_error << "Could not send measurement request packet.";
else
EVLOG_info << "Sent AC statistics measurement request packet.";
}


} // namespace board_support
} // namespace board_support_extended
} // namespace module
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ev_board_support_extendedImpl : public ev_board_support_extendedImplBase {
// insert other definitions here
// ev@3d7da0ad-02c2-493d-9920-0bbbd56b9876:v1

} // namespace board_support
} // namespace board_support_extended
} // namespace module

#endif // BOARD_SUPPORT_EV_BOARD_SUPPORT_EXTENDED_IMPL_HPP
106 changes: 49 additions & 57 deletions modules/mMWcarBSP/mMWcar_mcu_comms/evSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ void evSerial::handle_packet(uint8_t* buf, int len) {
McuToEverest msg_in;
pb_istream_t istream = pb_istream_from_buffer(buf, len);


if (pb_decode(&istream, McuToEverest_fields, &msg_in)) {
switch (msg_in.which_payload) {

Expand All @@ -158,50 +157,49 @@ void evSerial::handle_packet(uint8_t* buf, int len) {
case McuToEverest_response_calibration_tag:
signal_calibration_response(msg_in.payload.response_calibration);
break;
/*
case McuToEverest_cp_state_tag:
signal_cp_state(msg_in.connector, msg_in.payload.cp_state);
break;
case McuToEverest_set_coil_state_response_tag:
signal_set_coil_state_response(msg_in.connector, msg_in.payload.set_coil_state_response);
break;
case McuToEverest_error_flags_tag:
signal_error_flags(msg_in.connector, msg_in.payload.error_flags);
break;
case McuToEverest_telemetry_tag:
signal_telemetry(msg_in.connector, msg_in.payload.telemetry);
break;
case McuToEverest_reset_tag:
reset_done_flag = true;
if (!forced_reset)
signal_spurious_reset(msg_in.payload.reset);
break;
case McuToEverest_pp_state_tag:
signal_pp_state(msg_in.connector, msg_in.payload.pp_state);
break;
case McuToEverest_fan_state_tag:
signal_fan_state(msg_in.payload.fan_state);
break;
case McuToEverest_lock_state_tag:
signal_lock_state(msg_in.connector, msg_in.payload.lock_state);
break;
case McuToEverest_config_request_tag:
signal_config_request();
break;
*/
/*
case McuToEverest_cp_state_tag:
signal_cp_state(msg_in.connector, msg_in.payload.cp_state);
break;
case McuToEverest_set_coil_state_response_tag:
signal_set_coil_state_response(msg_in.connector, msg_in.payload.set_coil_state_response);
break;
case McuToEverest_error_flags_tag:
signal_error_flags(msg_in.connector, msg_in.payload.error_flags);
break;
case McuToEverest_telemetry_tag:
signal_telemetry(msg_in.connector, msg_in.payload.telemetry);
break;
case McuToEverest_reset_tag:
reset_done_flag = true;
if (!forced_reset)
signal_spurious_reset(msg_in.payload.reset);
break;
case McuToEverest_pp_state_tag:
signal_pp_state(msg_in.connector, msg_in.payload.pp_state);
break;
case McuToEverest_fan_state_tag:
signal_fan_state(msg_in.payload.fan_state);
break;
case McuToEverest_lock_state_tag:
signal_lock_state(msg_in.connector, msg_in.payload.lock_state);
break;
case McuToEverest_config_request_tag:
signal_config_request();
break;
*/
default:
break;
}
}

}

void evSerial::cobs_decode(uint8_t* buf, int len) {
Expand Down Expand Up @@ -270,7 +268,7 @@ void evSerial::read_thread() {
if (read_thread_handle.shouldExit())
break;
n = read(fd, buf, sizeof buf);

Check notice on line 270 in modules/mMWcarBSP/mMWcar_mcu_comms/evSerial.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/mMWcarBSP/mMWcar_mcu_comms/evSerial.cpp#L270

Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20).
//printf ("read %u bytes.\n", n);
// printf ("read %u bytes.\n", n);
cobs_decode(buf, n);
}
}
Expand Down Expand Up @@ -335,41 +333,36 @@ bool evSerial::serial_timed_out() {
return false;
}

bool evSerial::soft_reset()
{
bool evSerial::soft_reset() {
EverestToMcu msg_out;
msg_out.which_payload = EverestToMcu_reset_tag;
msg_out.payload.reset = true;

return link_write(&msg_out);
}

bool evSerial::get_ac_data_instant()
{
bool evSerial::get_ac_data_instant() {
EverestToMcu msg_out;
msg_out.which_payload = EverestToMcu_request_measurement_tag;
msg_out.payload.request_measurement = MeasRequest_AC_INSTANT;
msg_out.payload.request_measurement = MeasRequest_AC_INSTANT;
return link_write(&msg_out);
}

bool evSerial::get_ac_statistic()
{
bool evSerial::get_ac_statistic() {
EverestToMcu msg_out;
msg_out.which_payload = EverestToMcu_request_measurement_tag;
msg_out.payload.request_measurement = MeasRequest_AC_STATISTICS;
msg_out.payload.request_measurement = MeasRequest_AC_STATISTICS;
return link_write(&msg_out);
}

bool evSerial::get_calibration_values()
{
bool evSerial::get_calibration_values() {
EverestToMcu msg_out;
msg_out.which_payload = EverestToMcu_get_calibration_tag;
msg_out.payload.get_calibration = true;
return link_write(&msg_out);
}

bool evSerial::set_calibration_values(CalibrationValues& vals)
{
bool evSerial::set_calibration_values(CalibrationValues& vals) {
EverestToMcu msg_out;

msg_out.which_payload = EverestToMcu_set_calibration_tag;
Expand All @@ -378,8 +371,7 @@ bool evSerial::set_calibration_values(CalibrationValues& vals)
return link_write(&msg_out);
}

bool evSerial::request_ac_calibration(CalibrationRequest& req)
{
bool evSerial::request_ac_calibration(CalibrationRequest& req) {
EverestToMcu msg_out;

msg_out.which_payload = EverestToMcu_request_calibration_tag;
Expand Down
Loading

0 comments on commit f17afe4

Please sign in to comment.