Skip to content

Commit

Permalink
protobuf: updated packages
Browse files Browse the repository at this point in the history
protoc generates files once and for all

Signed-off-by: Cyril Fougeray <[email protected]>
  • Loading branch information
fouge committed Oct 21, 2024
1 parent bf75140 commit 3022e45
Show file tree
Hide file tree
Showing 52 changed files with 1,324 additions and 1,150 deletions.
4 changes: 2 additions & 2 deletions lib/dfu/include/dfu.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#include "bootutil/image.h"
#include "utils.h"
#include <mcu_messaging_common.pb.h>
#include <mcu.pb.h>
#include <stdbool.h>

#define DFU_BLOCK_SIZE_MAX \
STRUCT_MEMBER_ARRAY_SIZE(FirmwareUpdateData, image_block.bytes)
STRUCT_MEMBER_ARRAY_SIZE(orb_mcu_FirmwareUpdateData, image_block.bytes)

#if DT_NODE_HAS_COMPAT(DT_GPARENT(DT_ALIAS(secondary_slot)), jedec_spi_nor)
#include "flash/spi_nor.h"
Expand Down
7 changes: 4 additions & 3 deletions lib/logs_can/log_backend_can.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "log_backend_can.h"
#include "mcu_messaging_common.pb.h"
#include "common.pb.h"
#include "mcu.pb.h"
#include "orb_logs.h"
#include <zephyr/logging/log_backend.h>
LOG_MODULE_REGISTER(log_can, CONFIG_LOGS_CAN_LOG_LEVEL);

static int panic_count = 0;

// Max log string length per message, without NULL termination character
#define LOG_MAX_CHAR_COUNT (sizeof(Log) - 1)
#define LOG_MAX_CHAR_COUNT (sizeof(orb_mcu_Log) - 1)

static void (*print_log)(const char *log, size_t size, bool blocking) = NULL;

Expand Down Expand Up @@ -37,7 +38,7 @@ can_message_out(uint8_t *data, size_t length, void *ctx)
// Copy log into log_output_buf which has the same size as the Log message
// We define a log_output with `sizeof(Log) - 1` to keep room for the NULL
// termination character
static uint8_t log_output_buf[sizeof(Log)];
static uint8_t log_output_buf[sizeof(orb_mcu_Log)];
LOG_OUTPUT_DEFINE(log_output_can, can_message_out, log_output_buf,
LOG_MAX_CHAR_COUNT);

Expand Down
13 changes: 8 additions & 5 deletions main_board/src/gnss/gnss.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "gnss.h"
#include "mcu_messaging_main.pb.h"
#include "mcu.pb.h"
#include "orb_logs.h"
#include "utils.h"
#include <app_assert.h>
Expand Down Expand Up @@ -153,7 +153,7 @@ static int
send_nmea_message(const char *nmea_str)
{
static uint32_t counter = 0;
static GNSSDataPartial msg;
static orb_mcu_main_GNSSDataPartial msg;
int ret;

#if CONFIG_TEST_GNSS
Expand All @@ -178,12 +178,14 @@ send_nmea_message(const char *nmea_str)
msg.nmea_part[min] = '\0';
msg.counter = counter;

ret = publish_new(&msg, sizeof(msg), McuToJetson_gnss_partial_tag,
ret = publish_new(&msg, sizeof(msg),
orb_mcu_main_McuToJetson_gnss_partial_tag,
CONFIG_CAN_ADDRESS_DEFAULT_REMOTE);
if (ret == RET_SUCCESS) {
strncpy(msg.nmea_part, nmea_str + min, sizeof msg.nmea_part - 1);
msg.counter = counter + 1;
ret = publish_new(&msg, sizeof(msg), McuToJetson_gnss_partial_tag,
ret = publish_new(&msg, sizeof(msg),
orb_mcu_main_McuToJetson_gnss_partial_tag,
CONFIG_CAN_ADDRESS_DEFAULT_REMOTE);
}

Expand All @@ -203,7 +205,8 @@ gnss_thread_entry_point()
char ch;
static char msg[NMEA_MAX_SIZE + 1];

BUILD_ASSERT(sizeof msg <= STRUCT_MEMBER_ARRAY_SIZE(GNSSData, nmea),
BUILD_ASSERT(sizeof msg <=
STRUCT_MEMBER_ARRAY_SIZE(orb_mcu_main_GNSSData, nmea),
"msg must be small enough to fit into protobuf message");

for (;;) {
Expand Down
42 changes: 23 additions & 19 deletions main_board/src/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#if defined(CONFIG_BOARD_PEARL_MAIN)
#include "gnss/gnss.h"
#endif
#include "mcu.pb.h"
#include "optics/optics.h"
#include "orb_logs.h"
#include "power/battery/battery.h"
Expand Down Expand Up @@ -57,7 +58,8 @@ static void
ir_camera_test_reset(void *fixture)
{
ARG_UNUSED(fixture);
ir_camera_system_enable_leds(InfraredLEDs_Wavelength_WAVELENGTH_NONE);
ir_camera_system_enable_leds(
orb_mcu_main_InfraredLEDs_Wavelength_WAVELENGTH_NONE);
ir_camera_system_set_fps(0);
ir_camera_system_set_on_time_us(0);
}
Expand Down Expand Up @@ -95,17 +97,18 @@ app_assert_cb(fatal_error_info_t *err_info)
{
if (jetson_up_and_running) {
// fatal error, try to warn Jetson
static McuMessage fatal_error = {
.which_message = McuMessage_m_message_tag,
.message.m_message.which_payload = McuToJetson_fatal_error_tag,
static orb_mcu_McuMessage fatal_error = {
.which_message = orb_mcu_McuMessage_m_message_tag,
.message.m_message.which_payload =
orb_mcu_main_McuToJetson_fatal_error_tag,
.message.m_message.payload.fatal_error.reason =
FatalError_FatalReason_FATAL_ASSERT_HARD,
orb_mcu_FatalError_FatalReason_FATAL_ASSERT_HARD,
};

static uint8_t buffer[CAN_FRAME_MAX_SIZE];
pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
bool encoded = pb_encode_ex(&stream, McuMessage_fields, &fatal_error,
PB_ENCODE_DELIMITED);
bool encoded = pb_encode_ex(&stream, orb_mcu_McuMessage_fields,
&fatal_error, PB_ENCODE_DELIMITED);

can_message_t to_send = {.destination =
CONFIG_CAN_ADDRESS_DEFAULT_REMOTE,
Expand All @@ -126,35 +129,36 @@ send_reset_reason(void)
{
uint32_t reset_reason = fatal_get_status_register();
if (reset_reason != 0) {
FatalError fatal_error = {0};
orb_mcu_FatalError fatal_error = {0};
if (IS_WATCHDOG(reset_reason)) {
fatal_error.reason = FatalError_FatalReason_FATAL_WATCHDOG;
fatal_error.reason = orb_mcu_FatalError_FatalReason_FATAL_WATCHDOG;
publish_new(&fatal_error, sizeof(fatal_error),
McuToJetson_fatal_error_tag,
orb_mcu_main_McuToJetson_fatal_error_tag,
CONFIG_CAN_ADDRESS_DEFAULT_REMOTE);
}
if (IS_SOFTWARE(reset_reason)) {
fatal_error.reason = FatalError_FatalReason_FATAL_SOFTWARE_UNKNOWN;
fatal_error.reason =
orb_mcu_FatalError_FatalReason_FATAL_SOFTWARE_UNKNOWN;
publish_new(&fatal_error, sizeof(fatal_error),
McuToJetson_fatal_error_tag,
orb_mcu_main_McuToJetson_fatal_error_tag,
CONFIG_CAN_ADDRESS_DEFAULT_REMOTE);
}
if (IS_BOR(reset_reason)) {
fatal_error.reason = FatalError_FatalReason_FATAL_BROWNOUT;
fatal_error.reason = orb_mcu_FatalError_FatalReason_FATAL_BROWNOUT;
publish_new(&fatal_error, sizeof(fatal_error),
McuToJetson_fatal_error_tag,
orb_mcu_main_McuToJetson_fatal_error_tag,
CONFIG_CAN_ADDRESS_DEFAULT_REMOTE);
}
if (IS_PIN(reset_reason)) {
fatal_error.reason = FatalError_FatalReason_FATAL_PIN_RESET;
fatal_error.reason = orb_mcu_FatalError_FatalReason_FATAL_PIN_RESET;
publish_new(&fatal_error, sizeof(fatal_error),
McuToJetson_fatal_error_tag,
orb_mcu_main_McuToJetson_fatal_error_tag,
CONFIG_CAN_ADDRESS_DEFAULT_REMOTE);
}
if (IS_LOW_POWER(reset_reason)) {
fatal_error.reason = FatalError_FatalReason_FATAL_LOW_POWER;
fatal_error.reason = orb_mcu_FatalError_FatalReason_FATAL_LOW_POWER;
publish_new(&fatal_error, sizeof(fatal_error),
McuToJetson_fatal_error_tag,
orb_mcu_main_McuToJetson_fatal_error_tag,
CONFIG_CAN_ADDRESS_DEFAULT_REMOTE);
}
}
Expand Down Expand Up @@ -219,7 +223,7 @@ initialize(void)
err_code = version_init();
ASSERT_SOFT(err_code);

Hardware hw = {.version = version_get_hardware_rev()};
orb_mcu_Hardware hw = {.version = version_get_hardware_rev()};
LOG_INF("Hardware version: %u", hw.version);

// voltage_measurement module is used by battery and boot -> must be
Expand Down
6 changes: 3 additions & 3 deletions main_board/src/optics/1d_tof/tof_1d.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "tof_1d.h"
#include "app_config.h"
#include "mcu_messaging_main.pb.h"
#include "mcu.pb.h"
#include "orb_logs.h"
#include "pubsub/pubsub.h"
#include <errors.h>
Expand Down Expand Up @@ -56,7 +56,7 @@ tof_1d_thread()
{
int ret;
struct sensor_value distance_value;
ToF_1D tof;
orb_mcu_main_ToF_1D tof;
uint32_t count = 0;

uint32_t tick = 0;
Expand Down Expand Up @@ -100,7 +100,7 @@ tof_1d_thread()
if (count % (DISTANCE_PUBLISH_PERIOD_MS / FETCH_PERIOD_MS) == 0) {
LOG_INF("Distance in front: %umm", tof.distance_mm);

publish_new(&tof, sizeof(tof), McuToJetson_tof_1d_tag,
publish_new(&tof, sizeof(tof), orb_mcu_main_McuToJetson_tof_1d_tag,
CONFIG_CAN_ADDRESS_DEFAULT_REMOTE);
}

Expand Down
37 changes: 22 additions & 15 deletions main_board/src/optics/ir_camera_system/ir_camera_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ LOG_MODULE_REGISTER(ir_camera_system, CONFIG_IR_CAMERA_SYSTEM_LOG_LEVEL);
STATIC_OR_EXTERN atomic_t focus_sweep_in_progress;
STATIC_OR_EXTERN atomic_t mirror_sweep_in_progress;
STATIC_OR_EXTERN bool ir_camera_system_initialized;
STATIC_OR_EXTERN InfraredLEDs_Wavelength enabled_led_wavelength =
InfraredLEDs_Wavelength_WAVELENGTH_NONE;
STATIC_OR_EXTERN orb_mcu_main_InfraredLEDs_Wavelength enabled_led_wavelength =
orb_mcu_main_InfraredLEDs_Wavelength_WAVELENGTH_NONE;

#define MAKE_CAMERA_ENABLE_FUNC(camera_name) \
ret_code_t ir_camera_system_enable_##camera_name##_camera(void) \
Expand Down Expand Up @@ -148,7 +148,7 @@ MAKE_CAMERA_ENABLE_DISABLE_GET_FUNCTIONS(ir_face)
MAKE_CAMERA_ENABLE_DISABLE_GET_FUNCTIONS(2d_tof)

ret_code_t
ir_camera_system_enable_leds(InfraredLEDs_Wavelength wavelength)
ir_camera_system_enable_leds(orb_mcu_main_InfraredLEDs_Wavelength wavelength)
{
ret_code_t ret;

Expand All @@ -158,17 +158,24 @@ ir_camera_system_enable_leds(InfraredLEDs_Wavelength wavelength)
if (
#if defined(CONFIG_BOARD_PEARL_MAIN)
wavelength ==
InfraredLEDs_Wavelength_WAVELENGTH_740NM || // 740nm is
// deprecated
wavelength == InfraredLEDs_Wavelength_WAVELENGTH_850NM_CENTER ||
wavelength == InfraredLEDs_Wavelength_WAVELENGTH_850NM_SIDE ||
wavelength == InfraredLEDs_Wavelength_WAVELENGTH_940NM_SINGLE
orb_mcu_main_InfraredLEDs_Wavelength_WAVELENGTH_740NM || // 740nm
// is
// deprecated
wavelength ==
orb_mcu_main_InfraredLEDs_Wavelength_WAVELENGTH_850NM_CENTER ||
wavelength ==
orb_mcu_main_InfraredLEDs_Wavelength_WAVELENGTH_850NM_SIDE ||
wavelength ==
orb_mcu_main_InfraredLEDs_Wavelength_WAVELENGTH_940NM_SINGLE
#elif defined(CONFIG_BOARD_DIAMOND_MAIN)
wavelength ==
InfraredLEDs_Wavelength_WAVELENGTH_740NM || // 740nm is
// deprecated
wavelength == InfraredLEDs_Wavelength_WAVELENGTH_850NM_RIGHT ||
wavelength == InfraredLEDs_Wavelength_WAVELENGTH_850NM_LEFT
orb_mcu_main_InfraredLEDs_Wavelength_WAVELENGTH_740NM || // 740nm
// is
// deprecated
wavelength ==
orb_mcu_main_InfraredLEDs_Wavelength_WAVELENGTH_850NM_RIGHT ||
wavelength ==
orb_mcu_main_InfraredLEDs_Wavelength_WAVELENGTH_850NM_LEFT
#else
false
#endif
Expand All @@ -184,7 +191,7 @@ ir_camera_system_enable_leds(InfraredLEDs_Wavelength wavelength)
return ret;
}

InfraredLEDs_Wavelength
orb_mcu_main_InfraredLEDs_Wavelength
ir_camera_system_get_enabled_leds(void)
{
return enabled_led_wavelength;
Expand Down Expand Up @@ -241,7 +248,7 @@ ir_camera_system_set_on_time_us(uint16_t on_time_us)

ret_code_t
ir_camera_system_set_polynomial_coefficients_for_focus_sweep(
IREyeCameraFocusSweepValuesPolynomial poly)
orb_mcu_main_IREyeCameraFocusSweepValuesPolynomial poly)
{
ret_code_t ret;

Expand Down Expand Up @@ -302,7 +309,7 @@ ir_camera_system_perform_focus_sweep(void)

ret_code_t
ir_camera_system_set_polynomial_coefficients_for_mirror_sweep(
IREyeCameraMirrorSweepValuesPolynomial poly)
orb_mcu_main_IREyeCameraMirrorSweepValuesPolynomial poly)
{
ret_code_t ret;

Expand Down
15 changes: 8 additions & 7 deletions main_board/src/optics/ir_camera_system/ir_camera_system.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#pragma once

#include <errors.h>
#include <mcu_messaging_main.pb.h>
#include <mcu.pb.h>
#include <zephyr/sys/util.h>

#define MAX_NUMBER_OF_FOCUS_VALUES \
(STRUCT_MEMBER_SIZE_BYTES(IREyeCameraFocusSweepLensValues, focus_values) / \
(STRUCT_MEMBER_SIZE_BYTES(orb_mcu_main_IREyeCameraFocusSweepLensValues, \
focus_values) / \
(sizeof(uint16_t)))

#ifdef CONFIG_ZTEST
Expand Down Expand Up @@ -120,13 +121,13 @@ ir_camera_system_2d_tof_camera_is_enabled(void);
* @retval RET_ERROR_BUSY focus sweep or mirror sweep in progress
*/
ret_code_t
ir_camera_system_enable_leds(InfraredLEDs_Wavelength wavelength);
ir_camera_system_enable_leds(orb_mcu_main_InfraredLEDs_Wavelength wavelength);

/**
* @brief Get enabled LED wavelengths
* @return InfraredLEDs_Wavelength
* @return orb_mcu_main_InfraredLEDs_Wavelength
*/
InfraredLEDs_Wavelength
orb_mcu_main_InfraredLEDs_Wavelength
ir_camera_system_get_enabled_leds(void);

/**
Expand Down Expand Up @@ -202,7 +203,7 @@ ir_camera_system_set_focus_values_for_focus_sweep(int16_t *focus_values,
*/
ret_code_t
ir_camera_system_set_polynomial_coefficients_for_focus_sweep(
IREyeCameraFocusSweepValuesPolynomial poly);
orb_mcu_main_IREyeCameraFocusSweepValuesPolynomial poly);

/**
* Perform a focus sweep using the IR eye camera. Using this function has
Expand Down Expand Up @@ -237,7 +238,7 @@ progress
*/
ret_code_t
ir_camera_system_set_polynomial_coefficients_for_mirror_sweep(
IREyeCameraMirrorSweepValuesPolynomial poly);
orb_mcu_main_IREyeCameraMirrorSweepValuesPolynomial poly);

/**
* Perform a mirror sweep using the IR eye camera. Using this function has
Expand Down
Loading

0 comments on commit 3022e45

Please sign in to comment.