[extra_dl] Extend module functionality (#2042)

use dedicated buffer
This commit is contained in:
Michal Podhradsky
2017-03-21 03:08:15 -07:00
committed by Gautier Hattenberger
parent ec94d7dad9
commit 42c0cd27d1
11 changed files with 33 additions and 18 deletions
+10 -1
View File
@@ -11,7 +11,16 @@
</header>
<init fun="extra_pprz_dl_init()"/>
<periodic fun="extra_pprz_dl_periodic()" freq="TELEMETRY_FREQUENCY" autorun="TRUE"/>
<event fun="ExtraDatalinkEvent()"/>
<!--
The event function listens on the extra telemetry port (from the payload computer for example)
and parses the received "datalink" messages, such as MOVE_WP.
We need this function to be able to listen to the extra telemetry port
As a result all messages normally handled by the autopilot (such as MOVE_WP) are processed.
-->
<event fun="extra_pprz_dl_event()"/>
<makefile target="ap">
<configure name="EXTRA_DL_PORT" default="uart1" case="upper|lower"/>
<define name="EXTRA_DOWNLINK_DEVICE" value="$(EXTRA_DL_PORT_LOWER)"/>
+1 -1
View File
@@ -137,7 +137,7 @@ value set_datalink_message(value s)
}
dl_msg_available = true;
DlCheckAndParse(&(DOWNLINK_DEVICE).device, &ivy_tp.trans_tx, dl_buffer);
DlCheckAndParse(&(DOWNLINK_DEVICE).device, &ivy_tp.trans_tx, dl_buffer, &dl_msg_available);
return Val_unit;
}
+1 -1
View File
@@ -38,6 +38,6 @@ void bluegiga_dl_init(void)
void bluegiga_dl_event(void)
{
pprz_check_and_parse(&DOWNLINK_DEVICE.device, &pprz_bg_tp, dl_buffer, &dl_msg_available);
DlCheckAndParse(&DOWNLINK_DEVICE.device, &pprz_bg_tp.trans_tx, dl_buffer);
DlCheckAndParse(&DOWNLINK_DEVICE.device, &pprz_bg_tp.trans_tx, dl_buffer, &dl_msg_available);
}
+10 -1
View File
@@ -46,6 +46,8 @@
#include "modules/datalink/extra_pprz_dl.h"
#include "subsystems/datalink/telemetry.h"
bool extra_dl_msg_available;
uint8_t extra_dl_buffer[MSG_SIZE] __attribute__((aligned));
struct pprz_transport extra_pprz_tp;
@@ -54,6 +56,14 @@ void extra_pprz_dl_init(void)
pprz_transport_init(&extra_pprz_tp);
}
void extra_pprz_dl_event(void)
{
pprz_check_and_parse(&EXTRA_DOWNLINK_DEVICE.device, &extra_pprz_tp, extra_dl_buffer, &extra_dl_msg_available);
DlCheckAndParse(&EXTRA_DOWNLINK_DEVICE.device, &extra_pprz_tp.trans_tx, extra_dl_buffer, &extra_dl_msg_available);
}
void extra_pprz_dl_periodic(void)
{
#if PERIODIC_TELEMETRY && defined(TELEMETRY_PROCESS_Extra)
@@ -61,4 +71,3 @@ void extra_pprz_dl_periodic(void)
periodic_telemetry_send_Extra(DefaultPeriodic, &extra_pprz_tp.trans_tx, &(EXTRA_DOWNLINK_DEVICE).device);
#endif
}
+3 -5
View File
@@ -41,11 +41,9 @@
/* PPRZ transport structure */
extern struct pprz_transport extra_pprz_tp;
/* Datalink Event */
#define ExtraDatalinkEvent() { \
pprz_check_and_parse(&EXTRA_DOWNLINK_DEVICE.device, &extra_pprz_tp, dl_buffer, &dl_msg_available); \
DlCheckAndParse(&EXTRA_DOWNLINK_DEVICE.device, &extra_pprz_tp.trans_tx, dl_buffer); \
}
/** Datalink Event */
void extra_pprz_dl_event(void);
/** Init function */
extern void extra_pprz_dl_init(void);
+1 -1
View File
@@ -36,6 +36,6 @@ void pprz_dl_init(void)
void pprz_dl_event(void)
{
pprz_check_and_parse(&DOWNLINK_DEVICE.device, &pprz_tp, dl_buffer, &dl_msg_available);
DlCheckAndParse(&DOWNLINK_DEVICE.device, &pprz_tp.trans_tx, dl_buffer);
DlCheckAndParse(&DOWNLINK_DEVICE.device, &pprz_tp.trans_tx, dl_buffer, &dl_msg_available);
}
+1 -1
View File
@@ -53,6 +53,6 @@ void xbee_dl_init(void)
void xbee_dl_event(void)
{
xbee_check_and_parse(&(XBEE_UART).device, &xbee_tp, dl_buffer, &dl_msg_available);
DlCheckAndParse(&(XBEE_UART).device, &xbee_tp.trans_tx, dl_buffer);
DlCheckAndParse(&(XBEE_UART).device, &xbee_tp.trans_tx, dl_buffer, &dl_msg_available);
}
+1 -2
View File
@@ -31,9 +31,8 @@
* GEOFENCE_DATALINK_LOST_TIME is defined in the airframe config file
*/
#include <stdbool.h>
#ifdef GEOFENCE_DATALINK_LOST_TIME
#include "subsystems/datalink/datalink.h"
/*
* from the airfame config file:
* go to HOME mode if datalink lost for GEOFENCE_DATALINK_LOST_TIME
+3 -3
View File
@@ -79,7 +79,7 @@ EXTERN bool datalink_enabled;
}
/** Check for new message and parse */
static inline void DlCheckAndParse(struct link_device *dev, struct transport_tx *trans, uint8_t *buf)
static inline void DlCheckAndParse(struct link_device *dev, struct transport_tx *trans, uint8_t *buf, bool *msg_available)
{
// make it possible to disable datalink in NPS sim
#if USE_NPS
@@ -88,11 +88,11 @@ static inline void DlCheckAndParse(struct link_device *dev, struct transport_tx
}
#endif
if (dl_msg_available) {
if (*msg_available) {
datalink_time = 0;
datalink_nb_msgs++;
dl_parse_msg(dev, trans, buf);
dl_msg_available = false;
*msg_available = false;
}
}
+1 -1
View File
@@ -288,7 +288,7 @@ void superbitrf_dl_init(void)
*/
void superbitrf_dl_event(void)
{
DlCheckAndParse(&DOWNLINK_DEVICE.device, &pprz_srf_tp.trans_tx, dl_buffer);
DlCheckAndParse(&DOWNLINK_DEVICE.device, &pprz_srf_tp.trans_tx, dl_buffer, &dl_msg_available);
}
void superbitrf_set_mfg_id(uint32_t id)
+1 -1
View File
@@ -104,7 +104,7 @@ static inline void w5100_check_and_parse(struct link_device *dev, struct pprz_tr
static inline w5100_event(void)
{
w5100_check_and_parse(&(W5100).device, &pprz_w5100_tp);
DlCheckAndParse(&(W5100).device, &pprz_w5100_tp.trans_tx, dl_buffer);
DlCheckAndParse(&(W5100).device, &pprz_w5100_tp.trans_tx, dl_buffer, &dl_msg_available);
}
#endif /* W5100_H */