kopia lustrzana https://github.com/DL7AD/pecanpico10
Implemented packet TX via packet system radio manager queue.
rodzic
a59dcd7b45
commit
8042401de1
|
@ -517,7 +517,7 @@ AFSKDemodDriver *pktCreateAFSKDecoder(packet_svc_t *pktHandler) {
|
|||
myDriver->packet_handler = pktHandler;
|
||||
|
||||
/* The radio associated with this AFSK driver. */
|
||||
radio_unit_t rid = myDriver->packet_handler->radio_config.radio_id;
|
||||
radio_unit_t rid = myDriver->packet_handler->radio_rx_config.radio_id;
|
||||
|
||||
/* Create a PWM FIFO name for this radio. */
|
||||
chsnprintf(myDriver->pwm_fifo_name, sizeof(myDriver->pwm_fifo_name),
|
||||
|
@ -542,7 +542,7 @@ AFSKDemodDriver *pktCreateAFSKDecoder(packet_svc_t *pktHandler) {
|
|||
myDriver->active_demod_object = NULL;
|
||||
|
||||
/* Attach and initialize the ICU PWM system. */
|
||||
myDriver->icudriver = pktAttachICU(pktHandler->radio_config.radio_id);
|
||||
myDriver->icudriver = pktAttachICU(pktHandler->radio_rx_config.radio_id);
|
||||
|
||||
/* Set the link from ICU driver to AFSK demod driver. */
|
||||
myDriver->icudriver->link = myDriver;
|
||||
|
|
|
@ -49,13 +49,13 @@ THD_FUNCTION(pktRadioManager, arg) {
|
|||
if(fifo_msg == MSG_TIMEOUT)
|
||||
continue;
|
||||
|
||||
/* Something to do. Handler pointer is in fifo_msg. */
|
||||
/* Something to do. Handler pointer is in fifo_msg for RX tasks. */
|
||||
|
||||
packet_svc_t *handler = task_object->handler;
|
||||
|
||||
/* Process command. */
|
||||
switch(task_object->command) {
|
||||
case PKT_RADIO_OPEN: {
|
||||
case PKT_RADIO_RX_OPEN: {
|
||||
/* Create the packet management services. */
|
||||
pktBufferManagerCreate(handler);
|
||||
pktCallbackManagerCreate(handler);
|
||||
|
@ -88,15 +88,14 @@ THD_FUNCTION(pktRadioManager, arg) {
|
|||
} /* End case PKT_RADIO_OPEN. */
|
||||
|
||||
/* TODO: Tune radio to channel. */
|
||||
case PKT_RADIO_RX: {
|
||||
case PKT_RADIO_RX_START: {
|
||||
switch(task_object->type) {
|
||||
case MOD_AFSK: {
|
||||
pktStartDecoder(handler);
|
||||
radio_squelch_t sq = task_object->squelch;
|
||||
//radio_freq_t freq = task_object->base_frequency;
|
||||
//channel_hz_t step = task_object->step_hz;
|
||||
|
||||
radio_ch_t chan = task_object->channel;
|
||||
/* TODO: Use channel only to start receive. */
|
||||
radio_squelch_t sq = task_object->squelch;
|
||||
|
||||
Si446x_receiveNoLock(chan, sq, MOD_AFSK);
|
||||
rx_active = true;
|
||||
break;
|
||||
|
@ -126,43 +125,34 @@ THD_FUNCTION(pktRadioManager, arg) {
|
|||
break;
|
||||
} /* End case PKT_RADIO_RX_STOP. */
|
||||
|
||||
case PKT_RADIO_TX: {
|
||||
case PKT_RADIO_TX_SEND: {
|
||||
/*
|
||||
* TODO: The 446x driver currently pauses decoding itself.
|
||||
* Consider moving it to here?
|
||||
*/
|
||||
packet_t pp = task_object->packet_out;
|
||||
radio_freq_t freq = task_object->base_frequency;
|
||||
channel_hz_t step = task_object->step_hz;
|
||||
radio_ch_t chan = task_object->channel;
|
||||
uint8_t pwr = task_object->tx_power;
|
||||
uint32_t speed = task_object->tx_speed;
|
||||
|
||||
switch(task_object->type) {
|
||||
case MOD_AFSK: {
|
||||
/*
|
||||
* TODO: The 446x driver currently pauses decoding
|
||||
* Consider moving it to here.
|
||||
*/
|
||||
/* switch(mod)
|
||||
{
|
||||
case MOD_2FSK:
|
||||
Si446x_send2FSK(pp, freq, step, chan, pwr, 9600);
|
||||
break;
|
||||
case MOD_AFSK:
|
||||
Si446x_sendAFSK(pp, freq, step, chan, pwr);
|
||||
break;
|
||||
}*/
|
||||
//=============================
|
||||
pktStartDecoder(handler);
|
||||
radio_squelch_t sq = task_object->squelch;
|
||||
//radio_freq_t freq = task_object->base_frequency;
|
||||
//channel_hz_t step = task_object->step_hz;
|
||||
radio_ch_t chan = task_object->channel;
|
||||
/* TODO: Use channel only to start receive. */
|
||||
Si446x_receiveNoLock(chan, sq, MOD_AFSK);
|
||||
rx_active = true;
|
||||
case MOD_2FSK:
|
||||
Si446x_send2FSK(pp, freq, step, chan, pwr, speed);
|
||||
break;
|
||||
|
||||
case MOD_AFSK:
|
||||
Si446x_sendAFSK(pp, freq, step, chan, pwr);
|
||||
break;
|
||||
} /* End case PKT_RADIO_RX. */
|
||||
|
||||
case MOD_NONE:
|
||||
case MOD_2FSK: {
|
||||
break;
|
||||
}
|
||||
} /* End switch on task_object->type. */
|
||||
break;
|
||||
}
|
||||
} /* End case PKT_RADIO_TX. */
|
||||
|
||||
case PKT_RADIO_CLOSE: {
|
||||
case PKT_RADIO_RX_CLOSE: {
|
||||
event_listener_t el;
|
||||
event_source_t *esp;
|
||||
thread_t *decoder = NULL;
|
||||
|
@ -211,7 +201,6 @@ THD_FUNCTION(pktRadioManager, arg) {
|
|||
break;
|
||||
} /*end case close. */
|
||||
} /* End switch on command. */
|
||||
|
||||
if(task_object->callback != NULL)
|
||||
/* Perform the callback. */
|
||||
task_object->callback(handler);
|
||||
|
@ -225,7 +214,7 @@ THD_FUNCTION(pktRadioManager, arg) {
|
|||
void pktRadioManagerCreate(packet_svc_t *handler) {
|
||||
|
||||
/* The radio associated with this packet handler. */
|
||||
radio_unit_t rid = handler->radio_config.radio_id;
|
||||
radio_unit_t rid = handler->radio_rx_config.radio_id;
|
||||
|
||||
/* Create the radio manager name. */
|
||||
chsnprintf(handler->rtask_name, sizeof(handler->rtask_name),
|
||||
|
|
|
@ -40,11 +40,11 @@
|
|||
* @details Radio task requests execute these commands.
|
||||
*/
|
||||
typedef enum radioCommand {
|
||||
PKT_RADIO_OPEN,
|
||||
PKT_RADIO_RX,
|
||||
PKT_RADIO_RX_OPEN,
|
||||
PKT_RADIO_RX_START,
|
||||
PKT_RADIO_RX_STOP,
|
||||
PKT_RADIO_TX,
|
||||
PKT_RADIO_CLOSE
|
||||
PKT_RADIO_TX_SEND,
|
||||
PKT_RADIO_RX_CLOSE
|
||||
} radio_command_t;
|
||||
|
||||
/**
|
||||
|
@ -73,6 +73,9 @@ typedef uint8_t radio_squelch_t;
|
|||
*/
|
||||
typedef struct radioTask radio_task_object_t;
|
||||
typedef struct packetHandlerData packet_svc_t;
|
||||
#ifdef PKT_IS_TEST_PROJECT
|
||||
typedef void * packet_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Radio task notification callback type.
|
||||
|
@ -110,6 +113,9 @@ struct radioTask {
|
|||
radio_squelch_t squelch;
|
||||
radio_task_cb_t callback;
|
||||
packet_svc_t *handler;
|
||||
packet_t packet_out;
|
||||
uint8_t tx_power;
|
||||
uint32_t tx_speed;
|
||||
};
|
||||
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -52,10 +52,12 @@ void pktServiceCreate() {
|
|||
*/
|
||||
chEvtObjectInit(pktGetEventSource(handler));
|
||||
|
||||
memset(&handler->radio_config, 0, sizeof(radio_task_object_t));
|
||||
memset(&handler->radio_rx_config, 0, sizeof(radio_task_object_t));
|
||||
memset(&handler->radio_tx_config, 0, sizeof(radio_task_object_t));
|
||||
|
||||
/* Set parameters and send request. */
|
||||
handler->radio_config.radio_id = PKT_RADIO_1;
|
||||
handler->radio_rx_config.radio_id = PKT_RADIO_1;
|
||||
handler->radio_tx_config.radio_id = PKT_RADIO_1;
|
||||
|
||||
/* Set service semaphore to idle state. */
|
||||
chBSemObjectInit(&handler->close_sem, false);
|
||||
|
@ -110,9 +112,9 @@ msg_t pktOpenRadioService(radio_unit_t radio,
|
|||
chBSemWait(&handler->close_sem);
|
||||
|
||||
/* Save radio configuration. */
|
||||
handler->radio_config.type = encoding;
|
||||
handler->radio_config.base_frequency = frequency;
|
||||
handler->radio_config.step_hz = ch_step;
|
||||
handler->radio_rx_config.type = encoding;
|
||||
handler->radio_rx_config.base_frequency = frequency;
|
||||
handler->radio_rx_config.step_hz = ch_step;
|
||||
|
||||
/* Reset the statistics collection variables. */
|
||||
handler->sync_count = 0;
|
||||
|
@ -120,10 +122,10 @@ msg_t pktOpenRadioService(radio_unit_t radio,
|
|||
handler->valid_count = 0;
|
||||
handler->good_count = 0;
|
||||
|
||||
radio_task_object_t rt = handler->radio_config;
|
||||
radio_task_object_t rt = handler->radio_rx_config;
|
||||
|
||||
/* Set parameters for radio command. */
|
||||
rt.command = PKT_RADIO_OPEN;
|
||||
rt.command = PKT_RADIO_RX_OPEN;
|
||||
|
||||
/*
|
||||
* Open (init) the radio (via submit radio task).
|
||||
|
@ -171,12 +173,12 @@ msg_t pktStartDataReception(packet_svc_t *handler,
|
|||
|
||||
handler->usr_callback = cb;
|
||||
|
||||
handler->radio_config.channel = channel;
|
||||
handler->radio_config.squelch = sq;
|
||||
handler->radio_rx_config.channel = channel;
|
||||
handler->radio_rx_config.squelch = sq;
|
||||
|
||||
radio_task_object_t rt = handler->radio_config;
|
||||
radio_task_object_t rt = handler->radio_rx_config;
|
||||
|
||||
rt.command = PKT_RADIO_RX;
|
||||
rt.command = PKT_RADIO_RX_START;
|
||||
|
||||
msg_t msg = pktSendRadioCommand(handler, &rt);
|
||||
if(msg != MSG_OK)
|
||||
|
@ -203,7 +205,7 @@ void pktStartDecoder(packet_svc_t *handler) {
|
|||
event_listener_t el;
|
||||
event_source_t *esp;
|
||||
|
||||
switch(handler->radio_config.type) {
|
||||
switch(handler->radio_rx_config.type) {
|
||||
case MOD_AFSK: {
|
||||
|
||||
esp = pktGetEventSource((AFSKDemodDriver *)handler->link_controller);
|
||||
|
@ -259,7 +261,7 @@ msg_t pktStopDataReception(packet_svc_t *handler) {
|
|||
|
||||
/* Stop the radio processing. */
|
||||
|
||||
radio_task_object_t rt = handler->radio_config;
|
||||
radio_task_object_t rt = handler->radio_rx_config;
|
||||
|
||||
rt.command = PKT_RADIO_RX_STOP;
|
||||
|
||||
|
@ -288,7 +290,7 @@ void pktStopDecoder(packet_svc_t *handler) {
|
|||
event_listener_t el;
|
||||
event_source_t *esp;
|
||||
|
||||
switch(handler->radio_config.type) {
|
||||
switch(handler->radio_rx_config.type) {
|
||||
case MOD_AFSK: {
|
||||
esp = pktGetEventSource((AFSKDemodDriver *)handler->link_controller);
|
||||
|
||||
|
@ -344,9 +346,9 @@ msg_t pktCloseRadioService(packet_svc_t *handler) {
|
|||
|
||||
/* Set parameters for radio. */;
|
||||
|
||||
radio_task_object_t rt = handler->radio_config;
|
||||
radio_task_object_t rt = handler->radio_rx_config;
|
||||
|
||||
rt.command = PKT_RADIO_CLOSE;
|
||||
rt.command = PKT_RADIO_RX_CLOSE;
|
||||
|
||||
/* Submit command. A timeout can occur waiting for a command queue object. */
|
||||
msg_t msg = pktSendRadioCommand(handler, &rt);
|
||||
|
@ -589,7 +591,7 @@ THD_FUNCTION(pktCompletion, arg) {
|
|||
|
||||
void pktCallbackManagerOpen(packet_svc_t *handler) {
|
||||
|
||||
radio_unit_t rid = handler->radio_config.radio_id;
|
||||
radio_unit_t rid = handler->radio_rx_config.radio_id;
|
||||
|
||||
/* Create the callback handler thread name. */
|
||||
chsnprintf(handler->cbend_name, sizeof(handler->cbend_name),
|
||||
|
@ -609,7 +611,7 @@ void pktCallbackManagerOpen(packet_svc_t *handler) {
|
|||
|
||||
dyn_objects_fifo_t *pktBufferManagerCreate(packet_svc_t *handler) {
|
||||
/* The radio associated with this AFSK driver. */
|
||||
radio_unit_t rid = handler->radio_config.radio_id;
|
||||
radio_unit_t rid = handler->radio_rx_config.radio_id;
|
||||
|
||||
/* Create the packet buffer name for this radio. */
|
||||
chsnprintf(handler->pbuff_name, sizeof(handler->pbuff_name),
|
||||
|
@ -645,7 +647,7 @@ dyn_objects_fifo_t *pktBufferManagerCreate(packet_svc_t *handler) {
|
|||
|
||||
|
||||
void pktCallbackManagerCreate(packet_svc_t *handler) {
|
||||
radio_unit_t rid = handler->radio_config.radio_id;
|
||||
radio_unit_t rid = handler->radio_rx_config.radio_id;
|
||||
|
||||
/* Create the callback termination thread name. */
|
||||
chsnprintf(handler->cbend_name, sizeof(handler->cbend_name),
|
||||
|
|
|
@ -86,9 +86,14 @@ typedef struct packetHandlerData {
|
|||
packet_state_t state;
|
||||
|
||||
/**
|
||||
* @brief Radio operating parameters.
|
||||
* @brief Radio receiver operating parameters.
|
||||
*/
|
||||
radio_task_object_t radio_config;
|
||||
radio_task_object_t radio_rx_config;
|
||||
|
||||
/**
|
||||
* @brief Radio transmitter operating parameters.
|
||||
*/
|
||||
radio_task_object_t radio_tx_config;
|
||||
|
||||
/**
|
||||
* @brief Pointer to link level protocol data.
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
|
||||
#define SUSPEND_HANDLING NO_SUSPEND
|
||||
|
||||
/* Extra GPIO value. */
|
||||
/* Extra GPIO value used in local GPIO set/clear/toggle functions. */
|
||||
#define PAL_TOGGLE 2U
|
||||
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -64,8 +64,8 @@ bool transmitOnRadio(packet_t pp, uint32_t freq, uint16_t step, uint8_t chan,
|
|||
if(len) // Message length is not zero
|
||||
{
|
||||
|
||||
/* Set band and step size in 446x. */
|
||||
/* TODO: Check for success/fail from band set. */
|
||||
/* Set band and step size in 446x.
|
||||
* TODO: move this into radio manager. */
|
||||
if(!Si446x_setBandParameters(freq, step, RADIO_TX)) {
|
||||
|
||||
TRACE_ERROR("RAD > Transmit base frequency of %d.%03d MHz is invalid",
|
||||
|
@ -82,7 +82,42 @@ bool transmitOnRadio(packet_t pp, uint32_t freq, uint16_t step, uint8_t chan,
|
|||
aprs_debug_getPacket(pp, buf, sizeof(buf));
|
||||
TRACE_INFO("TX > %s", buf);
|
||||
|
||||
switch(mod)
|
||||
/*
|
||||
* TODO: The following is an interim setup.
|
||||
* The management of TX is only partially integrated.
|
||||
* Packet services also has WIP in handler <> radio mapping, etc.
|
||||
*/
|
||||
|
||||
extern packet_svc_t RPKTD1;
|
||||
packet_svc_t *handler = &RPKTD1;
|
||||
|
||||
if(!(handler->state == PACKET_OPEN || handler->state == PACKET_RUN)) {
|
||||
TRACE_ERROR("RAD > Packet services are not open for transmit");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Update the saved radio data with this new request. */
|
||||
radio_task_object_t rt = handler->radio_tx_config;
|
||||
|
||||
rt.handler = handler;
|
||||
rt.command = PKT_RADIO_TX_SEND;
|
||||
rt.type = mod;
|
||||
rt.base_frequency = freq;
|
||||
rt.step_hz = step;
|
||||
rt.channel = chan;
|
||||
rt.tx_power = pwr;
|
||||
rt.tx_speed = (mod == MOD_2FSK ? 9600 : 1200);
|
||||
rt.packet_out = pp;
|
||||
rt.callback = NULL;
|
||||
|
||||
/* Save the current data. */
|
||||
handler->radio_tx_config = rt;
|
||||
|
||||
msg_t msg = pktSendRadioCommand(rt.handler, &rt);
|
||||
if(msg != MSG_OK)
|
||||
return false;
|
||||
|
||||
/* switch(mod)
|
||||
{
|
||||
case MOD_2FSK:
|
||||
Si446x_send2FSK(pp, freq, step, chan, pwr, 9600);
|
||||
|
@ -90,7 +125,7 @@ bool transmitOnRadio(packet_t pp, uint32_t freq, uint16_t step, uint8_t chan,
|
|||
case MOD_AFSK:
|
||||
Si446x_sendAFSK(pp, freq, step, chan, pwr);
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
|
||||
} else {
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue