Serial Monitor using a specific PC application: XMON
XMONlib.h@0:ad2d25216a13, 2012-06-28 (annotated)
- Committer:
- clemente
- Date:
- Thu Jun 28 10:20:45 2012 +0000
- Revision:
- 0:ad2d25216a13
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
clemente | 0:ad2d25216a13 | 1 | /* mbed XMON library. |
clemente | 0:ad2d25216a13 | 2 | * |
clemente | 0:ad2d25216a13 | 3 | * XMON Micro controller serial port debugger variable view realtime curve tracer |
clemente | 0:ad2d25216a13 | 4 | * http://webx.dk/XMON/index.htm |
clemente | 0:ad2d25216a13 | 5 | * |
clemente | 0:ad2d25216a13 | 6 | * XMON is a windows program that show and plot value received fomr the serial port. |
clemente | 0:ad2d25216a13 | 7 | * This is the banner from the XMON documentation: |
clemente | 0:ad2d25216a13 | 8 | * // XMON 2.1 ALPHA (autoscaling on/off/min/max) 15 feb 2008 |
clemente | 0:ad2d25216a13 | 9 | * // XMON is a free utility for monitoring and communication with MCU development |
clemente | 0:ad2d25216a13 | 10 | * // Made by DZL (help ideas support testing TST) |
clemente | 0:ad2d25216a13 | 11 | * // if this program help you and you are happy to use it, please donate a fee to thomas@webx.dk via paypal |
clemente | 0:ad2d25216a13 | 12 | * // any donation will be put into improving XMON, any size of donation small or big will be most appliciated. |
clemente | 0:ad2d25216a13 | 13 | * // suggestions and bugs to thomas@webx.dk |
clemente | 0:ad2d25216a13 | 14 | * // we will setup a homepage with features and tips and tricks and so on soon, see webx.dk and dzl.dk |
clemente | 0:ad2d25216a13 | 15 | * |
clemente | 0:ad2d25216a13 | 16 | * Copyright (c) 2011 NXP 3786 |
clemente | 0:ad2d25216a13 | 17 | * |
clemente | 0:ad2d25216a13 | 18 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
clemente | 0:ad2d25216a13 | 19 | * of this software and associated documentation files (the "Software"), to deal |
clemente | 0:ad2d25216a13 | 20 | * in the Software without restriction, including without limitation the rights |
clemente | 0:ad2d25216a13 | 21 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
clemente | 0:ad2d25216a13 | 22 | * copies of the Software, and to permit persons to whom the Software is |
clemente | 0:ad2d25216a13 | 23 | * furnished to do so, subject to the following conditions: |
clemente | 0:ad2d25216a13 | 24 | * |
clemente | 0:ad2d25216a13 | 25 | * The above copyright notice and this permission notice shall be included in |
clemente | 0:ad2d25216a13 | 26 | * all copies or substantial portions of the Software. |
clemente | 0:ad2d25216a13 | 27 | * |
clemente | 0:ad2d25216a13 | 28 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
clemente | 0:ad2d25216a13 | 29 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
clemente | 0:ad2d25216a13 | 30 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
clemente | 0:ad2d25216a13 | 31 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
clemente | 0:ad2d25216a13 | 32 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
clemente | 0:ad2d25216a13 | 33 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
clemente | 0:ad2d25216a13 | 34 | * THE SOFTWARE. |
clemente | 0:ad2d25216a13 | 35 | */ |
clemente | 0:ad2d25216a13 | 36 | |
clemente | 0:ad2d25216a13 | 37 | #ifndef __MBED_XMONLIB_H |
clemente | 0:ad2d25216a13 | 38 | #define __MBED_XMONLIB_H |
clemente | 0:ad2d25216a13 | 39 | |
clemente | 0:ad2d25216a13 | 40 | #include "mbed.h" |
clemente | 0:ad2d25216a13 | 41 | |
clemente | 0:ad2d25216a13 | 42 | #define XMON_AUTO_SCALE_OFF 0 |
clemente | 0:ad2d25216a13 | 43 | #define XMON_AUTO_SCALE_ON 1 |
clemente | 0:ad2d25216a13 | 44 | #define XMON_RED 0 // Colors of the PLOT GRAPHS |
clemente | 0:ad2d25216a13 | 45 | #define XMON_GREEN 1 |
clemente | 0:ad2d25216a13 | 46 | #define XMON_BLUE 2 |
clemente | 0:ad2d25216a13 | 47 | #define XMON_YELLOW 3 |
clemente | 0:ad2d25216a13 | 48 | |
clemente | 0:ad2d25216a13 | 49 | /** XMON Micro controller serial port debugger |
clemente | 0:ad2d25216a13 | 50 | * |
clemente | 0:ad2d25216a13 | 51 | * @code |
clemente | 0:ad2d25216a13 | 52 | * #include "mbed.h" |
clemente | 0:ad2d25216a13 | 53 | * #include "XMONlib.h" |
clemente | 0:ad2d25216a13 | 54 | * |
clemente | 0:ad2d25216a13 | 55 | * XMON xm( USBTX, USBRX); |
clemente | 0:ad2d25216a13 | 56 | * |
clemente | 0:ad2d25216a13 | 57 | * int main() |
clemente | 0:ad2d25216a13 | 58 | * { |
clemente | 0:ad2d25216a13 | 59 | * // Set the rate to XMON. Remenber to change the program too... |
clemente | 0:ad2d25216a13 | 60 | * xm.baud( 115200); |
clemente | 0:ad2d25216a13 | 61 | * .... |
clemente | 0:ad2d25216a13 | 62 | * xm.viewf( 3.1415, 0); // view pi value |
clemente | 0:ad2d25216a13 | 63 | * xm.view( 100, 1); // view an integer value |
clemente | 0:ad2d25216a13 | 64 | * |
clemente | 0:ad2d25216a13 | 65 | * xm.plotZero(); // clear the plot area |
clemente | 0:ad2d25216a13 | 66 | * for (int i=0; i<128; i++) |
clemente | 0:ad2d25216a13 | 67 | * { |
clemente | 0:ad2d25216a13 | 68 | * xm.plot( i, 0); // plot the i value... |
clemente | 0:ad2d25216a13 | 69 | * } |
clemente | 0:ad2d25216a13 | 70 | * |
clemente | 0:ad2d25216a13 | 71 | * |
clemente | 0:ad2d25216a13 | 72 | */ |
clemente | 0:ad2d25216a13 | 73 | |
clemente | 0:ad2d25216a13 | 74 | class XMON : public Serial |
clemente | 0:ad2d25216a13 | 75 | { |
clemente | 0:ad2d25216a13 | 76 | |
clemente | 0:ad2d25216a13 | 77 | public: |
clemente | 0:ad2d25216a13 | 78 | |
clemente | 0:ad2d25216a13 | 79 | XMON( PinName tx, PinName rx); |
clemente | 0:ad2d25216a13 | 80 | |
clemente | 0:ad2d25216a13 | 81 | /** Clear and restart x axis for the specified trace |
clemente | 0:ad2d25216a13 | 82 | * |
clemente | 0:ad2d25216a13 | 83 | * @param trace trace value |
clemente | 0:ad2d25216a13 | 84 | */ |
clemente | 0:ad2d25216a13 | 85 | void plotZero( unsigned int trace); |
clemente | 0:ad2d25216a13 | 86 | |
clemente | 0:ad2d25216a13 | 87 | /** Clear all trace and restart x axis |
clemente | 0:ad2d25216a13 | 88 | * @param none |
clemente | 0:ad2d25216a13 | 89 | */ |
clemente | 0:ad2d25216a13 | 90 | void plotZero( void); |
clemente | 0:ad2d25216a13 | 91 | |
clemente | 0:ad2d25216a13 | 92 | /** Plot float data |
clemente | 0:ad2d25216a13 | 93 | * |
clemente | 0:ad2d25216a13 | 94 | * @param data float value to plot. |
clemente | 0:ad2d25216a13 | 95 | * @param trace color graph |
clemente | 0:ad2d25216a13 | 96 | */ |
clemente | 0:ad2d25216a13 | 97 | void plotf( float data, unsigned int trace); |
clemente | 0:ad2d25216a13 | 98 | |
clemente | 0:ad2d25216a13 | 99 | /** View float data |
clemente | 0:ad2d25216a13 | 100 | * |
clemente | 0:ad2d25216a13 | 101 | * @param data float value to view. |
clemente | 0:ad2d25216a13 | 102 | * @param line line label |
clemente | 0:ad2d25216a13 | 103 | */ |
clemente | 0:ad2d25216a13 | 104 | void viewf( float data, unsigned int trace); |
clemente | 0:ad2d25216a13 | 105 | |
clemente | 0:ad2d25216a13 | 106 | /** Plot signed 32 bits data |
clemente | 0:ad2d25216a13 | 107 | * |
clemente | 0:ad2d25216a13 | 108 | * @param data signed 32bit value to plot. |
clemente | 0:ad2d25216a13 | 109 | * @param trace color graph |
clemente | 0:ad2d25216a13 | 110 | */ |
clemente | 0:ad2d25216a13 | 111 | void plotl( int data,unsigned int trace); |
clemente | 0:ad2d25216a13 | 112 | |
clemente | 0:ad2d25216a13 | 113 | /** View signed 32 bits data |
clemente | 0:ad2d25216a13 | 114 | * |
clemente | 0:ad2d25216a13 | 115 | * @param data unsigned short value to view. |
clemente | 0:ad2d25216a13 | 116 | * @param line line label |
clemente | 0:ad2d25216a13 | 117 | */ |
clemente | 0:ad2d25216a13 | 118 | void viewl( int data, unsigned int trace); |
clemente | 0:ad2d25216a13 | 119 | |
clemente | 0:ad2d25216a13 | 120 | /** Plot unsigned 16 bits data |
clemente | 0:ad2d25216a13 | 121 | * |
clemente | 0:ad2d25216a13 | 122 | * @param data unsigned short value to plot. |
clemente | 0:ad2d25216a13 | 123 | * @param trace color graph |
clemente | 0:ad2d25216a13 | 124 | */ |
clemente | 0:ad2d25216a13 | 125 | void plot( unsigned short data, unsigned int trace); |
clemente | 0:ad2d25216a13 | 126 | |
clemente | 0:ad2d25216a13 | 127 | /** View unsigned 16 bits data |
clemente | 0:ad2d25216a13 | 128 | * |
clemente | 0:ad2d25216a13 | 129 | * @param data unsigned short value to view. |
clemente | 0:ad2d25216a13 | 130 | * @param line line label |
clemente | 0:ad2d25216a13 | 131 | */ |
clemente | 0:ad2d25216a13 | 132 | void view( unsigned short data, unsigned int line); |
clemente | 0:ad2d25216a13 | 133 | |
clemente | 0:ad2d25216a13 | 134 | /** Put the PLOT GRAPH in auto scale mode |
clemente | 0:ad2d25216a13 | 135 | * |
clemente | 0:ad2d25216a13 | 136 | * @param s 0 auto scale OFF, 1 auto scale ON |
clemente | 0:ad2d25216a13 | 137 | */ |
clemente | 0:ad2d25216a13 | 138 | void autoscale( char s); |
clemente | 0:ad2d25216a13 | 139 | |
clemente | 0:ad2d25216a13 | 140 | }; |
clemente | 0:ad2d25216a13 | 141 | |
clemente | 0:ad2d25216a13 | 142 | #endif |