Logging facility for endpoints

Fork of ErrorHandler by Doug Anson

Committer:
ansond
Date:
Tue Sep 23 16:56:15 2014 +0000
Revision:
8:cc73ab137ae9
Parent:
7:4844475a4135
Child:
9:cec063a0b9a9
doxygened

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 0:906788c5813d 1 /* Copyright C2014 ARM, MIT License
ansond 0:906788c5813d 2 *
ansond 0:906788c5813d 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
ansond 0:906788c5813d 4 * and associated documentation files the "Software", to deal in the Software without restriction,
ansond 0:906788c5813d 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
ansond 0:906788c5813d 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
ansond 0:906788c5813d 7 * furnished to do so, subject to the following conditions:
ansond 0:906788c5813d 8 *
ansond 0:906788c5813d 9 * The above copyright notice and this permission notice shall be included in all copies or
ansond 0:906788c5813d 10 * substantial portions of the Software.
ansond 0:906788c5813d 11 *
ansond 0:906788c5813d 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
ansond 0:906788c5813d 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
ansond 0:906788c5813d 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
ansond 0:906788c5813d 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ansond 0:906788c5813d 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ansond 0:906788c5813d 17 */
ansond 0:906788c5813d 18
ansond 0:906788c5813d 19 #ifndef _ERROR_HANDLER_H_
ansond 0:906788c5813d 20 #define _ERROR_HANDLER_H_
ansond 0:906788c5813d 21
ansond 0:906788c5813d 22 // our definitions
ansond 0:906788c5813d 23 #include "Definitions.h"
ansond 0:906788c5813d 24
ansond 7:4844475a4135 25 // biggest log message length
ansond 7:4844475a4135 26 #define MAX_LOG_MESSAGE_PREFIX 128
ansond 7:4844475a4135 27 #define MAX_LOG_MESSAGE (MAX_BUFFER_LENGTH+MAX_LOG_MESSAGE_PREFIX+1)
ansond 7:4844475a4135 28
ansond 0:906788c5813d 29 // Support for varargs
ansond 0:906788c5813d 30 #include <stdarg.h>
ansond 0:906788c5813d 31
ansond 0:906788c5813d 32 // LCD Support
ansond 0:906788c5813d 33 #if _UBLOX_PLATFORM
ansond 0:906788c5813d 34 #include "C12832.h"
ansond 0:906788c5813d 35 #define LCDCLASS C12832
ansond 0:906788c5813d 36 #endif
ansond 0:906788c5813d 37
ansond 0:906788c5813d 38 #if _NXP_PLATFORM
ansond 0:906788c5813d 39 #include "C12832_lcd.h"
ansond 0:906788c5813d 40 #define LCDCLASS C12832_LCD
ansond 0:906788c5813d 41 #endif
ansond 1:8d42444464d3 42
ansond 2:e771ffdf5c1b 43 #if _K64F_PLATFORM
ansond 2:e771ffdf5c1b 44 #define LCDCLASS void // not used
ansond 2:e771ffdf5c1b 45 #endif
ansond 2:e771ffdf5c1b 46
ansond 8:cc73ab137ae9 47 /**
ansond 8:cc73ab137ae9 48 ErrorHandler
ansond 8:cc73ab137ae9 49 Error handling class for mbed endpoints
ansond 8:cc73ab137ae9 50 */
ansond 0:906788c5813d 51 class ErrorHandler {
ansond 0:906788c5813d 52 private:
ansond 5:7b3bbd74c1b1 53 RawSerial *m_pc;
ansond 5:7b3bbd74c1b1 54 LCDCLASS *m_lcd;
ansond 5:7b3bbd74c1b1 55 char m_message[MAX_LOG_MESSAGE+1];
ansond 0:906788c5813d 56
ansond 0:906788c5813d 57 public:
ansond 8:cc73ab137ae9 58 /**
ansond 8:cc73ab137ae9 59 Default constructor
ansond 8:cc73ab137ae9 60 @param pc RawSerial instance
ansond 8:cc73ab137ae9 61 @param lcd LCDCLASS instance (or NULL)
ansond 8:cc73ab137ae9 62 */
ansond 5:7b3bbd74c1b1 63 ErrorHandler(RawSerial *pc,LCDCLASS *lcd);
ansond 8:cc73ab137ae9 64
ansond 8:cc73ab137ae9 65 /**
ansond 8:cc73ab137ae9 66 Default destructor
ansond 8:cc73ab137ae9 67 */
ansond 0:906788c5813d 68 virtual ~ErrorHandler();
ansond 0:906788c5813d 69
ansond 8:cc73ab137ae9 70 /**
ansond 8:cc73ab137ae9 71 log message to the serial console and LCD (if enabled)
ansond 8:cc73ab137ae9 72 @param format variable argument format
ansond 8:cc73ab137ae9 73 */
ansond 0:906788c5813d 74 void log(const char *format, ...);
ansond 8:cc73ab137ae9 75
ansond 8:cc73ab137ae9 76 /**
ansond 8:cc73ab137ae9 77 log message to the serial console only
ansond 8:cc73ab137ae9 78 @param format variable argument format
ansond 8:cc73ab137ae9 79 */
ansond 6:be3ca195f0d1 80 void logConsole(const char *format, ...);
ansond 0:906788c5813d 81
ansond 8:cc73ab137ae9 82 /**
ansond 8:cc73ab137ae9 83 turn the multi-colored LED red
ansond 8:cc73ab137ae9 84 */
ansond 0:906788c5813d 85 void turnLEDRed();
ansond 8:cc73ab137ae9 86
ansond 8:cc73ab137ae9 87 /**
ansond 8:cc73ab137ae9 88 turn the multi-colored LED green
ansond 8:cc73ab137ae9 89 */
ansond 0:906788c5813d 90 void turnLEDGreen();
ansond 8:cc73ab137ae9 91
ansond 8:cc73ab137ae9 92 /**
ansond 8:cc73ab137ae9 93 turn the multi-colored LED blue
ansond 8:cc73ab137ae9 94 */
ansond 0:906788c5813d 95 void turnLEDBlue();
ansond 8:cc73ab137ae9 96
ansond 8:cc73ab137ae9 97 /**
ansond 8:cc73ab137ae9 98 turn the multi-colored LED purple
ansond 8:cc73ab137ae9 99 */
ansond 0:906788c5813d 100 void turnLEDPurple();
ansond 8:cc73ab137ae9 101
ansond 8:cc73ab137ae9 102 /**
ansond 8:cc73ab137ae9 103 turn the multi-colored LED black
ansond 8:cc73ab137ae9 104 */
ansond 0:906788c5813d 105 void turnLEDBlack();
ansond 8:cc73ab137ae9 106
ansond 8:cc73ab137ae9 107 /**
ansond 8:cc73ab137ae9 108 turn the multi-colored LED yellow
ansond 8:cc73ab137ae9 109 */
ansond 0:906788c5813d 110 void turnLEDYellow();
ansond 8:cc73ab137ae9 111
ansond 8:cc73ab137ae9 112 /**
ansond 8:cc73ab137ae9 113 turn the multi-colored LED orange
ansond 8:cc73ab137ae9 114 */
ansond 0:906788c5813d 115 void turnLEDOrange();
ansond 0:906788c5813d 116
ansond 8:cc73ab137ae9 117 /**
ansond 8:cc73ab137ae9 118 blink the transmit LED
ansond 8:cc73ab137ae9 119 */
ansond 1:8d42444464d3 120 void blinkTransportTxLED();
ansond 8:cc73ab137ae9 121
ansond 8:cc73ab137ae9 122 /**
ansond 8:cc73ab137ae9 123 blink the receiver LED
ansond 8:cc73ab137ae9 124 */
ansond 1:8d42444464d3 125 void blinkTransportRxLED();
ansond 1:8d42444464d3 126
ansond 0:906788c5813d 127 private:
ansond 0:906788c5813d 128 void setRGBLED(float H, float S, float V);
ansond 1:8d42444464d3 129 void blinkLED(DigitalOut led);
ansond 0:906788c5813d 130 };
ansond 0:906788c5813d 131
ansond 0:906788c5813d 132 #endif // _ERROR_HANDLER_H_