Wilson Tang
/
HSP_RPC_GUI
Fork of the offical HSP_RPC_GUI firmware
Fork of MAXREFDES100 firmware for MAX32620HSP
Diff: HSP/LoggingService/DataLoggingService.cpp
- Revision:
- 1:9490836294ea
- Parent:
- 0:e4a10ed6eb92
--- a/HSP/LoggingService/DataLoggingService.cpp Tue Oct 25 15:22:11 2016 +0000 +++ b/HSP/LoggingService/DataLoggingService.cpp Fri Apr 21 12:12:30 2017 -0500 @@ -31,6 +31,7 @@ ******************************************************************************* */ #include "mbed.h" +#include "USBSerial.h" #include "Logging.h" #include "Streaming.h" #include "RpcServer.h" @@ -90,6 +91,8 @@ } eStartEvent; static eStartEvent startEvent; +extern USBSerial *usbSerialPtr; + /** * @brief Sets a flag to start USB logging (streaming) */ @@ -173,7 +176,7 @@ * @brief Process a RPC command that is pointed to. * @param cmd RPC string to process */ -void ProcessCmd(char *cmd) { +void ProcessCmd(const char *cmd) { char cmd_[256]; char reply[512]; strcpy(cmd_, cmd); @@ -213,7 +216,7 @@ index = sramIndex - 256; ptr = &PingPong_SRAM[index]; - sprintf(str, "currentPage=%d", currentPage); + sprintf(str, "currentPage=%lu", currentPage); Peripherals::s25FS512()->writePage_Helper(currentPage, ptr, 0); // this page is no longer dirty @@ -240,7 +243,7 @@ if (sram_buffer_1_dirty == 1) { ptr += 256; } - printf("_LoggingServer_WriteDirtySramBufferToFlash:%d,%d\n", + printf("_LoggingServer_WriteDirtySramBufferToFlash:%lu,%lu\n", sram_buffer_0_dirty, sram_buffer_1_dirty); fflush(stdout); // s25fs512_WritePage_Helper(currentPage, ptr, 0); @@ -254,7 +257,7 @@ static void _LoggingServer_OutputToCdcAcm(uint32_t fifoData) { uint8_t *ptr; uint8_t str[16]; - sprintf((char *)str, "%X ", fifoData); + sprintf((char *)str, "%X ", (unsigned int)fifoData); ptr = str; usb_block_index = 0; while (*ptr != 0) { @@ -262,7 +265,7 @@ ptr++; usb_block_index++; } - Peripherals::usbSerial()->writeBlock(usb_block, usb_block_index); + usbSerialPtr->writeBlock(usb_block, usb_block_index); } /** @@ -285,14 +288,14 @@ // Log to CDCACM // result = true; - sprintf((char *)str, "%X ", fifoData); + sprintf((char *)str, "%X ", (unsigned int)fifoData); ptr = str; while (*ptr != 0) { usb_block[usb_block_index] = *ptr; ptr++; usb_block_index++; if (usb_block_index >= 64) { - result = Peripherals::usbSerial()->writeBlock(usb_block, 64); + result = usbSerialPtr->writeBlock(usb_block, 64); usb_block_index = 0; } } @@ -305,7 +308,7 @@ static void _LoggingServer_OutputToCdcAcm_End(void) { if (usb_block_index == 0) return; - Peripherals::usbSerial()->writeBlock(usb_block, usb_block_index - 1); + usbSerialPtr->writeBlock(usb_block, usb_block_index - 1); } /** @@ -363,7 +366,7 @@ uint8_t LoggingService_ServiceRoutine(void) { uint32_t fifoData; uint32_t endPage; - USBSerial *usbSerial = Peripherals::usbSerial(); + //USBSerial *usbSerial = Peripherals::usbSerial(); // BMP280 *bmp280 = Peripherals::bmp280(); bool buttonPressed; int packetBurstCount = 0; @@ -451,8 +454,8 @@ ServiceNonInterrupt_Init(); ServiceNonInterrupt_StartTimer(); - while (usbSerial->readable()) { - usbSerial->_getc(); + while (usbSerialPtr->readable()) { + usbSerialPtr->_getc(); } fifo_clear(GetUSBIncomingFifo()); // clear USB serial incoming fifo fifo_clear(GetStreamOutFifo()); @@ -461,10 +464,10 @@ sram_buffer_1_dirty = 0; - if (loggingOutput == eLogToNothing) printf("eLogToNothing..."); fflush(stdout); - if (loggingOutput == eLogToFlash) printf("eLogToFlash..."); fflush(stdout); - if (loggingOutput == eLogtoUsb) printf("eLogtoUsb..."); fflush(stdout); - printf("highDataRate=%d...",highDataRate); fflush(stdout); + if (loggingOutput == eLogToNothing) { printf("eLogToNothing..."); fflush(stdout); } + if (loggingOutput == eLogToFlash) { printf("eLogToFlash..."); fflush(stdout); } + if (loggingOutput == eLogtoUsb) { printf("eLogtoUsb..."); fflush(stdout); } + printf("highDataRate=%u...",(unsigned int)highDataRate); fflush(stdout); Peripherals::timestampTimer()->reset(); @@ -474,6 +477,7 @@ while (1) { if (loggingOutput == eLogToFlash) { // check if we are at the end of flash + endPage = Logging_GetLoggingEndPage(); if (currentPage >= endPage) { BlinkEndOfDatalogging(); // blink for 3 seconds to signal end of logging break; @@ -502,13 +506,13 @@ if (startEvent == eStartEvent_RPC_TO_USB || startEvent == eStartEvent_RPC_TO_FLASH) { - if (usbSerial->available()) { + if (usbSerialPtr->available()) { if (loggingOutput == eLogToFlash) { _LoggingServer_WriteDirtySramBufferToFlash(); } wait(0.2f); - while (usbSerial->available()) { - usbSerial->_getc(); + while (usbSerialPtr->available()) { + usbSerialPtr->_getc(); } fifo_clear(GetUSBIncomingFifo()); // clear USB serial incoming fifo fifo_clear(GetStreamOutFifo());