50 for (
int i = 0; i < msg->
length; i++) {
51 buf[4+i] = msg->
data[i];
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) {
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;
328 memcpy(c->
data, &data[len - buf_rem], data_size);
329 c->
size =
sizeof(c->header) + data_size;
330 buf_rem -= data_size;
#define CRTP_PORT_PPRZLINK
uint8_t data[SYSLINK_MAX_DATA_LEN]
static void handle_raw_other(syslink_message_t *msg)
Handle various raw messages.
#define SYSLINK_RADIO_RAW
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
syslink_parse_state state
syslink parser state
void syslink_parse_init(syslink_parse_state *state)
Init syslink parser.
syslink_message_t msg_rx
last received syslink message
#define CRTP_MAX_DATA_SIZE
#define SYSLINK_PM_ONOFF_SWITCHOFF
uint8_t uart_getch(struct uart_periph *p)
void syslink_dl_event(void)
Datalink event.
#define SYSLINK_PM_BATTERY_STATE
uint8_t tx_insert_idx
tx insert index
void uart_put_buffer(struct uart_periph *p, long fd, const uint8_t *data, uint16_t len)
Uart transmit buffer implementation.
#define PPRZ_MUTEX_LOCK(_mtx)
#define SYSLINK_RADIO_ADDRESS
static void send_message(syslink_message_t *msg)
Send a syslink message.
static void handle_radio(syslink_message_t *msg)
float vsupply
supply voltage in V
static uint8_t syslink_getch(struct syslink_dl *s)
void syslink_dl_periodic(void)
Periodic function.
#define SYSLINK_RADIO_DATARATE
uint8_t data[CRTP_MAX_DATA_SIZE]
PPRZ_MUTEX(syslink_tx_mtx)
Protect syslink TX with Mutex when using RTOS.
Interface for electrical status: supply voltage, current, battery status, etc.
void syslink_compute_cksum(syslink_message_t *msg)
Compute syslink checksum.
static int syslink_char_available(struct syslink_dl *s)
static void syslink_send_message(struct syslink_dl *s UNUSED, long fd UNUSED)
bool charging
battery charging
struct link_device device
uint8_t rx_buf[SYSLINK_RX_BUF_LEN]
received pprzlink bytes from syslink/crtp
uint8_t rx_extract_idx
rx extract index
void syslink_dl_init(void)
Init function.
#define CRTP_PORT_COMMANDER
uint8_t rx_insert_idx
rx insert index
#define PPRZ_MUTEX_INIT(_mtx)
static int syslink_check_free_space(struct syslink_dl *s, long *fd UNUSED, uint16_t len)
Implementation of syslink as generic device.
#define SYSLINK_RADIO_RSSI
Utility functions and macros to abstract some RTOS functionalities such as mutexes.
bool syslink_parse_char(syslink_parse_state *state, uint8_t c, syslink_message_t *msg)
Parse one byte.
#define SYSLINK_RADIO_CHANNEL
#define SYSLINK_RX_BUF_LEN
struct syslink_dl syslink
arch independent LED (Light Emitting Diodes) API
uint8_t tx_extract_idx
tx extract index
static void syslink_put_byte(struct syslink_dl *s, long fd, const uint8_t b)
struct Electrical electrical
static void handle_battery(syslink_message_t *msg)
Handle battery message.
static void handle_new_msg(syslink_message_t *msg)
New RX message.
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
Syslink protocol handling and functionalities.
crtp_message_t msg_tx[CRTP_BUF_LEN]
queued crtp packets to be send
#define PPRZ_MUTEX_UNLOCK(_mtx)
static void syslink_put_buffer(struct syslink_dl *s, long fd UNUSED, const uint8_t *data, uint16_t len)
int uart_char_available(struct uart_periph *p)
Check UART for available chars in receive buffer.
static void handle_raw(syslink_message_t *msg)
Handle raw datalink.