diff --git a/tracker/software/main.c b/tracker/software/main.c index 5f2d4dbc..f64eeb2b 100644 --- a/tracker/software/main.c +++ b/tracker/software/main.c @@ -16,7 +16,7 @@ int main(void) { pktConfigureCoreIO(); /* Setup the mutex for trace output. */ - //DEBUG_INIT(); + debug_init(); #if ACTIVATE_CONSOLE /* Start console. */ @@ -33,7 +33,7 @@ int main(void) { chDbgAssert(pkt == true, "failed to init packet system"); /* Start serial debug channel(s) if selected. */ - pktSerialStart(); + //pktSerialStart(); /* * Create a packet radio service. diff --git a/tracker/software/source/config/config.c b/tracker/software/source/config/config.c index 0c99f256..1dc9b238 100644 --- a/tracker/software/source/config/config.c +++ b/tracker/software/source/config/config.c @@ -14,8 +14,8 @@ const conf_t conf_flash_default = { .pos_pri = { .beacon = { .active = true, - .cycle = TIME_S2I(120), - .init_delay = TIME_S2I(0), + .cycle = TIME_S2I(30), + .init_delay = TIME_S2I(5), .fixed = false // Add lat, lon, alt fields when enabling fixed }, .radio_conf = { @@ -49,24 +49,24 @@ const conf_t conf_flash_default = { .cca = 0x4F }, // App identity - .call = "DL7AD-5", - .path = "WIDE2-1", - .symbol = SYM_DIGIPEATER, - .aprs_msg = false, // Enable APRS message reception on this app + .call = "DL7AD-12", + .path = "WIDE1-1", + .symbol = SYM_BALLOON, + .aprs_msg = true, // Enable APRS message reception on this app }, // Primary image app .img_pri = { .svc_conf = { - .active = true, + .active = false, .cycle = CYCLE_CONTINUOUSLY, .init_delay = TIME_S2I(30), .send_spacing = TIME_S2I(10) }, .radio_conf = { .pwr = 0x7F, - .freq = FREQ_GEOFENCE, - .mod = MOD_AFSK, + .freq = 144860000, + .mod = MOD_2FSK, .cca = 0x5F }, @@ -75,7 +75,7 @@ const conf_t conf_flash_default = { .path = "", // Image settings - .res = RES_QVGA, + .res = RES_VGA, .quality = 4, .buf_size = 50 * 1024, .redundantTx = false @@ -85,15 +85,15 @@ const conf_t conf_flash_default = { .img_sec = { .svc_conf = { .active = false, - .cycle = TIME_S2I(60 * 15), - .init_delay = TIME_S2I(15 * 1), - .send_spacing = TIME_S2I(2) + .cycle = CYCLE_CONTINUOUSLY, + .init_delay = TIME_S2I(60), + .send_spacing = TIME_S2I(10) }, .radio_conf = { - .pwr = 0x1F, - .freq = FREQ_APRS_AUSTRALIA, - .mod = MOD_AFSK, - .cca = 0x4F + .pwr = 0x7F, + .freq = 144860000, + .mod = MOD_2FSK, + .cca = 0x5F }, // App identity .call = "DL7AD-12", @@ -133,32 +133,32 @@ const conf_t conf_flash_default = { // The packet receive service is enabled if true // Receive is paused and resumed by transmission .active = false, - .init_delay = TIME_S2I(20) + .init_delay = TIME_S2I(5) }, // Receive radio configuration .radio_conf = { .freq = FREQ_GEOFENCE, .mod = MOD_AFSK, - .rssi = 0x3F + .rssi = 0x5F }, // APRS identity used in message responses if digipeat is not enabled - .call = "DL7AD-4", - .symbol = SYM_ANTENNA + .call = "DL7AD-15", + .symbol = SYM_BALLOON }, - .aprs_msg = false, // Set true to enable messages to be accepted on RX call sign - .digi = false, + .aprs_msg = true, // Set true to enable messages to be accepted on RX call sign + .digi = true, .tx = { // Transmit radio configuration .radio_conf = { .freq = FREQ_RX_APRS, .pwr = 0x7F, .mod = MOD_AFSK, - .cca = 0x4F + .cca = 0x5F }, // Digipeat transmission identity - .call = "DL7AD-5", - .path = "WIDE2-1", - .symbol = SYM_DIGIPEATER, + .call = "DL7AD-15", + .path = "WIDE1-1", + .symbol = SYM_BALLOON, // A digipeater beacon can be added using one of the POS apps // Set the POS identity the same as the dipipeater TX identity // Alternatively the digipeater can have its own .beacon entry here @@ -169,9 +169,9 @@ const conf_t conf_flash_default = { // Power control .keep_cam_switched_on = false, - .gps_on_vbat = 3600, // mV - .gps_off_vbat = 3400, // mV - .gps_onper_vbat = 4000, // mV + .gps_on_vbat = 3300, // mV + .gps_off_vbat = 3000, // mV + .gps_onper_vbat = 3500, // mV // GPS altitude model control (air pressure controlled using on-board BME280) .gps_pressure = 90000, // Air pressure (Pa) threshold for alt model switch @@ -180,7 +180,7 @@ const conf_t conf_flash_default = { // APRS // How often to send telemetry config (global for beacons) - .tel_enc_cycle = TIME_S2I(60 * 60 * 2), + .tel_enc_cycle = TIME_S2I(3600), // The default APRS frequency when geofence is not resolved .freq = FREQ_APRS_EUROPE, diff --git a/tracker/software/source/drivers/usb/debug.c b/tracker/software/source/drivers/usb/debug.c index 3d46cb0e..8ab32465 100644 --- a/tracker/software/source/drivers/usb/debug.c +++ b/tracker/software/source/drivers/usb/debug.c @@ -1,15 +1,69 @@ #include "ch.h" #include "hal.h" #include "debug.h" +#include "portab.h" -//mutex_t trace_mtx; // Used internal to synchronize multiple chprintf in debug.h +mutex_t mtx; // Used internal to synchronize multiple chprintf in debug.h char error_list[ERROR_LIST_SIZE][ERROR_LIST_LENGTH]; uint8_t error_counter; +static const SerialConfig debug_config = { + 115200, + 0, + 0, + 0 +}; + #ifdef USB_TRACE_LEVEL uint8_t usb_trace_level = USB_TRACE_LEVEL; // Set in makefile UDEFS #else uint8_t usb_trace_level = 2; // Level: Errors + Warnings #endif + +void debug_init(void) { + chMtxObjectInit(&mtx); + + sdStart(&SD3, &debug_config); + palSetLineMode(LINE_IO_TXD, PAL_MODE_ALTERNATE(7)); + palSetLineMode(LINE_IO_RXD, PAL_MODE_ALTERNATE(7)); +} + +void debug_print(char *type, char* filename, uint32_t line, char* format, ...) +{ + chMtxLock(&mtx); + + if(isConsoleOutputAvailable()) { + if(TRACE_TIME) { + chprintf((BaseSequentialStream*)&SDU1, "[%8d.%03d]", chVTGetSystemTime()/CH_CFG_ST_FREQUENCY, (chVTGetSystemTime()*1000/CH_CFG_ST_FREQUENCY)%1000); + } + chprintf((BaseSequentialStream*)&SDU1, "[%s]", type); + if(TRACE_FILE) { + chprintf((BaseSequentialStream*)&SDU1, "[%12s %04d]", filename, line); + } + chprintf((BaseSequentialStream*)&SDU1, " "); + va_list args; + va_start(args, format); + chprintf((BaseSequentialStream*)&SDU1, (format), args); + va_end(args); + chprintf((BaseSequentialStream*)&SDU1, "\r\n"); + } + + if(TRACE_TIME) { + chprintf((BaseSequentialStream*)&SD3, "[%8d.%03d]", chVTGetSystemTime()/CH_CFG_ST_FREQUENCY, (chVTGetSystemTime()*1000/CH_CFG_ST_FREQUENCY)%1000); + } + chprintf((BaseSequentialStream*)&SD3, "[%s]", type); + if(TRACE_FILE) { + chprintf((BaseSequentialStream*)&SD3, "[%12s %04d]", filename, line); + } + chprintf((BaseSequentialStream*)&SD3, " "); + va_list args; + va_start(args, format); + chprintf((BaseSequentialStream*)&SD3, (format), args); + va_end(args); + chprintf((BaseSequentialStream*)&SD3, "\r\n"); + + chMtxUnlock(&mtx); +} + diff --git a/tracker/software/source/drivers/usb/debug.h b/tracker/software/source/drivers/usb/debug.h index 86965230..ed4bbeca 100644 --- a/tracker/software/source/drivers/usb/debug.h +++ b/tracker/software/source/drivers/usb/debug.h @@ -17,40 +17,15 @@ extern char error_list[ERROR_LIST_SIZE][ERROR_LIST_LENGTH]; extern uint8_t error_counter; -extern mutex_t trace_mtx; -extern const SerialConfig uart_config; extern uint8_t usb_trace_level; -// Initializer for serial debug and LEDs -/* -#define DEBUG_INIT() { \ - chMtxObjectInit(&trace_mtx); \ -} -*/ - -#define TRACE_BASE(format, type, args...) { \ - if(isConsoleOutputAvailable()) { \ - if(TRACE_TIME) { \ - chprintf((BaseSequentialStream*)&SDU1, "[%8d.%03d]", chVTGetSystemTime()/CH_CFG_ST_FREQUENCY, (chVTGetSystemTime()*1000/CH_CFG_ST_FREQUENCY)%1000); \ - } \ - chprintf((BaseSequentialStream*)&SDU1, "[%s]", type); \ - if(TRACE_FILE) { \ - chprintf((BaseSequentialStream*)&SDU1, "[%12s %04d]", __FILENAME__, __LINE__); \ - } \ - chprintf((BaseSequentialStream*)&SDU1, " "); \ - chprintf((BaseSequentialStream*)&SDU1, (format), ##args); \ - chprintf((BaseSequentialStream*)&SDU1, "\r\n"); \ - chThdSleep(TIME_MS2I(10)); \ - } \ -} - -#define TRACE_DEBUG(format, args...) if(usb_trace_level > 4) { TRACE_BASE(format, "DEBUG", ##args) } -#define TRACE_INFO(format, args...) if(usb_trace_level > 3) { TRACE_BASE(format, " ", ##args) } -#define TRACE_MON(format, args...) if(usb_trace_level > 2) { TRACE_BASE(format, " ", ##args) } -#define TRACE_WARN(format, args...) if(usb_trace_level > 1) { TRACE_BASE(format, "WARN ", ##args) } +#define TRACE_DEBUG(format, args...) if(usb_trace_level > 4) { debug_print("DEBUG", __FILENAME__, __LINE__, format, ##args); } +#define TRACE_INFO(format, args...) if(usb_trace_level > 3) { debug_print(" ", __FILENAME__, __LINE__, format, ##args); } +#define TRACE_MON(format, args...) if(usb_trace_level > 2) { debug_print(" ", __FILENAME__, __LINE__, format, ##args); } +#define TRACE_WARN(format, args...) if(usb_trace_level > 1) { debug_print("WARN ", __FILENAME__, __LINE__, format, ##args); } #define TRACE_ERROR(format, args...) { \ if(usb_trace_level > 0) { \ - TRACE_BASE(format, "ERROR", ##args); \ + debug_print("ERROR", __FILENAME__, __LINE__, format, ##args); \ } \ \ uint8_t strcnt = chsnprintf(error_list[error_counter], ERROR_LIST_LENGTH, "[%8d.%03d] ", chVTGetSystemTime()/CH_CFG_ST_FREQUENCY, (chVTGetSystemTime()*1000/CH_CFG_ST_FREQUENCY)%1000); \ @@ -68,28 +43,6 @@ extern uint8_t usb_trace_level; #define TRACE_TAB " " #endif -/* -#define TRACE_BIN(data, len) { \ - chMtxLock(&trace_mtx); \ - chprintf((BaseSequentialStream*)&SD3, "[%8d.%03d][DEBUG] ", chVTGetSystemTime()/CH_CFG_ST_FREQUENCY, (chVTGetSystemTime()*1000/CH_CFG_ST_FREQUENCY)%1000); \ - chprintf((BaseSequentialStream*)&SD3, " > Binary data (%d bits)\r\n", (len)); \ - for(uint32_t i=0; i<((len)+7)/8; i+=8) \ - chprintf((BaseSequentialStream*)&SD3, "%s 0x%03x ... 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\r\n", \ - TRACE_TAB, i, (data)[i], (data)[i+1], (data)[i+2], (data)[i+3], (data)[i+4], (data)[i+5], (data)[i+6], (data)[i+7]); \ - chMtxUnlock(&trace_mtx); \ -} - -#define TRACE_BIN_CHAR(data, len) { \ - chMtxLock(&trace_mtx); \ - chprintf((BaseSequentialStream*)&SD3, "[%8d.%03d][DEBUG] ", chVTGetSystemTime()/CH_CFG_ST_FREQUENCY, (chVTGetSystemTime()*1000/CH_CFG_ST_FREQUENCY)%1000); \ - chprintf((BaseSequentialStream*)&SD3, " > Binary data (%d bits)\r\n", (len)); \ - for(uint32_t i=0; i<((len)+7)/8; i+=8) \ - chprintf((BaseSequentialStream*)&SD3, "%s %c%c%c%c%c%c%c%c\r\n", \ - TRACE_TAB, i, (data)[i], (data)[i+1], (data)[i+2], (data)[i+3], (data)[i+4], (data)[i+5], (data)[i+6], (data)[i+7]); \ - chMtxUnlock(&trace_mtx); \ -} -*/ - /* #if USE_CCM_FOR_PKT_POOL == TRUE @@ -110,5 +63,8 @@ static inline heap_header_t *pktSystemCheck(void) { } #endif +void debug_init(void); +void debug_print(char *type, char* filename, uint32_t line, char* format, ...); + #endif /* __TRACE_H__ */