MDK-ARM Keil, MDK-ARM Datasheet - Page 99

KIT REALVIEW MCU DEVELOPMENT

MDK-ARM

Manufacturer Part Number
MDK-ARM
Description
KIT REALVIEW MCU DEVELOPMENT
Manufacturer
Keil
Type
Compiler and IDEr
Datasheets

Specifications of MDK-ARM

For Use With/related Products
ARM MCUs
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
Getting Started: Building Applications with RL-ARM
The second function is telnet_process_cmd(). This command line parser is used
to read the input from the Telnet client and then calls the required C application
functions. When a client connects to the Telnet server and enters a command
string, the telnet_process_cmd() function is triggered. The cmd pointer can
access the command string entered by the client.
Any reply by the Telnet server must be entered into the buffer buf. The size of
this buffer depends on the network maximum segment size. The third parameter,
buflen, contains the current maximum size for the buffer buf. Within this
function, we must make a command line parser. This will be used to inter-
operate the Telnet client commands and call the C application functions.
if (tnet_ccmp (cmd, "ADIN") == __TRUE)
}
When the telnet_process_cmd() function is triggered, we can use the helper
function tnet_ccmp() to examine the contents of the command buffer cmd. In the
above example, the client command ADIN requests the current conversion value
for a selected ADC channel. It is important to note that the helper function
tnet_ccmp() converts the command string characters to uppercase. This means,
that all your menu options must be defined as uppercase strings. The example
parses the string to determine which channel is required. Then it calls the user
ADC() conversion function. Next, it places the results in the reply buffer, which
is then sent back to the Telnet client. Finally, the number of bytes written into
the reply buffer must be returned to the RL-TCPnet library.
if (tnet_ccmp (cmd, "BYE") == __TRUE)
}
As well as returning the number of bytes in the reply buffer, the most significant
bit of the return value acts as a disconnect flag. Setting this bit terminates a
Telnet session.
Exercise: Telnet Server
This exercise demonstrates a Telnet server with a simple command line parser.
if (len >= 6)
}
len = str_copy (buf, "\r\nDisconnect...\r\n");
return (len | 0x8000);
sscanf ((const S8 *)(cmd+5), "%d",&ch);
val = AD_in (ch);
len = sprintf ((S8 *) buf, "\r\n ADIN %d = %d", ch, val);
return (len);
{
{
{
99

Related parts for MDK-ARM