|
|
@ -11,6 +11,7 @@ |
|
|
|
#include "hardware/claim.h" |
|
|
|
#include "hardware/claim.h" |
|
|
|
|
|
|
|
|
|
|
|
KissClass Kiss; |
|
|
|
KissClass Kiss; |
|
|
|
|
|
|
|
struct ax25_frame AX25Frame; //defined in kiss.h
|
|
|
|
|
|
|
|
|
|
|
|
bool startRadio(); |
|
|
|
bool startRadio(); |
|
|
|
void getPacketData(int packetLength); |
|
|
|
void getPacketData(int packetLength); |
|
|
@ -429,31 +430,72 @@ void ProcessSerialInput(char string[]) |
|
|
|
} |
|
|
|
} |
|
|
|
void ReadUSBSerial(void) |
|
|
|
void ReadUSBSerial(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
static char strg[100]; |
|
|
|
static char strg[512]; |
|
|
|
int chr; |
|
|
|
int chr; |
|
|
|
static int lp = 0; |
|
|
|
static int lp = 0; |
|
|
|
|
|
|
|
|
|
|
|
// Read serial port (USB) - non-blocking!
|
|
|
|
if (Status.KissMode == OFF) { |
|
|
|
chr = getchar_timeout_us(0); |
|
|
|
// Read serial port (USB) - non-blocking!
|
|
|
|
while(chr != PICO_ERROR_TIMEOUT) |
|
|
|
chr = getchar_timeout_us(0); |
|
|
|
{ |
|
|
|
while(chr != PICO_ERROR_TIMEOUT) |
|
|
|
log_out("%c", chr); |
|
|
|
{ |
|
|
|
|
|
|
|
log_out("%c", chr); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strg[lp++] = chr; |
|
|
|
|
|
|
|
if(chr == CR || lp == (sizeof(strg) - 1)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
strg[lp-1] = 0; //terminate string by overwriting <CR> with NULL
|
|
|
|
|
|
|
|
//log_out("You wrote - %s\n", strg);
|
|
|
|
|
|
|
|
lp = 0; //reset string buffer pointer
|
|
|
|
|
|
|
|
log_out("\n"); |
|
|
|
|
|
|
|
|
|
|
|
strg[lp++] = chr; |
|
|
|
ProcessSerialInput(strg); |
|
|
|
if(chr == CR || lp == (sizeof(strg) - 1)) |
|
|
|
|
|
|
|
{ |
|
|
|
break; |
|
|
|
strg[lp-1] = 0; //terminate string by overwriting <CR> with NULL
|
|
|
|
} |
|
|
|
//log_out("You wrote - %s\n", strg);
|
|
|
|
|
|
|
|
lp = 0; //reset string buffer pointer
|
|
|
|
|
|
|
|
log_out("\n"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProcessSerialInput(strg); |
|
|
|
chr = getchar_timeout_us(0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// We are in KISS mode
|
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Read serial port (USB) - non-blocking!
|
|
|
|
|
|
|
|
chr = getchar_timeout_us(0); |
|
|
|
|
|
|
|
while(chr != PICO_ERROR_TIMEOUT) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
strg[lp++] = chr; |
|
|
|
|
|
|
|
// Receive buffer buffer full
|
|
|
|
|
|
|
|
if( lp == (sizeof(strg) - 1)) { |
|
|
|
|
|
|
|
lp=0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Received FEND (=begin or end frame)
|
|
|
|
|
|
|
|
if(chr == FEND) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Valid FISS frame received
|
|
|
|
|
|
|
|
if (strg[0] == FEND && lp > 1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (Kiss.DecodeFrame((uint8_t *) strg, &AX25Frame) == 2) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//exit KISS MODE
|
|
|
|
|
|
|
|
stdio_set_translate_crlf(&stdio_usb, true); |
|
|
|
|
|
|
|
Status.KissMode = OFF;
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
lp = 0; //reset string buffer pointer
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// We received a FEND byte,so we are probably between two KISS frames. Let's assume the latest FEND is the beginning of a new frame
|
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
strg[0] = chr; |
|
|
|
|
|
|
|
lp = 1; // set string buffer pointer to second position
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
chr = getchar_timeout_us(0); |
|
|
|
chr = getchar_timeout_us(0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int main() { |
|
|
|
int main() { |
|
|
@ -641,7 +683,6 @@ uint16_t decode_packet () |
|
|
|
int cnt = 0; |
|
|
|
int cnt = 0; |
|
|
|
|
|
|
|
|
|
|
|
struct aprs_frame AprsFrame; //defined in kiss.h
|
|
|
|
struct aprs_frame AprsFrame; //defined in kiss.h
|
|
|
|
struct ax25_frame AX25Frame; //defined in kiss.h
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memset(AprsFrame.source_address, 0, sizeof(AprsFrame.source_address)); |
|
|
|
memset(AprsFrame.source_address, 0, sizeof(AprsFrame.source_address)); |
|
|
|
memset(AprsFrame.digi_path, 0, sizeof(AprsFrame.digi_path)); |
|
|
|
memset(AprsFrame.digi_path, 0, sizeof(AprsFrame.digi_path)); |
|
|
@ -768,7 +809,7 @@ uint16_t decode_packet () |
|
|
|
log_out("Source address: %s\nDigipeaters (%u): %s %s %s %s\nData: %s\n", AprsFrame.source_address, AprsFrame.number_of_digipeaters+1, AprsFrame.digis[0], AprsFrame.digis[1], AprsFrame.digis[2], AprsFrame.digis[3], AprsFrame.data_field); |
|
|
|
log_out("Source address: %s\nDigipeaters (%u): %s %s %s %s\nData: %s\n", AprsFrame.source_address, AprsFrame.number_of_digipeaters+1, AprsFrame.digis[0], AprsFrame.digis[1], AprsFrame.digis[2], AprsFrame.digis[3], AprsFrame.data_field); |
|
|
|
|
|
|
|
|
|
|
|
// If in KISS mode the struct AprsFrame is handed over to the KISS encoder
|
|
|
|
// If in KISS mode the struct AprsFrame is handed over to the KISS encoder
|
|
|
|
if (Status.KissMode == 0) |
|
|
|
if (Status.KissMode == ON) |
|
|
|
Kiss.EncodeFrame(&AprsFrame, &AX25Frame); |
|
|
|
Kiss.EncodeFrame(&AprsFrame, &AX25Frame); |
|
|
|
|
|
|
|
|
|
|
|
if (AprsFrame.message[0]) |
|
|
|
if (AprsFrame.message[0]) |
|
|
|