uCon HomePage

MONCMD Server


uCon supports the ability to receive ASCII command strings via UDP. It uses the same mechanism as is built into MicroMonitor (aka uMon); hence, the uMon-host-tool called 'moncmd' (or uCon's script command called MONCMD) can be used to communicate with another uCon session whose MONCMD server has been turned on.  There's also a cut-back version of the moncmd.exe tool that comes with uCon, called uconcmd.exe.  This is probably all you'll ever need.

The 'moncmd' client (part of the freely available MicroMonitor package at the Microcross website ) is a tool that allows a developer to communicate (via UDP) with the command line interface of an embedded system running MicroMonitor.  The 'uconcmd' tool comes with the uCon installation, found in the same directory as ucon.exe.

The MONCMD server in uCon is essentially the same server built into it; hence, it can receive commands via the moncmd client.

The menu item Servers->MONCMD brings up the following dialog box:

On the server side, there's not much to configure. It simply gets enabled or disabled, along with the port number (default being 777).

uCon uses the first white-space-delimited token of the incoming command line from moncmd to determine what
to do.  There are currently three different commands: SCRCMD, BUTTON and FKEY.

SCRCMD:  

With this as the first token, a moncmd client (or another uCon session using the MONCMD script command) can tell a uCon session to run any of uCon's script commands.  See below for example.

BUTTON:  

With this as the first token, the remote UDP client can tell uCon to virtually click any of the 16 buttons.  For example BUTTON: 4

FKEY:  

With this as the first token (similar to BUTTON), the remote client can tel uCon to virtually click any of the 8 function keys. For example FKEY: 3

Example using 'SCRCMD:'...

Assume we have a uCon session running on some PC whose IP address is 1.2.3.4, and the MONCMD server has been enabled to run on port 987. We can now use either the stand-alone 'uconcmd' client or the MONCMD script command in uCon to 'talk' to this uCon session. Probably the most likely to be used is the "SEND" command, so we'll use that as the example. Assume, for example, that uCon's backend is attached to an embedded system's console port, and we want to issue the "reboot" command. The following command line would do this:

uconcmd -p 987 1.2.3.4 "SCRCMD: SEND -n \"reboot\""

Note that uconcmd is basically a trimmed down version the Micromonitor host-tool called 'moncmd'.  Being able to do this with the stand-alone 'moncmd' tool allows a user to communicate with a uCon session from any machine that the moncmd tool is built for (Linux, Unix, PCWindows, etc..., the moncmd source code will build on windows or linux/unix).

Similarly, if we chose to do this with a second uCon session, we would use the MONCMD script command as the client...

MONCMD -p 987 1.2.3.4 "SCRCMD: SEND -n \"reboot\""

Note that this is essentially the same command line as the first example, except now it is within a uCon script.  This would be received by the uCon session running on PC 1.2.3.4, with the MONCMD server enabled on port 987 and it would then send the reboot string to the target it is attached to.

Alternatively, you may want to use a python script to communicate with this server.  
For example, assuming the python script below is called "scrcmd.py", the equivalent  usage to the above examples would be:

scrcmd.py 1.2.3.4 987 "SEND -n \"reboot\""

#!/usr/bin/python
import sys
import socket

if len(sys.argv) != 4:
  print "Usage: " + sys.argv[0] + " {host} {port} {string}"
  sys.exit(1)

s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM,0)
host = sys.argv[1]
port = int(sys.argv[2])
msg = sys.argv[3]

s.connect((host, port))
s.send("SCRCMD:  " + msg + "\000")
s.close