Galaxis Codebase  1.0.0
Team Galaxis software stack for the Carolo Cup 2023 - ROS2 based software
Packets.hpp File Reference
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "quadrature_counter.h"
#include <util/firmware_settings.h>
Include dependency graph for Packets.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PACKET_ID_COMPUTER   (0U)
 
#define PACKET_ID_SETTINGS   (1U)
 

Typedefs

typedef uint8_t PacketId_t
 

Functions

struct __attribute__ ((packed))
 

Variables

 SettingsPacket
 
union {
   char   wrong_offset_preamble [(offsetof(SettingsPacket,
      preamble)==0) ? 1 :-1]
 
   char   wrong_offset_packet_id [(offsetof(SettingsPacket,
      packet_id)==8) ? 1 :-1]
 
   char   wrong_offset_firmware [(offsetof(SettingsPacket,
      firmware)==8+1) ? 1 :-1]
 
   char   wrong_offset_crc [(offsetof(SettingsPacket, crc)==8+1+32+3) ? 1 :-1]
 
   char   wrong_sizeof_packet [((sizeof(SettingsPacket) >
       4) &&(sizeof(SettingsPacket)
      % sizeof(uint32_t)==0)) ? 1 :-1]
 
} SettingsPacketTest
 
 ComputerPacket
 
union {
   char   wrong_offset_preamble [(offsetof(ComputerPacket,
      preamble)==0) ? 1 :-1]
 
   char   wrong_offset_packet_id [(offsetof(ComputerPacket,
      packet_id)==8) ? 1 :-1]
 
   char   wrong_offset_motor_erpm [(offsetof(ComputerPacket,
      motor_erpm)==8+1) ? 1 :-1]
 
   char   wrong_offset_motor_current [(offsetof(ComputerPacket,
      motor_current)==8+1+4) ? 1 :-1]
 
   char   wrong_offset_servo_front [(offsetof(ComputerPacket,
      servo_front)==8+1+4+4) ? 1 :-1]
 
   char   wrong_offset_servo_rear [(offsetof(ComputerPacket,
      servo_rear)==8+1+4+4+1) ? 1 :-1]
 
   char   wrong_offset_lightState [(offsetof(ComputerPacket,
      lightState)==8+1+4+4+1+1) ? 1 :-1]
 
   char   wrong_offset_brake [(offsetof(ComputerPacket,
      brake)==8+1+4+4+1+1+2) ? 1 :-1]
 
   char   wrong_offset_padding [(offsetof(ComputerPacket,
      padding)==8+1+4+4+1+1+2+1) ? 1 :-1]
 
   char   wrong_offset_crc [(offsetof(ComputerPacket, crc)==8+1+4+4+1+1+2+1+2) ? 1 :-1]
 
   char   wrong_sizeof_packet [((sizeof(ComputerPacket) >
       4) &&(sizeof(ComputerPacket)
      % sizeof(uint32_t)==0)) ? 1 :-1]
 
} ComputerPacketTest
 
 EcuPacket
 
union {
   char   wrong_offset_preamble [(offsetof(EcuPacket, preamble)==0) ? 1 :-1]
 
   char   wrong_offset_rc_active [(offsetof(EcuPacket,
      rc_active)==8) ? 1 :-1]
 
   char   wrong_offset_motor_erpm [(offsetof(EcuPacket,
      motor_erpm)==8+1) ? 1 :-1]
 
   char   wrong_offset_tof_right [(offsetof(EcuPacket,
      tof_right)==8+1+4) ? 1 :-1]
 
   char   wrong_offset_tof_rear [(offsetof(EcuPacket, tof_rear)==8+1+4+2) ? 1 :-1]
 
   char   wrong_offset_orientation [(offsetof(EcuPacket,
      orientation)==8+1+4+4) ? 1 :-1]
 
   char   wrong_offset_linear_acceleration_x [(offsetof(EcuPacket,
      linear_acceleration_x)==8+1+4+4+4) ? 1 :-1]
 
   char   wrong_offset_linear_acceleration_y [(offsetof(EcuPacket,
      linear_acceleration_y)==8+1+4+4+4+4) ? 1 :-1]
 
   char   wrong_offset_linear_acceleration_z [(offsetof(EcuPacket,
      linear_acceleration_z)==8+1+4+4+4+4+4) ? 1 :-1]
 
   char   wrong_offset_gyro_x [(offsetof(EcuPacket, gyro_x)==8+1+4+4+4+12) ? 1 :-1]
 
   char   wrong_offset_buttonState [(offsetof(EcuPacket,
      buttonState)==8+1+4+4+4+12+4) ? 1 :-1]
 
   char   wrong_offset_batteryLevel [(offsetof(EcuPacket,
      batteryLevel)==8+1+4+4+4+12+4+1) ? 1 :-1]
 
   char   wrong_offset_batteryCellLevel [(offsetof(EcuPacket,
      batteryCellLevel)==8+1+4+4+4+12+4+1+2) ? 1 :-1]
 
   char   wrong_offset_applied_servo_front [(offsetof(EcuPacket,
      applied_servo_front)==8+1+4+4+4+12+4+3+6) ? 1 :-1]
 
   char   wrong_offset_applied_servo_rear [(offsetof(EcuPacket,
      applied_servo_rear)==8+1+4+4+4+12+4+3+6+1) ? 1 :-1]
 
   char   wrong_offset_motor_duty_cycle [(offsetof(EcuPacket,
      motor_duty_cycle)==8+1+4+4+4+12+4+1+2+6+2) ? 1 :-1]
 
   char   wrong_offset_applied_motor_current [(offsetof(EcuPacket,
      applied_motor_current)==8+1+4+4+4+12+4+1+2+6+2+4) ? 1 :-1]
 
   char   wrong_offset_applied_motor_erpm [(offsetof(EcuPacket,
      applied_motor_erpm)==8+1+4+4+4+12+4+1+2+6+2+4+4) ? 1 :-1]
 
   char   wrong_offset_applied_motor_brake [(offsetof(EcuPacket,
      applied_motor_brake)==8+1+4+4+4+12+4+1+2+6+2+4+4+4) ? 1 :-1]
 
   char   wrong_offset_padding [(offsetof(EcuPacket, padding)==8+1+4+4+4+12+4+1+2+6+2+4+4+4+1) ? 1 :-1]
 
   char   wrong_offset_crc [(offsetof(EcuPacket, crc)==8+1+4+4+4+12+4+1+2+6+2+4+4+4+4) ? 1 :-1]
 
   char   wrong_sizeof_packet [((sizeof(EcuPacket) >
       4) &&(sizeof(EcuPacket)
      % sizeof(uint32_t)==0)) ? 1 :-1]
 
   char   wrong_sizeof_float [(sizeof(float)==4) ? 1 :-1]
 
} EcuPacketTest
 

Macro Definition Documentation

◆ PACKET_ID_COMPUTER

#define PACKET_ID_COMPUTER   (0U)

Definition at line 12 of file Packets.hpp.

◆ PACKET_ID_SETTINGS

#define PACKET_ID_SETTINGS   (1U)

Definition at line 13 of file Packets.hpp.

Typedef Documentation

◆ PacketId_t

typedef uint8_t PacketId_t

Definition at line 11 of file Packets.hpp.

Function Documentation

◆ __attribute__()

struct __attribute__ ( (packed)  )

Speed value for the motor

This variable usually would be used for system identification

The motor current in Ampere

Servo values are between [-100,100]

Stores the states for car lights and scenario settings

There are 2 bits for the following states The order is the following: Bits: [13,12|11,10|9,8|7,6|5,4|3,2|1,0] [scenario3,scenario2,scenario1,brakes,blinkerRight,blinkerLeft,headlight]

Enable/Disable Brakes (1 for enable, 0 for disable, otherwise undefined)

the values of the quadrature counters

applied value at front servo

is in range of [-100,100]

applied value at rear servo

is in range of [-100,100]

The current duty Cycle for the motor

The current that is really applied to the motor.

Can come from the remote control or the computer settings depending on which one is active

the applied ERPM which overrides the motor current if != 0

boolean value which is 1 if brakes got applied

Definition at line 15 of file Packets.hpp.

15  {
16  uint64_t preamble;
17 
18  /* should be PACKET_ID_SETTINGS */
19  PacketId_t packet_id;
20 
21  /* 24 bytes */
22  FirmwareSetup_t firmware;
23 
24  uint8_t padding[3];
25 
26  /*
27  * CRC value for the packet that is transferred from the
28  * computer to the microcontroller
29  */
30  uint32_t crc;

References FirmwareSetup_t.

Variable Documentation

◆ ComputerPacket

ComputerPacket

◆ ComputerPacketTest

union { ... } ComputerPacketTest

◆ EcuPacket

EcuPacket

Definition at line 242 of file Packets.hpp.

Referenced by ECUHandler::ReceiveHandler().

◆ EcuPacketTest

union { ... } EcuPacketTest

◆ SettingsPacket

◆ SettingsPacketTest

union { ... } SettingsPacketTest

◆ wrong_offset_applied_motor_brake

char wrong_offset_applied_motor_brake[(offsetof(EcuPacket, applied_motor_brake)==8+1+4+4+4+12+4+1+2+6+2+4+4+4) ? 1 :-1]

Definition at line 281 of file Packets.hpp.

◆ wrong_offset_applied_motor_current

char wrong_offset_applied_motor_current[(offsetof(EcuPacket, applied_motor_current)==8+1+4+4+4+12+4+1+2+6+2+4) ? 1 :-1]

Definition at line 277 of file Packets.hpp.

◆ wrong_offset_applied_motor_erpm

char wrong_offset_applied_motor_erpm[(offsetof(EcuPacket, applied_motor_erpm)==8+1+4+4+4+12+4+1+2+6+2+4+4) ? 1 :-1]

Definition at line 279 of file Packets.hpp.

◆ wrong_offset_applied_servo_front

char wrong_offset_applied_servo_front[(offsetof(EcuPacket, applied_servo_front)==8+1+4+4+4+12+4+3+6) ? 1 :-1]

Definition at line 272 of file Packets.hpp.

◆ wrong_offset_applied_servo_rear

char wrong_offset_applied_servo_rear[(offsetof(EcuPacket, applied_servo_rear)==8+1+4+4+4+12+4+3+6+1) ? 1 :-1]

Definition at line 273 of file Packets.hpp.

◆ wrong_offset_batteryCellLevel

char wrong_offset_batteryCellLevel[(offsetof(EcuPacket, batteryCellLevel)==8+1+4+4+4+12+4+1+2) ? 1 :-1]

Definition at line 270 of file Packets.hpp.

◆ wrong_offset_batteryLevel

char wrong_offset_batteryLevel[(offsetof(EcuPacket, batteryLevel)==8+1+4+4+4+12+4+1) ? 1 :-1]

Definition at line 269 of file Packets.hpp.

◆ wrong_offset_brake

char wrong_offset_brake[(offsetof(ComputerPacket, brake)==8+1+4+4+1+1+2) ? 1 :-1]

Definition at line 125 of file Packets.hpp.

◆ wrong_offset_buttonState

char wrong_offset_buttonState[(offsetof(EcuPacket, buttonState)==8+1+4+4+4+12+4) ? 1 :-1]

Definition at line 267 of file Packets.hpp.

◆ wrong_offset_crc

char wrong_offset_crc[(offsetof(EcuPacket, crc)==8+1+4+4+4+12+4+1+2+6+2+4+4+4+4) ? 1 :-1]

Definition at line 46 of file Packets.hpp.

◆ wrong_offset_firmware

char wrong_offset_firmware[(offsetof(SettingsPacket, firmware)==8+1) ? 1 :-1]

Definition at line 44 of file Packets.hpp.

◆ wrong_offset_gyro_x

char wrong_offset_gyro_x[(offsetof(EcuPacket, gyro_x)==8+1+4+4+4+12) ? 1 :-1]

Definition at line 265 of file Packets.hpp.

◆ wrong_offset_lightState

char wrong_offset_lightState[(offsetof(ComputerPacket, lightState)==8+1+4+4+1+1) ? 1 :-1]

Definition at line 123 of file Packets.hpp.

◆ wrong_offset_linear_acceleration_x

char wrong_offset_linear_acceleration_x[(offsetof(EcuPacket, linear_acceleration_x)==8+1+4+4+4) ? 1 :-1]

Definition at line 261 of file Packets.hpp.

◆ wrong_offset_linear_acceleration_y

char wrong_offset_linear_acceleration_y[(offsetof(EcuPacket, linear_acceleration_y)==8+1+4+4+4+4) ? 1 :-1]

Definition at line 262 of file Packets.hpp.

◆ wrong_offset_linear_acceleration_z

char wrong_offset_linear_acceleration_z[(offsetof(EcuPacket, linear_acceleration_z)==8+1+4+4+4+4+4) ? 1 :-1]

Definition at line 263 of file Packets.hpp.

◆ wrong_offset_motor_current

char wrong_offset_motor_current[(offsetof(ComputerPacket, motor_current)==8+1+4) ? 1 :-1]

Definition at line 118 of file Packets.hpp.

◆ wrong_offset_motor_duty_cycle

char wrong_offset_motor_duty_cycle[(offsetof(EcuPacket, motor_duty_cycle)==8+1+4+4+4+12+4+1+2+6+2) ? 1 :-1]

Definition at line 275 of file Packets.hpp.

◆ wrong_offset_motor_erpm

char wrong_offset_motor_erpm[(offsetof(EcuPacket, motor_erpm)==8+1) ? 1 :-1]

Definition at line 117 of file Packets.hpp.

◆ wrong_offset_orientation

char wrong_offset_orientation[(offsetof(EcuPacket, orientation)==8+1+4+4) ? 1 :-1]

Definition at line 259 of file Packets.hpp.

◆ wrong_offset_packet_id

char wrong_offset_packet_id[(offsetof(ComputerPacket, packet_id)==8) ? 1 :-1]

Definition at line 42 of file Packets.hpp.

◆ wrong_offset_padding

char wrong_offset_padding[(offsetof(EcuPacket, padding)==8+1+4+4+4+12+4+1+2+6+2+4+4+4+1) ? 1 :-1]

Definition at line 127 of file Packets.hpp.

◆ wrong_offset_preamble

char wrong_offset_preamble[(offsetof(EcuPacket, preamble)==0) ? 1 :-1]

Definition at line 40 of file Packets.hpp.

◆ wrong_offset_rc_active

char wrong_offset_rc_active[(offsetof(EcuPacket, rc_active)==8) ? 1 :-1]

Definition at line 253 of file Packets.hpp.

◆ wrong_offset_servo_front

char wrong_offset_servo_front[(offsetof(ComputerPacket, servo_front)==8+1+4+4) ? 1 :-1]

Definition at line 120 of file Packets.hpp.

◆ wrong_offset_servo_rear

char wrong_offset_servo_rear[(offsetof(ComputerPacket, servo_rear)==8+1+4+4+1) ? 1 :-1]

Definition at line 121 of file Packets.hpp.

◆ wrong_offset_tof_rear

char wrong_offset_tof_rear[(offsetof(EcuPacket, tof_rear)==8+1+4+2) ? 1 :-1]

Definition at line 257 of file Packets.hpp.

◆ wrong_offset_tof_right

char wrong_offset_tof_right[(offsetof(EcuPacket, tof_right)==8+1+4) ? 1 :-1]

Definition at line 256 of file Packets.hpp.

◆ wrong_sizeof_float

char wrong_sizeof_float[(sizeof(float)==4) ? 1 :-1]

Definition at line 291 of file Packets.hpp.

◆ wrong_sizeof_packet

char wrong_sizeof_packet[((sizeof(EcuPacket) > 4) &&(sizeof(EcuPacket) % sizeof(uint32_t)==0)) ? 1 : -1]

Definition at line 52 of file Packets.hpp.

FirmwareSetup_t
FirmwareSetup_t
Definition: firmware_settings.h:33
PacketId_t
uint8_t PacketId_t
Definition: Packets.hpp:11
SettingsPacket
SettingsPacket
Definition: Packets.hpp:31