| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 32 | kaklik | /****************************************************************************** |
| 2 | |||
| 3 | MRF24WB0M Driver Console Msg Handler |
||
| 4 | Module for Microchip TCP/IP Stack |
||
| 5 | -Provides access to MRF24WB0M WiFi controller |
||
| 6 | -Reference: MRF24WB0M Data sheet, IEEE 802.11 Standard |
||
| 7 | |||
| 8 | ******************************************************************************* |
||
| 9 | FileName: WFConsoleMsgHandler.h |
||
| 10 | Dependencies: TCP/IP Stack header files |
||
| 11 | Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F, PIC32 |
||
| 12 | Compiler: Microchip C32 v1.10b or higher |
||
| 13 | Microchip C30 v3.22 or higher |
||
| 14 | Microchip C18 v3.34 or higher |
||
| 15 | Company: Microchip Technology, Inc. |
||
| 16 | |||
| 17 | Software License Agreement |
||
| 18 | |||
| 19 | Copyright (C) 2002-2010 Microchip Technology Inc. All rights reserved. |
||
| 20 | |||
| 21 | Microchip licenses to you the right to use, modify, copy, and distribute: |
||
| 22 | (i) the Software when embedded on a Microchip microcontroller or digital |
||
| 23 | signal controller product ("Device") which is integrated into |
||
| 24 | Licensee's product; or |
||
| 25 | (ii) ONLY the Software driver source files ENC28J60.c, ENC28J60.h, |
||
| 26 | ENCX24J600.c and ENCX24J600.h ported to a non-Microchip device used in |
||
| 27 | conjunction with a Microchip ethernet controller for the sole purpose |
||
| 28 | of interfacing with the ethernet controller. |
||
| 29 | |||
| 30 | You should refer to the license agreement accompanying this Software for |
||
| 31 | additional information regarding your rights and obligations. |
||
| 32 | |||
| 33 | THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY |
||
| 34 | KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY |
||
| 35 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND |
||
| 36 | NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR ANY INCIDENTAL, |
||
| 37 | SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST |
||
| 38 | OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS BY |
||
| 39 | THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS |
||
| 40 | FOR INDEMNITY OR CONTRIBUTION, OR OTHER SIMILAR COSTS, WHETHER ASSERTED ON |
||
| 41 | THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR |
||
| 42 | OTHERWISE. |
||
| 43 | |||
| 44 | |||
| 45 | Author Date Comment |
||
| 46 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
| 47 | KH 27 Jan 2010 Updated for MRF24WB0M |
||
| 48 | ******************************************************************************/ |
||
| 49 | |||
| 50 | |||
| 51 | //--------- |
||
| 52 | // Includes |
||
| 53 | //--------- |
||
| 54 | #include <stdio.h> |
||
| 55 | #include <string.h> |
||
| 56 | #include <ctype.h> |
||
| 57 | |||
| 58 | #include "TCPIP Stack/TCPIP.h" |
||
| 59 | #include "TCPIP Stack/WFConsole.h" |
||
| 60 | |||
| 61 | #if defined ( WF_CONSOLE ) |
||
| 62 | |||
| 63 | #include "TCPIP Stack/WFConsoleMsgHandler.h" |
||
| 64 | #include "TCPIP Stack/WFConsoleIfconfig.h" |
||
| 65 | #include "TCPIP Stack/WFConsoleIwconfig.h" |
||
| 66 | #include "TCPIP Stack/WFConsoleIwpriv.h" |
||
| 67 | |||
| 68 | typedef struct dataStructDescriptor |
||
| 69 | { |
||
| 70 | UINT16 dataFormat; |
||
| 71 | void * p_validateFunc; |
||
| 72 | void * p_dest; |
||
| 73 | } tDataStructDescriptor; |
||
| 74 | |||
| 75 | |||
| 76 | #define kWFValidateWithU8 (0) |
||
| 77 | #define kWFValidateWithU16 (1) |
||
| 78 | #define kWFValidateWithS8 (2) |
||
| 79 | #define kWFValidateWithX8 (3) |
||
| 80 | |||
| 81 | |||
| 82 | //============================================================================ |
||
| 83 | // Function Prototypes |
||
| 84 | //============================================================================ |
||
| 85 | |||
| 86 | static void do_help_msg(void); |
||
| 87 | static void do_get_wfver_cmd(void); |
||
| 88 | static void do_cls_cmd(void); |
||
| 89 | |||
| 90 | /***************************************************************************** |
||
| 91 | * FUNCTION: process_cmd |
||
| 92 | * |
||
| 93 | * RETURNS: None |
||
| 94 | * |
||
| 95 | * PARAMS: None |
||
| 96 | * |
||
| 97 | * NOTES: Determines which command has been received and processes it. |
||
| 98 | *****************************************************************************/ |
||
| 99 | void process_cmd(void) |
||
| 100 | { |
||
| 101 | BOOL new_arg; |
||
| 102 | UINT8 i; |
||
| 103 | |||
| 104 | |||
| 105 | g_ConsoleContext.argc = 0; |
||
| 106 | new_arg = TRUE; |
||
| 107 | |||
| 108 | // Get pointers to each token in the command string |
||
| 109 | TokenizeCmdLine(g_ConsoleContext.rxBuf); |
||
| 110 | |||
| 111 | // if command line nothing but white kWFSpace or a linefeed |
||
| 112 | if ( g_ConsoleContext.argc == 0u ) |
||
| 113 | { |
||
| 114 | return; // nothing to do |
||
| 115 | } |
||
| 116 | |||
| 117 | // change the command itself (token[0]) to lower case |
||
| 118 | for (i = 0; i < strlen((char *)g_ConsoleContext.argv[0]); ++i) |
||
| 119 | { |
||
| 120 | g_ConsoleContext.argv[0][i] = tolower(g_ConsoleContext.argv[0][i]); |
||
| 121 | } |
||
| 122 | |||
| 123 | |||
| 124 | if ( IS_ECHO_ON() ) |
||
| 125 | { |
||
| 126 | putrsUART("\n\r"); |
||
| 127 | } |
||
| 128 | |||
| 129 | switch (GetCmdId()) |
||
| 130 | { |
||
| 131 | |||
| 132 | case HELP_MSG: |
||
| 133 | do_help_msg(); |
||
| 134 | WFConsoleSetMsgFlag(); |
||
| 135 | break; |
||
| 136 | |||
| 137 | case GET_WF_VERSION_MSG: |
||
| 138 | do_get_wfver_cmd(); |
||
| 139 | break; |
||
| 140 | |||
| 141 | case RESET_HOST: |
||
| 142 | Reset(); |
||
| 143 | break; |
||
| 144 | |||
| 145 | case CLEAR_SCREEN_MSG: |
||
| 146 | do_cls_cmd(); |
||
| 147 | break; |
||
| 148 | |||
| 149 | #if defined(WF_CONSOLE_IFCFGUTIL) |
||
| 150 | case IFCONFIG_MSG: |
||
| 151 | do_ifconfig_cmd(); |
||
| 152 | break; |
||
| 153 | |||
| 154 | case IWCONFIG_MSG: |
||
| 155 | do_iwconfig_cmd(); |
||
| 156 | break; |
||
| 157 | |||
| 158 | case IWPRIV_MSG: |
||
| 159 | do_iwpriv_cmd(); |
||
| 160 | break; |
||
| 161 | #endif // WF_CONSOLE_IFCFGUTIL |
||
| 162 | |||
| 163 | default: |
||
| 164 | WFConsoleSetMsgFlag(); |
||
| 165 | break; |
||
| 166 | } |
||
| 167 | } |
||
| 168 | |||
| 169 | BOOL convertAsciiToHexInPlace( INT8 *p_string, UINT8 expectedHexBinSize ) |
||
| 170 | { |
||
| 171 | |||
| 172 | INT8 ascii_buffer[3]; |
||
| 173 | UINT8 hex_binary_index = 0; |
||
| 174 | INT8 *hex_string_start = p_string; |
||
| 175 | UINT16 hex_buffer = 0; |
||
| 176 | |||
| 177 | /* gobble up any hex prefix */ |
||
| 178 | if ( memcmppgm2ram (hex_string_start, (const ROM FAR char*) "0x", 2) == 0 ) |
||
| 179 | hex_string_start+=2; |
||
| 180 | |||
| 181 | if ( strlen( (char *) hex_string_start) != (expectedHexBinSize*2) ) |
||
| 182 | return FALSE; |
||
| 183 | |||
| 184 | while ( hex_binary_index < expectedHexBinSize ) |
||
| 185 | { |
||
| 186 | |||
| 187 | memcpy ( ascii_buffer, (const char*) hex_string_start, 2 ); |
||
| 188 | ascii_buffer[2] = '\0'; |
||
| 189 | |||
| 190 | /* convert the hex string to a machine hex value */ |
||
| 191 | if ( !ConvertASCIIHexToBinary( ascii_buffer,&hex_buffer) ) |
||
| 192 | return FALSE; |
||
| 193 | |||
| 194 | p_string[hex_binary_index++] = (UINT8) hex_buffer; |
||
| 195 | |||
| 196 | hex_string_start +=2; |
||
| 197 | |||
| 198 | } |
||
| 199 | |||
| 200 | return TRUE; |
||
| 201 | |||
| 202 | } |
||
| 203 | |||
| 204 | static void do_cls_cmd(void) |
||
| 205 | { |
||
| 206 | Output_Monitor_Hdr(); |
||
| 207 | } |
||
| 208 | |||
| 209 | |||
| 210 | static void do_help_msg(void) |
||
| 211 | { |
||
| 212 | UINT8 i; |
||
| 213 | |||
| 214 | putrsUART("\n\r"); |
||
| 215 | for (i = 0; i < g_numCmds; ++i) |
||
| 216 | { |
||
| 217 | putrsUART( (ROM FAR char *) g_consoleCmd[i].p_cmdName); |
||
| 218 | putrsUART("\r\t\t"); |
||
| 219 | putrsUART( (ROM FAR char*) g_consoleCmd[i].p_cmdHelp); |
||
| 220 | putrsUART("\n\r"); |
||
| 221 | } |
||
| 222 | |||
| 223 | } |
||
| 224 | |||
| 225 | /***************************************************************************** |
||
| 226 | * FUNCTION: do_get_wfver_cmd |
||
| 227 | * |
||
| 228 | * RETURNS: None |
||
| 229 | * |
||
| 230 | * PARAMS: None |
||
| 231 | * |
||
| 232 | * NOTES: Processes get WF device information |
||
| 233 | *****************************************************************************/ |
||
| 234 | |||
| 235 | static void do_get_wfver_cmd(void) |
||
| 236 | { |
||
| 237 | tWFDeviceInfo deviceInfo; |
||
| 238 | |||
| 239 | WF_GetDeviceInfo(&deviceInfo); |
||
| 240 | WFConsolePrintRomStr("Firmware version 0x", FALSE); |
||
| 241 | WFConsolePrintHex(deviceInfo.romVersion, 2); |
||
| 242 | WFConsolePrintHex(deviceInfo.patchVersion, 2); |
||
| 243 | WFConsolePrintRomStr("", TRUE); |
||
| 244 | |||
| 245 | WFConsolePrintRomStr("Host Driver version ", FALSE); |
||
| 246 | WFConsolePrintRomStr(WF_HOST_DRIVER_VERSION_NUMBER, TRUE); |
||
| 247 | } |
||
| 248 | |||
| 249 | #endif /* WF_CONSOLE */ |
||
| 250 | |||
| 251 | |||
| 252 | |||
| 253 | |||
| 254 | |||
| 255 | |||
| 256 | |||
| 257 | |||
| 258 |
Powered by WebSVN v2.8.3