XPicoWiFi/CommandLineStatusExample

From Lantronix Wiki!
Revision as of 16:05, 6 April 2015 by Ltrxmg42 (talk | contribs) (Created page with "This example shows how to get the XML Status Register (XSR) from the Command Line Interface, and extract useful information from your microcontroller. The first step is for t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This example shows how to get the XML Status Register (XSR) from the Command Line Interface, and extract useful information from your microcontroller.

The first step is for the UART to be placed in CLI mode.

  • Configure UART to always be in CLI mode
  • From Modem Emulation, issue the ATD0 command
  • From Mux, issue the D command
<nowiki>

/*

* Function to connect on the second serial port of the xPico Wi-Fi
* and retrieve the current status (XSR).
* 
* This function parses the Command Line Interface (CLI) to get to the
* XSR status. It receives the XML, and then parses the XML to extract
* the current serial number of the device. Can be modified to extract
* other information as well.
*/

void getXSR(char buffer[]) {

       // Enter CLI from Modem Emulation

snprintf(buffer, 200, "ATD 0\r"); SendString(buffer, &deviceData); WAIT1_Waitms(50); waitForPrompt();

       // Go to the xml area of CLI and dump XSR for Device

snprintf(buffer, 200, "xml\r"); SendString(buffer, &deviceData); waitForPrompt(); WAIT1_Waitms(200); snprintf(buffer, 200, "xsr dump device\r"); SendString(buffer, &deviceData);

while(TRUE) {

              // Parse the XML response

receiveLine(buffer); if (buffer[0] == '\0') break; if (strstr(buffer, "/statusrecord") != NULL) { snprintf(buffer, 200, "exit\r"); SendString(buffer, &deviceData); WAIT1_Waitms(100); SendString(buffer, &deviceData); WAIT1_Waitms(100); break; } else if (strstr(buffer, "Serial Number") != NULL) { snprintf(buffer, 200, ""); receiveLine(buffer); assignToken(buffer, uid, 15); } snprintf(buffer, 200, ""); } }