48 #define UWB_SERIAL_PORT (&((SERIAL_UART).device))
52 #define UWB_SERIAL_COMM_MAX_MESSAGE 20
53 #define UWB_SERIAL_COMM_END_MARKER 255
54 #define UWB_SERIAL_COMM_SPECIAL_BYTE 253
55 #define UWB_SERIAL_COMM_START_MARKER 254
56 #define UWB_SERIAL_COMM_NODE_STATE_SIZE 7
58 #define UWB_SERIAL_COMM_NUM_NODES 3
59 #define UWB_SERIAL_COMM_DIST_NUM_NODES UWB_SERIAL_COMM_NUM_NODES-1
63 #define UWB_SERIAL_COMM_RANGE 0
64 #define UWB_SERIAL_COMM_VX 1
65 #define UWB_SERIAL_COMM_VY 2
66 #define UWB_SERIAL_COMM_Z 3
67 #define UWB_SERIAL_COMM_AX 4
68 #define UWB_SERIAL_COMM_AY 5
69 #define UWB_SERIAL_COMM_YAWR 6
132 static uint8_t receive_buffer[4];
134 uint8_t data_received_count = 0;
135 uint8_t this_address = received_message[1];
136 uint8_t msg_from = received_message[2];
137 uint8_t msg_type = received_message[3];
138 uint8_t nodeIndex = msg_from - 1 - (
uint8_t)(this_address < msg_from);
139 for (
uint8_t i = 4; i < bytes_received - 1; i++) {
141 uint8_t var_byte = received_message[i];
144 var_byte = var_byte + received_message[i];
146 if (data_received_count <= 4) {
147 receive_buffer[data_received_count] = var_byte;
149 data_received_count++;
151 if (data_received_count == 4) {
153 memcpy(&tempfloat, &receive_buffer, 4);
166 uint8_t data_send_count = msg_size;
167 *data_total_send = 0;
168 for (
uint8_t i = 0; i < data_send_count; i++) {
171 (*data_total_send)++;
174 data_send_buffer[*data_total_send] =
send_data[i];
176 (*data_total_send)++;
187 static uint8_t data_total_send = 0;
191 memcpy(floatbyte, &data, 4);
197 for (
uint8_t i = 0; i < data_total_send; i++) {
241 static bool in_progress =
false;
249 (*bytes_received) = 0;
255 received_message[*bytes_received] = var_byte;
Main include for ABI (AirBorneInterface).
static void send_data(uint32_t stamp)
static void checkStatesUpdated(void)
This function checks if all the states of all the distant nodes have at least once been updated.
#define UWB_SERIAL_COMM_NODE_STATE_SIZE
#define UWB_SERIAL_COMM_VX
#define UWB_SERIAL_COMM_AY
#define UWB_SERIAL_COMM_MAX_MESSAGE
void decawave_anchorless_communication_periodic(void)
This function periodically sends state data over the serial (which is received by the arduino)
#define UWB_SERIAL_COMM_VY
static struct nodeState states[UWB_SERIAL_COMM_DIST_NUM_NODES]
bool state_updated[UWB_SERIAL_COMM_NODE_STATE_SIZE]
#define UWB_SERIAL_COMM_END_MARKER
void decawave_anchorless_communication_init(void)
Initialization functio.
struct link_device * external_device
#define UWB_SERIAL_COMM_YAWR
static void handleNewStateValue(uint8_t nodeIndex, uint8_t msg_type, float value)
Function that is called when over the serial a new state value from a remote node is received.
static void sendFloat(uint8_t msg_type, float data)
Function that will send a float over serial.
static void getSerialData(uint8_t *bytes_received)
Function for receiving serial data.
#define UWB_SERIAL_COMM_Z
static void decodeHighBytes(uint8_t bytes_received, uint8_t *received_message)
Function for decoding the high bytes of received serial data and saving the message.
void decawave_anchorless_communication_event(void)
Event function currently checks for serial data and whether an update of states is available for a di...
#define UWB_SERIAL_COMM_DIST_NUM_NODES
#define UWB_SERIAL_COMM_AX
#define UWB_SERIAL_COMM_RANGE
#define UWB_SERIAL_COMM_SPECIAL_BYTE
#define UWB_SERIAL_COMM_START_MARKER
static void encodeHighBytes(uint8_t *send_data, uint8_t msg_size, uint8_t *data_send_buffer, uint8_t *data_total_send)
Function that encodes the high bytes of the serial data to be sent.
static void setNodeStatesFalse(uint8_t index)
Helper function that sets the boolean that tells whether a remote drone has a new state update to fal...
static struct NedCoor_f * stateGetAccelNed_f(void)
Get acceleration in NED coordinates (float).
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
static struct FloatRates * stateGetBodyRates_f(void)
Get vehicle body angular rate (float).
static struct EnuCoor_f * stateGetSpeedEnu_f(void)
Get ground speed in local ENU coordinates (float).
Generic interface for radio control modules.
API to get/set the generic vehicle states.
Periodic telemetry system header (includes downlink utility and generated code).
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.