50 for (
int i = 0; i <
msg->length; i++) {
51 buf[4+i] =
msg->data[i];
53 buf[
msg->length+4] =
msg->cksum[0];
54 buf[
msg->length+5] =
msg->cksum[1];
68 if (
msg->length != 9) {
79 memcpy(&vbat, &
msg->data[1],
sizeof(
float));
105 if (c->channel == 0) {
109 memset(&c->
data[2], 0, 3);
113 }
else if (cmd == 1) {
114 memset(&c->
data[1], 0, 7);
119 else if (c->channel == 1) {
125 else if (c->channel == 2) {
130 if (c->channel == 0) {
131 int cmd = c->
data[0];
141 if (c->channel == 0) {
143 memset(&c->
data[2], 0, 10);
147 else if (c->channel == 1) {
155 if (c->channel == 0) {
158 else if (c->channel == 1) {
161 strcpy((
char *)c->
data,
"Bitcraze PPRZ");
203 if (available > data_size) {
290 int slots =
s->tx_extract_idx -
s->tx_insert_idx;
308 while (buf_rem > 0) {
314 memcpy(&c->
data[c->
size -
sizeof(c->header)], &data[len - buf_rem], data_size);
315 c->
size += data_size;
316 buf_rem -= data_size;
321 if (tmp ==
s->tx_extract_idx) {
328 memcpy(c->
data, &data[len - buf_rem], data_size);
329 c->
size =
sizeof(c->header) + data_size;
330 buf_rem -= data_size;
331 s->tx_insert_idx = tmp;
350 uint8_t ret =
s->rx_buf[
s->rx_extract_idx];
357 int available =
s->rx_insert_idx -
s->rx_extract_idx;
#define CRTP_PORT_PPRZLINK
#define CRTP_PORT_COMMANDER
uint8_t data[CRTP_MAX_DATA_SIZE]
#define CRTP_MAX_DATA_SIZE
if(GpsFixValid() &&e_identification_started)
struct Electrical electrical
Interface for electrical status: supply voltage, current, battery status, etc.
float vsupply
supply voltage in V
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
arch independent LED (Light Emitting Diodes) API
int uart_char_available(struct uart_periph *p)
Check UART for available chars in receive buffer.
uint8_t uart_getch(struct uart_periph *p)
static int split(microrl_t *pThis, int limit)
Utility functions and macros to abstract some RTOS functionalities such as mutexes.
#define PPRZ_MUTEX_LOCK(_mtx)
#define PPRZ_MUTEX_UNLOCK(_mtx)
#define PPRZ_MUTEX_INIT(_mtx)
bool syslink_parse_char(syslink_parse_state *state, uint8_t c, syslink_message_t *msg)
Parse one byte.
void syslink_compute_cksum(syslink_message_t *msg)
Compute syslink checksum.
void syslink_parse_init(syslink_parse_state *state)
Init syslink parser.
#define SYSLINK_RADIO_RSSI
#define SYSLINK_RADIO_DATARATE
#define SYSLINK_RADIO_CHANNEL
#define SYSLINK_PM_ONOFF_SWITCHOFF
#define SYSLINK_RADIO_RAW
#define SYSLINK_RADIO_ADDRESS
#define SYSLINK_PM_BATTERY_STATE
static void handle_radio(syslink_message_t *msg)
static uint8_t syslink_getch(struct syslink_dl *s)
void syslink_dl_event(void)
Datalink event.
struct syslink_dl syslink
static void syslink_put_buffer(struct syslink_dl *s, long fd UNUSED, const uint8_t *data, uint16_t len)
PPRZ_MUTEX(syslink_tx_mtx)
Protect syslink TX with Mutex when using RTOS.
void syslink_dl_periodic(void)
Periodic function.
static void handle_battery(syslink_message_t *msg)
Handle battery message.
static void syslink_send_message(struct syslink_dl *s UNUSED, long fd UNUSED)
static void handle_new_msg(syslink_message_t *msg)
New RX message.
static int syslink_char_available(struct syslink_dl *s)
void syslink_dl_init(void)
Init function.
static int syslink_check_free_space(struct syslink_dl *s, long *fd UNUSED, uint16_t len)
Implementation of syslink as generic device.
static void syslink_put_byte(struct syslink_dl *s, long fd, const uint8_t b)
static void handle_raw(syslink_message_t *msg)
Handle raw datalink.
static void handle_raw_other(syslink_message_t *msg)
Handle various raw messages.
static void send_message(syslink_message_t *msg)
Send a syslink message.
Syslink protocol handling and functionalities.
struct link_device device
syslink_message_t msg_rx
last received syslink message
uint8_t tx_extract_idx
tx extract index
bool charging
battery charging
syslink_parse_state state
syslink parser state
uint8_t rx_insert_idx
rx insert index
uint8_t rx_buf[SYSLINK_RX_BUF_LEN]
received pprzlink bytes from syslink/crtp
#define SYSLINK_RX_BUF_LEN
crtp_message_t msg_tx[CRTP_BUF_LEN]
queued crtp packets to be send
uint8_t tx_insert_idx
tx insert index
void WEAK uart_put_buffer(struct uart_periph *p, long fd, const uint8_t *data, uint16_t len)
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.