|
Each "debug message" starts with a "debug code", which has a value from 128 - 255. Note that this is
outside the range of normal ASCII characters. So, if ASCII is sent via the embedded board, it will not
accidentally be interpreted as a debug messages.
The format of a "debug message" is:
[debug code][message code][message parameters]
- The "debug code" is a value from 128 to 255. When 255, it means that an "extended message
code" is to follow. This should only be used if there are more then 127 messages - if
message codes 128-254 are not enough! When "message code" 255 is used, the "debug command"
has the following format:
[debug code][255][extended message code][message parameters]
The message code will determine in which "Debug Tab" of the Modtronix Embedded Debugger the
message is written. A "Debug Tab" is created for each "debugHandler" element in the project file.
The "debugHandler" element will contain the range of "debug codes" accepted by that tab, and define
messages for "message codes"
- The "message code" is a value from 0 to 255, and has to be defined in a "message" element in the
project file. The Modtronix Embedded Debugger will display the message defined in the project file
when receiving a "debug message" from the embedded board.
- The "message parameters" are optional. The message string defined in the project file can contain
"format specifiers" that will be replaced with values contained in the "message parameters".
These "format specifiers" can be used to display hex, decimal or string data, which will be contained in
the "message parameters". The following "format specifiers" are defined:
- %x = A two character ascii hex value. For example "00", "F0", "80", "8A"..... Will be
displayed in lowercase hex.
- %X = A two character ascii hex value. For example "00", "F0", "80", "8A"..... Will be
displayed in uppercase hex.
- %B = A two character ascill hex value = Byte. Will be displayed in decimal.
- %W = A four character ascill hex value = Word. Will be displayed in decimal. Not implemented yet!
- %d = A one character value from 0-127. Will be displayed in decimal.
- %s = A null terminated string, for example "filename.txt".
Project File Format
The project files are in XML format. There can be multiple project files. They should be called "debug.xml"
or "mxdebug.xml". Each project file consists out of a number of "debugHandler" elements, which in turn
contains a "message" element for each message that can be accepted for that "debugHandler".
A tab will be created in the Modtronix Embedded Debugger for each "debugHandler" element. This element
also defines the range of "debug codes" accepted by this tab, and the tab name.
The "message" elements contain the message that is written out to the Modtronix Embedded Debugger when
that "message code" is received. The message string can contain "format specifiers" which will be replaced
by values contained in the "message parameters". For example, if the message string is "Could not find the
following file: %s", than the "message parameters" must contain a null terminated string for the %s
"format specifier" contained in the string.
Example Project File
Following is an example project file:
<mxdebug>
<!-- DHCP Debug Tab -->
<debugHandler name="DHCP" codeFrom="0xD1" codeTo="0xD1" offsetName="none">
<message code="1" type="info" param="Broadcast"/>
<message code="2" type="info" param="Discover"/>
<message code="3" type="info" param="Offer Message"/>
<message code="4" type="warn" param="NAK recieved. DHCP server error"/>
<message code="5" type="info" param="ACK Received"/>
<message code="6" type="warn" param="Timeout"/>
</debugHandler>
<!-- FTP Debug Tab -->
<debugHandler name="FTP" codeFrom="0xD2" codeTo="0xD2" offsetName="none">
<message code="1" type="info" param="Received FTP command = %s"/>
<message code="2" type="info" param="Received command = 0x%x"/>
<message code="3" type="info" param="Sending Responce message = %s"/>
</debugHandler>
<!-- TCP Debug Tab -->
<!-- Codes 0x80 to 0x8D handle sockets 0 - 14 -->
<!-- Code 0x8E handles given socket. Socket number will follow this code. -->
<!-- Code 0x8F handles general TCP debug messages -->
<debugHandler name="TCP" codeFrom="0x80" codeTo="0x8F" offsetName="Socket">
<message code="1" type="warn" param="TCP Packet Checksum error!"/>
<message code="2" type="info" param="Found Matching socket, assigned to TCP Handle %d"/>
<message code="3" type="warn" param="TCPDisconnect() forcefully closed connection!"/>
<message code="4" type="info" param="state FIN-WAIT-1: Disconnect called"/>
<message code="5" type="warn" param="state FIN-WAIT-1: Max Retries, connection closed!"/>
</debugHandler>
</mxdebug>
When loaded into the Modtronix Embedded Debugger, three tabs will be created for this project: DHCP, FTP
and TCP. To, for example display the "ACK Received" message defined in the DHCP "debugHandler", the
embedded board will send the following two byte message:
0xD1, 0x05
The 0xD1 byte is the "debug code", and indicates that this message is for the DHCP tab. The 0x05 byte is
the "message code", and means that the "ACK Received" message has to be displayed.
|