From f16b4d86acf86e1b05e7e75b9da13c7a8d2486de Mon Sep 17 00:00:00 2001 From: John Evan Jones Date: Tue, 31 Jul 2018 16:12:24 -0600 Subject: [PATCH 1/2] modified the creation of the transfer frames so that the solution was more elegant and correct, filling an incomplete transfer frame with packets of the idle data, rather than just stuffing it with idle data --- ElysiumCode/ccsds/sdlp.c | 36 ++++++++++++++++++++++++------------ ElysiumCode/ccsds/sdlp.h | 1 + 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ElysiumCode/ccsds/sdlp.c b/ElysiumCode/ccsds/sdlp.c index a64d785..6c04236 100644 --- a/ElysiumCode/ccsds/sdlp.c +++ b/ElysiumCode/ccsds/sdlp.c @@ -161,8 +161,9 @@ uint8_t elyRFDLLClampReg(uint8_t addr, uint8_t value) { /* TODO learn how to deal with non-SPP packets */ void elyRFDLLBuildFrame(void) { static ely_framebuilder_state_t state = FB_STATE_UNINIT; - static size_t idle_len = 0; + static size_t idle_len = SDLP_IDLE_PACKET_LENGTH; static size_t idle_idx = 0; + static size_t remaining_len = 0; size_t tf_idx = SDLP_TM_PH_LEN; bool fhp = false; @@ -207,7 +208,8 @@ void elyRFDLLBuildFrame(void) { tf_buffer[4] &= ~0x07; tf_buffer[5] = 0; fhp = true; - idle_len = 0; + idle_len = SDLP_IDLE_PACKET_LENGTH; + remaining_len = 0; idle_idx = 0; pkt_idx = 0; } @@ -235,13 +237,7 @@ void elyRFDLLBuildFrame(void) { } msg_t r = chMBFetch(&rf_mbox, (msg_t *)(&active_packet), SDLP_IDLE_PACKET_TIMEOUT); if (MSG_OK != r) { - idle_len = tf_data_len - tf_idx; - if (idle_len < 7) { - idle_len += tf_data_len; - } - idle_header[4] = (idle_len - 7) >> 8; - idle_header[5] = (idle_len - 7) & 0xFF; - idle_idx = 0; + idle_idx = idle_len; state = FB_STATE_IDLE; continue; } @@ -251,7 +247,23 @@ void elyRFDLLBuildFrame(void) { } tf_buffer[tf_idx++] = active_packet[pkt_idx++]; break; - case FB_STATE_IDLE: + case FB_STATE_IDLE: // we don't have any more payload data, so we need to fill the frame with idle data + if (idle_idx == idle_len){ + remaining_len = tf_data_len - tf_idx; // find how much room is left in the transfer frame + if (remaining_len < idle_len){ // if the last bit of the frame can't hold a full packet's worth of idle data... + idle_len = remaining_len; // then it won't. the frame will be given a slightly smaller packet + if (remaining_len < 7){ //if another idle header can't be fit into this transfer frame... + for (idle_idx = 0;idle_idx> 8; + idle_header[5] = (idle_len - 7) & 0xFF; + idle_idx = 0; + } + if (idle_idx < 6) { tf_buffer[tf_idx++] = idle_header[idle_idx++]; } @@ -259,13 +271,13 @@ void elyRFDLLBuildFrame(void) { tf_buffer[tf_idx++] = SPP_IDLE_DATA; idle_idx++; } - if (idle_idx == idle_len) { +/* if (idle_idx == idle_len && tf_idx != tf_data_len) { chDbgAssert(tf_idx == tf_data_len, "invalid framebuilder state"); idle_len = 0; chEvtWaitAnyTimeout(RFPktAvailable, TIME_IMMEDIATE); state = FB_STATE_UNINIT; continue; - } + }*/ break; default: chDbgAssert(false, "invalid framebuilder state"); diff --git a/ElysiumCode/ccsds/sdlp.h b/ElysiumCode/ccsds/sdlp.h index d4aa1c6..6e1b59f 100644 --- a/ElysiumCode/ccsds/sdlp.h +++ b/ElysiumCode/ccsds/sdlp.h @@ -20,6 +20,7 @@ /* TODO move this to SPP */ #define SPP_IDLE_DATA 0xAA +#define SDLP_IDLE_PACKET_LENGTH 1024 typedef enum { DLL_STATE_HDR, From 78baece2210020eea5f1399431cd6302bc904bb9 Mon Sep 17 00:00:00 2001 From: John Evan Jones Date: Wed, 1 Aug 2018 16:46:12 -0600 Subject: [PATCH 2/2] included sx1212.h into the sdlp header file --- ElysiumCode/ccsds/sdlp.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ElysiumCode/ccsds/sdlp.h b/ElysiumCode/ccsds/sdlp.h index 6e1b59f..a122284 100644 --- a/ElysiumCode/ccsds/sdlp.h +++ b/ElysiumCode/ccsds/sdlp.h @@ -4,6 +4,7 @@ #include "core.h" #include "sx1278.h" +#include "sx1212.h" #include "nl.h" #include "registers.h" #include "errors.h"