Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dump.cpp
00001 /* 00002 Copyright (c) 2011, Senio Networks, Inc. 00003 00004 Permission is hereby granted, free of charge, to any person obtaining a copy 00005 of this software and associated documentation files (the "Software"), to deal 00006 in the Software without restriction, including without limitation the rights 00007 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 copies of the Software, and to permit persons to whom the Software is 00009 furnished to do so, subject to the following conditions: 00010 00011 The above copyright notice and this permission notice shall be included in 00012 all copies or substantial portions of the Software. 00013 00014 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00020 THE SOFTWARE. 00021 */ 00022 00023 #include "XBee.h" 00024 #include <ctype.h> 00025 00026 void XBee::dump() { 00027 if (received != out || (in == out && free != 0)) 00028 return; 00029 00030 switch (getFrameType(buf[INDEX(out + 2)])) { 00031 case ATCommandResponse: { 00032 char id, name[2], status, data[16]; 00033 int length = 0; 00034 scan(FrameID, &id); 00035 scan(ATCommand, name, sizeof(name)); 00036 scan(Status, &status); 00037 scan(CommandData, data, sizeof(data), &length); 00038 mon.printf("ATCommandResponse, Id=%d, Nm=%c%c, St=%02X, ", id & 255, name[0], name[1], status); 00039 if (name[0] == 'I' && name[1] == 'S' && status == 0) 00040 dumpIOSample(data, length); 00041 else 00042 dump(data, length); 00043 } 00044 break; 00045 00046 case ModemStatus: { 00047 char status; 00048 scan(Status, &status); 00049 mon.printf("ModemStatus, St=%02X\n", status); 00050 } 00051 break; 00052 00053 case ZigBeeTransmitStatus: { 00054 char id, address16[2], retry, delivery, discovery; 00055 scan(FrameID, &id); 00056 scan(Address16, address16, sizeof(address16)); 00057 scan(RetryCount, &retry); 00058 scan(DeliveryStatus, &delivery); 00059 scan(DiscoveryStatus, &discovery); 00060 mon.printf("ZigBeeTransmitStatus, Id=%d, ad=%02X%02X, Rty=%d, Dlv=%02X, Dsc=%02X\n", 00061 id & 255, address16[0], address16[1], retry & 255, delivery, discovery); 00062 } 00063 break; 00064 00065 case ZigBeeReceivePacket: { 00066 char address64[8], address16[2], options, data[32]; 00067 int length = 0; 00068 scan(Address64, address64, sizeof(address64)); 00069 scan(Address16, address16, sizeof(address16)); 00070 scan(ReceiveOptions, &options); 00071 scan(ReceivedData, data, sizeof(data), &length); 00072 mon.printf("ZigBeeReceivePacket, AD=%02X%02X%02X%02X %02X%02X%02X%02X, ad=%02X%02X, Op=%02X, Length=%d, ", 00073 address64[0], address64[1], address64[2], address64[3], address64[4], address64[5], 00074 address64[6], address64[7], address16[0], address16[1], options, length); 00075 dump(data, min(sizeof(data), length)); 00076 } 00077 break; 00078 00079 case ZigBeeIODataSampleRxIndicator: { 00080 char address64[8], address16[2], options, data[16]; 00081 int length = 0; 00082 scan(Address64, address64, sizeof(address64)); 00083 scan(Address16, address16, sizeof(address16)); 00084 scan(ReceiveOptions, &options); 00085 scan(ReceivedData, data, sizeof(data), &length); 00086 mon.printf("ZigBeeIODataSampleRxIndicator, AD=%02X%02X%02X%02X %02X%02X%02X%02X, ad=%02X%02X, Op=%02X, ", 00087 address64[0], address64[1], address64[2], address64[3], address64[4], address64[5], 00088 address64[6], address64[7], address16[0], address16[1], options); 00089 dumpIOSample(data, length); 00090 } 00091 break; 00092 00093 case RemoteCommandResponse: { 00094 char address64[8], address16[2], id, name[2], status, data[16]; 00095 int length = 0; 00096 scan(Address64, address64, sizeof(address64)); 00097 scan(Address16, address16, sizeof(address16)); 00098 scan(FrameID, &id); 00099 scan(ATCommand, name, sizeof(name)); 00100 scan(Status, &status); 00101 scan(CommandData, data, sizeof(data), &length); 00102 mon.printf("RemoteCommandResponse, AD=%02X%02X%02X%02X %02X%02X%02X%02X, ad=%02X%02X, Id=%d, Nm=%c%c, St=%02X, ", 00103 address64[0], address64[1], address64[2], address64[3], address64[4], address64[5], 00104 address64[6], address64[7], address16[0], address16[1], id & 255, name[0], name[1], status); 00105 if (name[0] == 'I' && name[1] == 'S' && status == 0) 00106 dumpIOSample(data, length); 00107 else 00108 dump(data, length); 00109 } 00110 break; 00111 00112 default: { 00113 char data[32]; 00114 int length = 0; 00115 scan(RawData, data, sizeof(data), &length); 00116 mon.printf("Frametype:%02X, Length=%d, Data=", buf[INDEX(out + 2)] & 255, length); 00117 dump(data, min(sizeof(data), length)); 00118 } 00119 } 00120 } 00121 00122 void XBee::dumpAll() { 00123 mon.printf("cur = %04X\n", cur); 00124 mon.printf("in = %04X\n", in); 00125 mon.printf("out = %04X\n", out); 00126 mon.printf("received = %04X\n", received); 00127 mon.printf("free = %d\n", free); 00128 for (int i = 0; i < BUFSIZE; i += 16) { 00129 mon.printf("%04X: ", i); 00130 dump(buf + i, 16); 00131 } 00132 } 00133 00134 void XBee::dump(const char* data, int length) { 00135 for (int i = 0; i < length; i++) mon.printf("%02X", data[i]); 00136 mon.printf(" | "); 00137 for (int i = 0; i < length; i++) mon.printf("%c", isprint(data[i]) ? data[i] : '.'); 00138 mon.printf("\n"); 00139 } 00140 00141 void XBee::dumpIOSample(const char* data, int length) { 00142 if (length > 0) { 00143 IOSample sample(data); 00144 //sample.print(mon); 00145 mon.printf(sample); 00146 } 00147 }
Generated on Wed Jul 20 2022 22:15:57 by
