Skip to content

Commit

Permalink
add cpplint for dronecan
Browse files Browse the repository at this point in the history
  • Loading branch information
PonomarevDA committed Apr 2, 2024
1 parent b2314b8 commit d6ddac4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 27 deletions.
1 change: 1 addition & 0 deletions .github/workflows/code_style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ jobs:
- name: cpplint cyphal
run: |
cpplint Src/cyphal_application/*pp Src/cyphal_application/modules/*/*pp
cpplint Src/dronecan_application/*pp Src/dronecan_application/modules/*pp
6 changes: 3 additions & 3 deletions Src/dronecan_application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


void application_entry_point() {
paramsInit(static_cast<uint8_t>(IntParamsIndexes::INTEGER_PARAMS_AMOUNT), NUM_OF_STR_PARAMS, -1, 1);
paramsInit((ParamIndex_t)IntParamsIndexes::INTEGER_PARAMS_AMOUNT, NUM_OF_STR_PARAMS, -1, 1);
paramsLoad();

auto node_id = paramsGetIntegerValue(IntParamsIndexes::PARAM_UAVCAN_NODE_ID);
Expand All @@ -25,12 +25,12 @@ void application_entry_point() {
uavcanSetNodeName(node_name);

LedPeriphery::reset();

uavcanInitApplication(node_id);

CircuitStatusModule& status_module = CircuitStatusModule::get_instance();
LedColor color = LedColor::BLUE_COLOR;

if (!status_module.instance_initialized) {
color = LedColor::RED_COLOR;
}
Expand Down
8 changes: 4 additions & 4 deletions Src/dronecan_application/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
#ifndef SRC_LOGGER_HPP_
#define SRC_LOGGER_HPP_

#include <cstdio>
#include "main.h"
#include "uavcan/protocol/debug/LogMessage.h"
#include "logging.h"
#include "main.h"
#include <cstdio>

class Logger {
public:
Logger(const char* source);
explicit Logger(const char* source);
/**
* @brief Optionally init source and len fields if the source is provided
* It can be a brief task/module name or something that can't be changed later.
*/

int8_t init(const char* source);

/**
Expand Down
20 changes: 8 additions & 12 deletions Src/dronecan_application/modules/CircuitStatusModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CircuitStatusModule& CircuitStatusModule::get_instance() {
logger.log_debug("ADC init error");
} else {
instance_initialized = true;
};
}
}
return instance;
}
Expand All @@ -33,28 +33,24 @@ void CircuitStatusModule::spin_once() {
circuit_status.error_flags = ERROR_FLAG_OVERVOLTAGE;
} else if (circuit_status.current > 1.05) {
circuit_status.error_flags = ERROR_FLAG_OVERCURRENT;
} else if (publish_error) {
logger.log_debug("pub");
}

if (HAL_GetTick() > next_temp_pub_ms) {
temperature_status.temperature = CircuitPeriphery::temperature();
publish_error = dronecan_equipment_temperature_publish(&temperature_status, &temperature_transfer_id);
temperature_transfer_id ++;

dronecan_equipment_temperature_publish(&temperature_status, &temperature_transfer_id);
temperature_transfer_id++;
next_temp_pub_ms += 1000;
}

if (HAL_GetTick() > next_status_pub_ms) {

if (HAL_GetTick() > next_status_pub_ms) {
circuit_status.voltage = CircuitPeriphery::voltage_vin();
circuit_status.current = CircuitPeriphery::current();

publish_error = dronecan_equipment_circuit_status_publish(&circuit_status, &circuit_status_transfer_id);
circuit_status_transfer_id ++;
dronecan_equipment_circuit_status_publish(&circuit_status, &circuit_status_transfer_id);
circuit_status_transfer_id++;
next_status_pub_ms += 1000;

}

circuit_status.error_flags = ERROR_FLAG_CLEAR;
}
14 changes: 6 additions & 8 deletions Src/dronecan_application/modules/CircuitStatusModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Distributed under the terms of the GPL v3 license, available in the file LICENSE.
***/

#ifndef SRC_MODULE_CIRCUIT_STATUS_HPP_
#define SRC_MODULE_CIRCUIT_STATUS_HPP_
#ifndef SRC_MODULES_CIRCUIT_STATUS_HPP_
#define SRC_MODULES_CIRCUIT_STATUS_HPP_

#include "periphery/led/led.hpp"
#include "uavcan/equipment/temperature/Temperature.h"
Expand All @@ -24,19 +24,17 @@ class CircuitStatusModule {

CircuitStatus_t circuit_status = {};
Temperature_t temperature_status = {};

static Logger logger;

CircuitStatusModule(){};
CircuitStatusModule(){}

uint8_t circuit_status_transfer_id = 0;
uint8_t temperature_transfer_id = 0;

int8_t publish_error = 0;

int8_t init();
CircuitStatusModule(CircuitStatusModule &other) = delete;
CircuitStatusModule(const CircuitStatusModule &other) = delete;
void operator=(const CircuitStatusModule &) = delete;
};

#endif //SRC_MODULE_CIRCUIT_STATUS_HPP_
#endif // SRC_MODULES_CIRCUIT_STATUS_HPP_

0 comments on commit d6ddac4

Please sign in to comment.