From 13b792fcbe0d3d86dfe7f352d8e57c7062ee47e4 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 28 Apr 2014 17:53:43 +0200 Subject: [PATCH] TCP mode --- Modem/main.c | 4 +++- Modem/protocol/mp1.c | 45 +++++++++++++++++++++++++++++--------------- Modem/protocol/mp1.h | 3 +++ buildrev.h | 2 +- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/Modem/main.c b/Modem/main.c index 1fa2e39..0aa166e 100644 --- a/Modem/main.c +++ b/Modem/main.c @@ -89,7 +89,9 @@ int main(void) init(); // Record the current tick count for time-keeping ticks_t start = timer_clock(); - ticks_t frameQueued = 0; + #if MP1_USE_TX_QUEUE + ticks_t frameQueued = 0; + #endif // Go into ye good ol' infinite loop while (1) diff --git a/Modem/protocol/mp1.c b/Modem/protocol/mp1.c index ba49b54..8b1d1e0 100644 --- a/Modem/protocol/mp1.c +++ b/Modem/protocol/mp1.c @@ -412,11 +412,18 @@ void mp1Send(MP1 *mp1, void *_buffer, size_t length) { // Open transmitter and wait for MP1_TXDELAY msecs AFSK_HW_PTT_ON(); ticks_t start = timer_clock(); + #if MP1_USE_TX_QUEUE if (!mp1->queueProcessing) { while (timer_clock() - start < ms_to_ticks(MP1_TXDELAY)) { cpu_relax(); } } + #else + while (timer_clock() - start < ms_to_ticks(MP1_TXDELAY)) { + cpu_relax(); + } + #endif + // Get the transmit data buffer uint8_t *buffer = (uint8_t *)_buffer; @@ -534,30 +541,38 @@ void mp1Send(MP1 *mp1, void *_buffer, size_t length) { kfile_putc(HDLC_FLAG, mp1->modem); // Turn off manual PTT - if (!mp1->queueProcessing) AFSK_HW_PTT_OFF(); + #if MP1_USE_TX_QUEUE + if (!mp1->queueProcessing) AFSK_HW_PTT_OFF(); + #else + AFSK_HW_PTT_OFF(); + #endif } // This function accepts a frame and stores // it in the transmission queue -void mp1QueueFrame(MP1 *mp1, void *_buffer, size_t length) { - if (mp1->queueLength < MP1_TX_QUEUE_LENGTH) { - uint8_t *buffer = (uint8_t *)_buffer; - mp1->frameLengths[mp1->queueLength] = length; - memcpy(mp1->frameQueue[mp1->queueLength++], buffer, length); +#if MP1_USE_TX_QUEUE + void mp1QueueFrame(MP1 *mp1, void *_buffer, size_t length) { + if (mp1->queueLength < MP1_TX_QUEUE_LENGTH) { + uint8_t *buffer = (uint8_t *)_buffer; + mp1->frameLengths[mp1->queueLength] = length; + memcpy(mp1->frameQueue[mp1->queueLength++], buffer, length); + } } -} +#endif // This function processes the transmission // queue. -void mp1ProcessQueue(MP1 *mp1) { - int i = 0; - while (mp1->queueLength) { - mp1Send(mp1, mp1->frameQueue[i], mp1->frameLengths[i]); - i++; - mp1->queueLength--; +#if MP1_USE_TX_QUEUE + void mp1ProcessQueue(MP1 *mp1) { + int i = 0; + while (mp1->queueLength) { + mp1Send(mp1, mp1->frameQueue[i], mp1->frameLengths[i]); + i++; + mp1->queueLength--; + } + AFSK_HW_PTT_OFF(); } - AFSK_HW_PTT_OFF(); -} +#endif // A simple form of P-persistent CSMA. // Everytime we have heard activity diff --git a/Modem/protocol/mp1.h b/Modem/protocol/mp1.h index 6a12bd8..f9c89ed 100644 --- a/Modem/protocol/mp1.h +++ b/Modem/protocol/mp1.h @@ -8,6 +8,8 @@ #define MP1_ENABLE_TCP_COMPATIBILITY false #if MP1_ENABLE_TCP_COMPATIBILITY #define MP1_ENABLE_COMPRESSION false +#else + #define MP1_ENABLE_COMPRESSION true #endif #define MP1_ENABLE_CSMA true @@ -15,6 +17,7 @@ #define MP1_INTERLEAVE_SIZE 12 #if MP1_ENABLE_COMPRESSION #define MP1_MAX_FRAME_LENGTH 22 * MP1_INTERLEAVE_SIZE + #define MP1_USE_TX_QUEUE false #else #define MP1_MAX_FRAME_LENGTH 25 * MP1_INTERLEAVE_SIZE #define MP1_USE_TX_QUEUE true diff --git a/buildrev.h b/buildrev.h index 8e98bd7..c2a1442 100644 --- a/buildrev.h +++ b/buildrev.h @@ -1,2 +1,2 @@ -#define VERS_BUILD 1724 +#define VERS_BUILD 1734 #define VERS_HOST "shard"