Logging facility for endpoints
Fork of ErrorHandler by
ErrorHandler.h@9:cec063a0b9a9, 2014-09-24 (annotated)
- Committer:
- ansond
- Date:
- Wed Sep 24 04:12:51 2014 +0000
- Revision:
- 9:cec063a0b9a9
- Parent:
- 8:cc73ab137ae9
updates for mbed app shield
Who changed what in which revision?
User | Revision | Line number | New 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 | 9:cec063a0b9a9 | 44 | #include "C12832.h" |
ansond | 9:cec063a0b9a9 | 45 | #define LCDCLASS C12832 // not used |
ansond | 2:e771ffdf5c1b | 46 | #endif |
ansond | 2:e771ffdf5c1b | 47 | |
ansond | 8:cc73ab137ae9 | 48 | /** |
ansond | 8:cc73ab137ae9 | 49 | ErrorHandler |
ansond | 8:cc73ab137ae9 | 50 | Error handling class for mbed endpoints |
ansond | 8:cc73ab137ae9 | 51 | */ |
ansond | 0:906788c5813d | 52 | class ErrorHandler { |
ansond | 0:906788c5813d | 53 | private: |
ansond | 5:7b3bbd74c1b1 | 54 | RawSerial *m_pc; |
ansond | 5:7b3bbd74c1b1 | 55 | LCDCLASS *m_lcd; |
ansond | 5:7b3bbd74c1b1 | 56 | char m_message[MAX_LOG_MESSAGE+1]; |
ansond | 0:906788c5813d | 57 | |
ansond | 0:906788c5813d | 58 | public: |
ansond | 8:cc73ab137ae9 | 59 | /** |
ansond | 8:cc73ab137ae9 | 60 | Default constructor |
ansond | 8:cc73ab137ae9 | 61 | @param pc RawSerial instance |
ansond | 8:cc73ab137ae9 | 62 | @param lcd LCDCLASS instance (or NULL) |
ansond | 8:cc73ab137ae9 | 63 | */ |
ansond | 5:7b3bbd74c1b1 | 64 | ErrorHandler(RawSerial *pc,LCDCLASS *lcd); |
ansond | 8:cc73ab137ae9 | 65 | |
ansond | 8:cc73ab137ae9 | 66 | /** |
ansond | 8:cc73ab137ae9 | 67 | Default destructor |
ansond | 8:cc73ab137ae9 | 68 | */ |
ansond | 0:906788c5813d | 69 | virtual ~ErrorHandler(); |
ansond | 0:906788c5813d | 70 | |
ansond | 8:cc73ab137ae9 | 71 | /** |
ansond | 8:cc73ab137ae9 | 72 | log message to the serial console and LCD (if enabled) |
ansond | 8:cc73ab137ae9 | 73 | @param format variable argument format |
ansond | 8:cc73ab137ae9 | 74 | */ |
ansond | 0:906788c5813d | 75 | void log(const char *format, ...); |
ansond | 8:cc73ab137ae9 | 76 | |
ansond | 8:cc73ab137ae9 | 77 | /** |
ansond | 8:cc73ab137ae9 | 78 | log message to the serial console only |
ansond | 8:cc73ab137ae9 | 79 | @param format variable argument format |
ansond | 8:cc73ab137ae9 | 80 | */ |
ansond | 6:be3ca195f0d1 | 81 | void logConsole(const char *format, ...); |
ansond | 0:906788c5813d | 82 | |
ansond | 8:cc73ab137ae9 | 83 | /** |
ansond | 8:cc73ab137ae9 | 84 | turn the multi-colored LED red |
ansond | 8:cc73ab137ae9 | 85 | */ |
ansond | 0:906788c5813d | 86 | void turnLEDRed(); |
ansond | 8:cc73ab137ae9 | 87 | |
ansond | 8:cc73ab137ae9 | 88 | /** |
ansond | 8:cc73ab137ae9 | 89 | turn the multi-colored LED green |
ansond | 8:cc73ab137ae9 | 90 | */ |
ansond | 0:906788c5813d | 91 | void turnLEDGreen(); |
ansond | 8:cc73ab137ae9 | 92 | |
ansond | 8:cc73ab137ae9 | 93 | /** |
ansond | 8:cc73ab137ae9 | 94 | turn the multi-colored LED blue |
ansond | 8:cc73ab137ae9 | 95 | */ |
ansond | 0:906788c5813d | 96 | void turnLEDBlue(); |
ansond | 8:cc73ab137ae9 | 97 | |
ansond | 8:cc73ab137ae9 | 98 | /** |
ansond | 8:cc73ab137ae9 | 99 | turn the multi-colored LED purple |
ansond | 8:cc73ab137ae9 | 100 | */ |
ansond | 0:906788c5813d | 101 | void turnLEDPurple(); |
ansond | 8:cc73ab137ae9 | 102 | |
ansond | 8:cc73ab137ae9 | 103 | /** |
ansond | 8:cc73ab137ae9 | 104 | turn the multi-colored LED black |
ansond | 8:cc73ab137ae9 | 105 | */ |
ansond | 0:906788c5813d | 106 | void turnLEDBlack(); |
ansond | 8:cc73ab137ae9 | 107 | |
ansond | 8:cc73ab137ae9 | 108 | /** |
ansond | 8:cc73ab137ae9 | 109 | turn the multi-colored LED yellow |
ansond | 8:cc73ab137ae9 | 110 | */ |
ansond | 0:906788c5813d | 111 | void turnLEDYellow(); |
ansond | 8:cc73ab137ae9 | 112 | |
ansond | 8:cc73ab137ae9 | 113 | /** |
ansond | 8:cc73ab137ae9 | 114 | turn the multi-colored LED orange |
ansond | 8:cc73ab137ae9 | 115 | */ |
ansond | 0:906788c5813d | 116 | void turnLEDOrange(); |
ansond | 0:906788c5813d | 117 | |
ansond | 8:cc73ab137ae9 | 118 | /** |
ansond | 8:cc73ab137ae9 | 119 | blink the transmit LED |
ansond | 8:cc73ab137ae9 | 120 | */ |
ansond | 1:8d42444464d3 | 121 | void blinkTransportTxLED(); |
ansond | 8:cc73ab137ae9 | 122 | |
ansond | 8:cc73ab137ae9 | 123 | /** |
ansond | 8:cc73ab137ae9 | 124 | blink the receiver LED |
ansond | 8:cc73ab137ae9 | 125 | */ |
ansond | 1:8d42444464d3 | 126 | void blinkTransportRxLED(); |
ansond | 1:8d42444464d3 | 127 | |
ansond | 0:906788c5813d | 128 | private: |
ansond | 0:906788c5813d | 129 | void setRGBLED(float H, float S, float V); |
ansond | 1:8d42444464d3 | 130 | void blinkLED(DigitalOut led); |
ansond | 0:906788c5813d | 131 | }; |
ansond | 0:906788c5813d | 132 | |
ansond | 0:906788c5813d | 133 | #endif // _ERROR_HANDLER_H_ |