kopia lustrzana https://github.com/DL7AD/pecanpico10
Rework debug UART configuration. Move si446x driver to drivers folder.
rodzic
c264f211c4
commit
3493a9cb68
|
@ -142,8 +142,8 @@ void pktSerialStart(void) {
|
|||
sdStart(SERIAL_CFG_DEBUG_DRIVER, &debug_config);
|
||||
#endif
|
||||
/* Setup diagnostic resource access semaphore. */
|
||||
extern binary_semaphore_t diag_out_sem;
|
||||
chBSemObjectInit(&diag_out_sem, false);
|
||||
extern binary_semaphore_t debug_out_sem;
|
||||
chBSemObjectInit(&debug_out_sem, false);
|
||||
}
|
||||
|
||||
void dbgWrite(uint8_t level, uint8_t *buf, uint32_t len) {
|
||||
|
|
|
@ -150,7 +150,12 @@
|
|||
/* The external port can be used for bit bang I2C. */
|
||||
#define ENABLE_EXTERNAL_I2C TRUE
|
||||
|
||||
#if ENABLE_EXTERNAL_I2C == FALSE
|
||||
/* To use IO_TXD/IO_RXD for UART debug channel. */
|
||||
#define ENABLE_SERIAL_DEBUG FALSE
|
||||
|
||||
#if ENABLE_EXTERNAL_I2C == TRUE && ENABLE_SERIAL_DEBUG == TRUE
|
||||
#error "Cannot enable serial debug when using external I2C"
|
||||
#elif ENABLE_EXTERNAL_I2C == FALSE && ENABLE_SERIAL_DEBUG == TRUE
|
||||
#define LINE_USART3_TX LINE_IO_TXD
|
||||
#define LINE_USART3_RX LINE_IO_RXD
|
||||
#endif
|
||||
|
@ -198,7 +203,7 @@
|
|||
/* Definitions for ICU FIFO implemented using chfactory. */
|
||||
#if USE_HEAP_PWM_BUFFER == TRUE
|
||||
/* Use factory FIFO as stream control with separate chained PWM buffers. */
|
||||
#define NUMBER_PWM_FIFOS 3U
|
||||
#define NUMBER_PWM_FIFOS 5U
|
||||
/* Number of PWM data entries per queue object. */
|
||||
#define PWM_DATA_SLOTS 200
|
||||
/* Number of PWM queue objects in total. */
|
||||
|
|
|
@ -109,6 +109,9 @@ void pktConfigSerialDiag(void) {
|
|||
palSetLineMode(LINE_USART3_RX, PAL_MODE_ALTERNATE(7));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure packet dump output
|
||||
*/
|
||||
void pktConfigSerialPkt(void) {
|
||||
|
||||
}
|
||||
|
@ -135,14 +138,14 @@ uint8_t pktReadIOlines() {
|
|||
}
|
||||
|
||||
void pktSerialStart(void) {
|
||||
#if ENABLE_EXTERNAL_I2C == FALSE
|
||||
#if ENABLE_SERIAL_DEBUG == TRUE
|
||||
pktConfigSerialDiag();
|
||||
pktConfigSerialPkt();
|
||||
sdStart(SERIAL_CFG_DEBUG_DRIVER, &debug_config);
|
||||
#endif
|
||||
/* Setup diagnostic resource access semaphore. */
|
||||
extern binary_semaphore_t diag_out_sem;
|
||||
chBSemObjectInit(&diag_out_sem, false);
|
||||
extern binary_semaphore_t debug_out_sem;
|
||||
chBSemObjectInit(&debug_out_sem, false);
|
||||
}
|
||||
|
||||
void dbgWrite(uint8_t level, uint8_t *buf, uint32_t len) {
|
||||
|
|
|
@ -151,7 +151,10 @@
|
|||
/* The external port can be used for bit bang I2C. */
|
||||
#define ENABLE_EXTERNAL_I2C FALSE
|
||||
|
||||
#if ENABLE_EXTERNAL_I2C == FALSE
|
||||
/* To use IO_TXD/IO_RXD for UART debug channel. */
|
||||
#define ENABLE_SERIAL_DEBUG TRUE
|
||||
|
||||
#if ENABLE_SERIAL_DEBUG == TRUE
|
||||
#define LINE_USART3_TX LINE_IO_TXD
|
||||
#define LINE_USART3_RX LINE_IO_RXD
|
||||
#endif
|
||||
|
@ -199,7 +202,7 @@
|
|||
/* Definitions for ICU FIFO implemented using chfactory. */
|
||||
#if USE_HEAP_PWM_BUFFER == TRUE
|
||||
/* Use factory FIFO as stream control with separate chained PWM buffers. */
|
||||
#define NUMBER_PWM_FIFOS 3U
|
||||
#define NUMBER_PWM_FIFOS 5U
|
||||
/* Number of PWM data entries per queue object. */
|
||||
#define PWM_DATA_SLOTS 200
|
||||
/* Number of PWM queue objects in total. */
|
||||
|
|
|
@ -32,7 +32,7 @@ int main(void) {
|
|||
|
||||
chDbgAssert(pkt == true, "failed to init packet system");
|
||||
|
||||
/* Start serial diagnostic channels if selected. */
|
||||
/* Start serial debug channel(s) if selected. */
|
||||
pktSerialStart();
|
||||
|
||||
/*
|
||||
|
|
|
@ -136,7 +136,7 @@ const conf_t conf_flash_default = {
|
|||
.radio_conf = {
|
||||
.freq = FREQ_APRS_DYNAMIC,
|
||||
.mod = MOD_AFSK,
|
||||
.rssi = 0x2F
|
||||
.rssi = 0x3F
|
||||
},
|
||||
// APRS identity used in message responses if digipeat is not enabled
|
||||
.call = "VK2GJ-4",
|
||||
|
|
|
@ -322,7 +322,7 @@ void usb_cmd_time(BaseSequentialStream *chp, int argc, char *argv[]) {
|
|||
(void)argv;
|
||||
|
||||
if(argc > 0 && argc != 2) {
|
||||
shellUsage(chp, "time [YYYY:MM:DD HH:MM:SS]");
|
||||
shellUsage(chp, "time [YYYY-MM-DD HH:MM:SS]");
|
||||
return;
|
||||
}
|
||||
/* Read time from RTC. */
|
||||
|
@ -334,7 +334,10 @@ void usb_cmd_time(BaseSequentialStream *chp, int argc, char *argv[]) {
|
|||
time.hour, time.minute, time.day);
|
||||
return;
|
||||
}
|
||||
/* TODO: add error checking
|
||||
/*
|
||||
* TODO:
|
||||
* - add error checking of values.
|
||||
* - allow just date or time as parameter?
|
||||
*/
|
||||
struct tm cdate;
|
||||
struct tm ctime;
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
/*
|
||||
Aerospace Decoder - Copyright (C) 2018 Bob Anderson (VK2GJ)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Aerospace Decoder configuration definition and ChibiOS system includes. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#include "pktconf.h"
|
||||
|
||||
/**
|
||||
* @file dbguart.c
|
||||
* @brief Serial channels for debug.
|
||||
*
|
||||
* @addtogroup IODevices
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @} */
|
||||
/*
|
||||
Aerospace Decoder - Copyright (C) 2018 Bob Anderson (VK2GJ)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Aerospace Decoder configuration definition and ChibiOS system includes. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#include "pktconf.h"
|
||||
|
||||
/**
|
||||
* @file dbguart.c
|
||||
* @brief Serial channels for debug.
|
||||
*
|
||||
* @addtogroup IODevices
|
||||
* @{
|
||||
*/
|
||||
|
||||
binary_semaphore_t debug_out_sem;
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -1,145 +1,145 @@
|
|||
/*
|
||||
Aerospace Decoder - Copyright (C) 2018 Bob Anderson (VK2GJ)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ax25_dump.c
|
||||
* @brief Packet dump utility.
|
||||
*
|
||||
* @addtogroup DSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "pktconf.h"
|
||||
|
||||
/* Buffer and size params for serial terminal output. */
|
||||
char serial_buf[1024];
|
||||
int serial_out;
|
||||
|
||||
/* Access control semaphore. */
|
||||
extern binary_semaphore_t diag_out_sem;
|
||||
|
||||
void pktDumpAX25Frame(ax25char_t *frame_buffer,
|
||||
ax25size_t frame_size, ax25_select_t which) {
|
||||
if(which == AX25_DUMP_ALL || which == AX25_DUMP_RAW) {
|
||||
ax25size_t bufpos;
|
||||
ax25size_t bufpos_a = 0;
|
||||
/* Write out a buffer line as hex first. */
|
||||
for(bufpos = 0; bufpos < frame_size; bufpos++) {
|
||||
if((bufpos + 1) % DUMP_LINE_LENGTH == 0) {
|
||||
serial_out = chsnprintf(serial_buf, sizeof(serial_buf),
|
||||
"%02x\r\n", frame_buffer[bufpos]);
|
||||
pktWrite((uint8_t *)serial_buf, serial_out);
|
||||
/* Write out full line of converted ASCII under hex.*/
|
||||
bufpos_a = (bufpos + 1) - DUMP_LINE_LENGTH;
|
||||
do {
|
||||
char asciichar = frame_buffer[bufpos_a];
|
||||
if(asciichar == 0x7e) {
|
||||
asciichar = '^';
|
||||
} else {
|
||||
asciichar >>= 1;
|
||||
if(!((asciichar >= 0x70 && asciichar < 0x7a)
|
||||
|| (asciichar > 0x2f && asciichar < 0x3a)
|
||||
|| (asciichar > 0x40 && asciichar < 0x5b))) {
|
||||
asciichar = 0x20;
|
||||
} else if(asciichar >= 0x70 && asciichar < 0x7a) {
|
||||
asciichar &= 0x3f;
|
||||
}
|
||||
}
|
||||
if((bufpos_a + 1) % DUMP_LINE_LENGTH == 0) {
|
||||
serial_out = chsnprintf(serial_buf,
|
||||
sizeof(serial_buf),
|
||||
" %c\r\n", asciichar);
|
||||
} else {
|
||||
serial_out = chsnprintf(serial_buf,
|
||||
sizeof(serial_buf),
|
||||
" %c ", asciichar);
|
||||
}
|
||||
pktWrite((uint8_t *)serial_buf, serial_out);
|
||||
} while(bufpos_a++ < bufpos);
|
||||
} else {
|
||||
serial_out = chsnprintf(serial_buf, sizeof(serial_buf),
|
||||
"%02x ", frame_buffer[bufpos]);
|
||||
pktWrite((uint8_t *)serial_buf, serial_out);
|
||||
}
|
||||
} /* End for(bufpos = 0; bufpos < frame_size; bufpos++). */
|
||||
serial_out = chsnprintf(serial_buf, sizeof(serial_buf), "\r\n");
|
||||
pktWrite((uint8_t *)serial_buf, serial_out);
|
||||
/* Write out remaining partial line of converted ASCII under hex. */
|
||||
do {
|
||||
char asciichar = frame_buffer[bufpos_a];
|
||||
if(asciichar == 0x7e) {
|
||||
asciichar = '^';
|
||||
} else {
|
||||
asciichar >>= 1;
|
||||
if(!((asciichar >= 0x70 && asciichar < 0x7a)
|
||||
|| (asciichar > 0x2f && asciichar < 0x3a)
|
||||
|| (asciichar > 0x40 && asciichar < 0x5b))) {
|
||||
asciichar = 0x20;
|
||||
} else if(asciichar >= 0x70 && asciichar < 0x7a) {
|
||||
asciichar &= 0x3f;
|
||||
}
|
||||
}
|
||||
serial_out = chsnprintf(serial_buf, sizeof(serial_buf),
|
||||
" %c ", asciichar);
|
||||
pktWrite((uint8_t *)serial_buf, serial_out);
|
||||
} while(++bufpos_a < bufpos);
|
||||
serial_out = chsnprintf(serial_buf, sizeof(serial_buf), "\r\n");
|
||||
pktWrite((uint8_t *)serial_buf, serial_out);
|
||||
} /* End raw dump. */
|
||||
}
|
||||
|
||||
|
||||
void pktDiagnosticOutput(packet_svc_t *packetHandler,
|
||||
pkt_data_object_t *myPktFIFO) {
|
||||
chBSemWait(&diag_out_sem);
|
||||
/* Buffer and size params for serial terminal output. */
|
||||
char serial_buf[1024];
|
||||
int serial_out;
|
||||
|
||||
/* Packet buffer. */
|
||||
ax25char_t *frame_buffer = myPktFIFO->buffer;
|
||||
uint16_t frame_size = myPktFIFO->packet_size;
|
||||
|
||||
if(pktIsBufferValidAX25Frame(myPktFIFO)) {
|
||||
|
||||
uint16_t magicCRC = calc_crc16(frame_buffer, 0, frame_size);
|
||||
|
||||
float32_t good = (float32_t)packetHandler->good_count
|
||||
/ (float32_t)packetHandler->valid_count;
|
||||
serial_out = chsnprintf(serial_buf, sizeof(serial_buf),
|
||||
"AFSK... mode: %s, factory: %s, status: %x"
|
||||
", packet count: %u sync count: %u"
|
||||
" valid frames: %u"
|
||||
" good frames: %u (%.2f%%), bytes: %u"
|
||||
", CRCm: %04x\r\n",
|
||||
((packetHandler->usr_callback == NULL) ? "polling" : "callback"),
|
||||
packetHandler->pbuff_name,
|
||||
myPktFIFO->status,
|
||||
packetHandler->sync_count,
|
||||
packetHandler->frame_count,
|
||||
packetHandler->valid_count,
|
||||
packetHandler->good_count,
|
||||
(good * 100),
|
||||
frame_size,
|
||||
magicCRC
|
||||
);
|
||||
dbgWrite(DBG_INFO, (uint8_t *)serial_buf, serial_out);
|
||||
/* Dump the frame contents out. */
|
||||
pktDumpAX25Frame(frame_buffer, frame_size, AX25_DUMP_RAW);
|
||||
} else { /* End if valid frame. */
|
||||
serial_out = chsnprintf(serial_buf, sizeof(serial_buf),
|
||||
"Invalid frame, status %x, bytes %u\r\n",
|
||||
myPktFIFO->status, myPktFIFO->packet_size);
|
||||
dbgWrite(DBG_INFO, (uint8_t *)serial_buf, serial_out);
|
||||
}
|
||||
|
||||
chBSemSignal(&diag_out_sem);
|
||||
}
|
||||
|
||||
|
||||
/** @} */
|
||||
/*
|
||||
Aerospace Decoder - Copyright (C) 2018 Bob Anderson (VK2GJ)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ax25_dump.c
|
||||
* @brief Packet dump utility.
|
||||
*
|
||||
* @addtogroup DSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "pktconf.h"
|
||||
|
||||
/* Buffer and size params for serial terminal output. */
|
||||
char serial_buf[1024];
|
||||
int serial_out;
|
||||
|
||||
/* Access control semaphore. */
|
||||
extern binary_semaphore_t debug_out_sem;
|
||||
|
||||
void pktDumpAX25Frame(ax25char_t *frame_buffer,
|
||||
ax25size_t frame_size, ax25_select_t which) {
|
||||
if(which == AX25_DUMP_ALL || which == AX25_DUMP_RAW) {
|
||||
ax25size_t bufpos;
|
||||
ax25size_t bufpos_a = 0;
|
||||
/* Write out a buffer line as hex first. */
|
||||
for(bufpos = 0; bufpos < frame_size; bufpos++) {
|
||||
if((bufpos + 1) % DUMP_LINE_LENGTH == 0) {
|
||||
serial_out = chsnprintf(serial_buf, sizeof(serial_buf),
|
||||
"%02x\r\n", frame_buffer[bufpos]);
|
||||
pktWrite((uint8_t *)serial_buf, serial_out);
|
||||
/* Write out full line of converted ASCII under hex.*/
|
||||
bufpos_a = (bufpos + 1) - DUMP_LINE_LENGTH;
|
||||
do {
|
||||
char asciichar = frame_buffer[bufpos_a];
|
||||
if(asciichar == 0x7e) {
|
||||
asciichar = '^';
|
||||
} else {
|
||||
asciichar >>= 1;
|
||||
if(!((asciichar >= 0x70 && asciichar < 0x7a)
|
||||
|| (asciichar > 0x2f && asciichar < 0x3a)
|
||||
|| (asciichar > 0x40 && asciichar < 0x5b))) {
|
||||
asciichar = 0x20;
|
||||
} else if(asciichar >= 0x70 && asciichar < 0x7a) {
|
||||
asciichar &= 0x3f;
|
||||
}
|
||||
}
|
||||
if((bufpos_a + 1) % DUMP_LINE_LENGTH == 0) {
|
||||
serial_out = chsnprintf(serial_buf,
|
||||
sizeof(serial_buf),
|
||||
" %c\r\n", asciichar);
|
||||
} else {
|
||||
serial_out = chsnprintf(serial_buf,
|
||||
sizeof(serial_buf),
|
||||
" %c ", asciichar);
|
||||
}
|
||||
pktWrite((uint8_t *)serial_buf, serial_out);
|
||||
} while(bufpos_a++ < bufpos);
|
||||
} else {
|
||||
serial_out = chsnprintf(serial_buf, sizeof(serial_buf),
|
||||
"%02x ", frame_buffer[bufpos]);
|
||||
pktWrite((uint8_t *)serial_buf, serial_out);
|
||||
}
|
||||
} /* End for(bufpos = 0; bufpos < frame_size; bufpos++). */
|
||||
serial_out = chsnprintf(serial_buf, sizeof(serial_buf), "\r\n");
|
||||
pktWrite((uint8_t *)serial_buf, serial_out);
|
||||
/* Write out remaining partial line of converted ASCII under hex. */
|
||||
do {
|
||||
char asciichar = frame_buffer[bufpos_a];
|
||||
if(asciichar == 0x7e) {
|
||||
asciichar = '^';
|
||||
} else {
|
||||
asciichar >>= 1;
|
||||
if(!((asciichar >= 0x70 && asciichar < 0x7a)
|
||||
|| (asciichar > 0x2f && asciichar < 0x3a)
|
||||
|| (asciichar > 0x40 && asciichar < 0x5b))) {
|
||||
asciichar = 0x20;
|
||||
} else if(asciichar >= 0x70 && asciichar < 0x7a) {
|
||||
asciichar &= 0x3f;
|
||||
}
|
||||
}
|
||||
serial_out = chsnprintf(serial_buf, sizeof(serial_buf),
|
||||
" %c ", asciichar);
|
||||
pktWrite((uint8_t *)serial_buf, serial_out);
|
||||
} while(++bufpos_a < bufpos);
|
||||
serial_out = chsnprintf(serial_buf, sizeof(serial_buf), "\r\n");
|
||||
pktWrite((uint8_t *)serial_buf, serial_out);
|
||||
} /* End raw dump. */
|
||||
}
|
||||
|
||||
|
||||
void pktDiagnosticOutput(packet_svc_t *packetHandler,
|
||||
pkt_data_object_t *myPktFIFO) {
|
||||
chBSemWait(&debug_out_sem);
|
||||
/* Buffer and size params for serial terminal output. */
|
||||
char serial_buf[1024];
|
||||
int serial_out;
|
||||
|
||||
/* Packet buffer. */
|
||||
ax25char_t *frame_buffer = myPktFIFO->buffer;
|
||||
uint16_t frame_size = myPktFIFO->packet_size;
|
||||
|
||||
if(pktIsBufferValidAX25Frame(myPktFIFO)) {
|
||||
|
||||
uint16_t magicCRC = calc_crc16(frame_buffer, 0, frame_size);
|
||||
|
||||
float32_t good = (float32_t)packetHandler->good_count
|
||||
/ (float32_t)packetHandler->valid_count;
|
||||
serial_out = chsnprintf(serial_buf, sizeof(serial_buf),
|
||||
"AFSK... mode: %s, factory: %s, status: %x"
|
||||
", packet count: %u sync count: %u"
|
||||
" valid frames: %u"
|
||||
" good frames: %u (%.2f%%), bytes: %u"
|
||||
", CRCm: %04x\r\n",
|
||||
((packetHandler->usr_callback == NULL) ? "polling" : "callback"),
|
||||
packetHandler->pbuff_name,
|
||||
myPktFIFO->status,
|
||||
packetHandler->sync_count,
|
||||
packetHandler->frame_count,
|
||||
packetHandler->valid_count,
|
||||
packetHandler->good_count,
|
||||
(good * 100),
|
||||
frame_size,
|
||||
magicCRC
|
||||
);
|
||||
dbgWrite(DBG_INFO, (uint8_t *)serial_buf, serial_out);
|
||||
/* Dump the frame contents out. */
|
||||
pktDumpAX25Frame(frame_buffer, frame_size, AX25_DUMP_RAW);
|
||||
} else { /* End if valid frame. */
|
||||
serial_out = chsnprintf(serial_buf, sizeof(serial_buf),
|
||||
"Invalid frame, status %x, bytes %u\r\n",
|
||||
myPktFIFO->status, myPktFIFO->packet_size);
|
||||
dbgWrite(DBG_INFO, (uint8_t *)serial_buf, serial_out);
|
||||
}
|
||||
|
||||
chBSemSignal(&debug_out_sem);
|
||||
}
|
||||
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -25,8 +25,9 @@ void pktDisableEventTrace(radio_unit_t radio) {
|
|||
}
|
||||
|
||||
/*
|
||||
* TODO: Refactor and add severity categories filtering
|
||||
* Add packet service listener object per radio.
|
||||
* TODO:
|
||||
* - Refactor and add severity categories filtering
|
||||
* - Add packet service listener object per radio.
|
||||
*/
|
||||
void pktTraceEvents() {
|
||||
if(!trace_enabled)
|
||||
|
|
|
@ -24,4 +24,3 @@
|
|||
|
||||
packet_svc_t RPKTD1;
|
||||
|
||||
binary_semaphore_t diag_out_sem;
|
||||
|
|
Ładowanie…
Reference in New Issue