Before interleaver

This commit is contained in:
Mark Qvist 2014-04-15 20:18:22 +02:00
parent 565a5f35eb
commit 0b2683e486
6 changed files with 33 additions and 16 deletions

View File

@ -11,7 +11,7 @@
#define CONFIG_AFSK_RXTIMEOUT 0 // How long a read operation from the modem #define CONFIG_AFSK_RXTIMEOUT 0 // How long a read operation from the modem
// will wait for data before timing out. // will wait for data before timing out.
#define CONFIG_AFSK_PREAMBLE_LEN 250UL // The length of the packet preamble in milliseconds #define CONFIG_AFSK_PREAMBLE_LEN 500UL // The length of the packet preamble in milliseconds
#define CONFIG_AFSK_TRAILER_LEN 20UL // The length of the packet tail in milliseconds #define CONFIG_AFSK_TRAILER_LEN 100UL // The length of the packet tail in milliseconds
#endif #endif

View File

@ -19,7 +19,7 @@ static Afsk *modem;
// M1 correction = 9500 // M1 correction = 9500
// M2 correction = 40000 // M2 correction = 40000
#define FREQUENCY_CORRECTION 40000 #define FREQUENCY_CORRECTION 9500
// This function initializes the ADC and configures // This function initializes the ADC and configures
// it the way we need. // it the way we need.

View File

@ -50,11 +50,10 @@ static bool sertx = false; // Flag signifying whether it's time to send da
static void mp1Callback(struct MP1Packet *packet) { static void mp1Callback(struct MP1Packet *packet) {
kfile_printf(&ser.fd, "%.*s\n", packet->dataLength, packet->data); kfile_printf(&ser.fd, "%.*s\n", packet->dataLength, packet->data);
// if (false) { if (packet->data[0]-128 == 'R' && packet->data[1]-128 == 'Q') {
// // strcmp(packet->data, "OZ7TMD") timer_delay(1000);
// timer_delay(300); mp1Send(&mp1, TEST_PACKET, sizeof(TEST_PACKET));
// mp1Send(&mp1, TEST_PACKET, sizeof(TEST_PACKET)); }
// }
//kprintf("%.*s\n", packet->dataLength, packet->data); //kprintf("%.*s\n", packet->dataLength, packet->data);
} }
@ -118,6 +117,8 @@ int main(void)
// If one of the above conditions were actually the // If one of the above conditions were actually the
// case, it means we have to transmit, se we set // case, it means we have to transmit, se we set
// transmission flag to true. // transmission flag to true.
serialBuffer[serialLen] = sbyte;
serialLen++;
sertx = true; sertx = true;
} }
} }

View File

@ -113,6 +113,8 @@ void mp1Poll(MP1 *mp1) {
mp1->checksum_in ^= correction; mp1->checksum_in ^= correction;
} }
mp1->buffer[mp1->packetLength-(2-i)] ^= correction; mp1->buffer[mp1->packetLength-(2-i)] ^= correction;
if (s != 0) mp1->correctionsMade += 1;
} }
} }
continue; continue;
@ -129,13 +131,15 @@ void mp1Poll(MP1 *mp1) {
// the end of the packet. Pass control to the // the end of the packet. Pass control to the
// decoder. // decoder.
if ((mp1->checksum_in & 0xff) == 0x00) { if ((mp1->checksum_in & 0xff) == 0x00) {
kprintf("[CHK-OK] [C=%d] ", mp1->correctionsMade);
mp1Decode(mp1); mp1Decode(mp1);
} else { } else {
// Checksum was incorrect, we don't do anything, // Checksum was incorrect, we don't do anything,
// but you can enable the decode anyway, if you // but you can enable the decode anyway, if you
// need it for testing or debugging // need it for testing or debugging
// kprintf("[ER] [%d] ", mp1->checksum_in); // kprintf("[ER] [%d] ", mp1->checksum_in);
//mp1Decode(mp1); kprintf("[CHK-ER] [C=%d] ", mp1->correctionsMade);
mp1Decode(mp1);
} }
} }
// If the above is not the case, this must be the // If the above is not the case, this must be the
@ -144,6 +148,7 @@ void mp1Poll(MP1 *mp1) {
mp1->packetLength = 0; mp1->packetLength = 0;
mp1->readLength = 0; mp1->readLength = 0;
mp1->checksum_in = MP1_CHECKSUM_INIT; mp1->checksum_in = MP1_CHECKSUM_INIT;
mp1->correctionsMade = 0;
// We have indicated that we are reading, // We have indicated that we are reading,
// and reset the length counter. Now we'll // and reset the length counter. Now we'll
@ -206,8 +211,6 @@ static void mp1Putbyte(MP1 *mp1, uint8_t byte) {
byte == HDLC_RESET || byte == HDLC_RESET ||
byte == AX25_ESC) { byte == AX25_ESC) {
kfile_putc(AX25_ESC, mp1->modem); kfile_putc(AX25_ESC, mp1->modem);
lastByte = AX25_ESC;
//sendParityBlock ^= true;
} }
kfile_putc(byte, mp1->modem); kfile_putc(byte, mp1->modem);
@ -221,6 +224,19 @@ static void mp1Putbyte(MP1 *mp1, uint8_t byte) {
sendParityBlock ^= true; sendParityBlock ^= true;
} }
static void mp1WriteByte(MP1 *mp1, uint8_t byte) {
// If we are sending something that looks
// like an HDLC special byte, send an escape
// character first
if (byte == HDLC_FLAG ||
byte == HDLC_RESET ||
byte == AX25_ESC) {
kfile_putc(AX25_ESC, mp1->modem);
}
kfile_putc(byte, mp1->modem);
}
void mp1Send(MP1 *mp1, const void *_buffer, size_t length) { void mp1Send(MP1 *mp1, const void *_buffer, size_t length) {
// Get the transmit data buffer // Get the transmit data buffer
const uint8_t *buffer = (const uint8_t *)_buffer; const uint8_t *buffer = (const uint8_t *)_buffer;
@ -234,7 +250,6 @@ void mp1Send(MP1 *mp1, const void *_buffer, size_t length) {
bool packetCompression = false; bool packetCompression = false;
size_t compressedSize = compress(buffer, length); size_t compressedSize = compress(buffer, length);
if (compressedSize != 0 && compressedSize < length) { if (compressedSize != 0 && compressedSize < length) {
//kprintf("Using compression\n");
// Compression saved us some space, we'll // Compression saved us some space, we'll
// send the paket compressed // send the paket compressed
packetCompression = true; packetCompression = true;

View File

@ -6,7 +6,7 @@
// Frame sizing & checksum // Frame sizing & checksum
#define MP1_MIN_FRAME_LENGTH 3 #define MP1_MIN_FRAME_LENGTH 3
#define MP1_MAX_FRAME_LENGTH 200 #define MP1_MAX_FRAME_LENGTH 300
#define MP1_CHECKSUM_INIT 0xAA #define MP1_CHECKSUM_INIT 0xAA
// We need to know some basic HDLC flag bytes // We need to know some basic HDLC flag bytes
@ -44,6 +44,7 @@ typedef struct MP1 {
bool reading; // True when we have seen a HDLC flag bool reading; // True when we have seen a HDLC flag
bool escape; // We need to know if we are in an escape sequence bool escape; // We need to know if we are in an escape sequence
bool fecEscape; // fec escape bool fecEscape; // fec escape
long correctionsMade; // correction count
} MP1; } MP1;
// A struct encapsulating a network packet // A struct encapsulating a network packet

View File

@ -1,2 +1,2 @@
#define VERS_BUILD 1070 #define VERS_BUILD 1108
#define VERS_HOST "vixen" #define VERS_HOST "vixen"