User`s guide
22
K
A
DAK
KwikNet Overview
1.7 KwikNet Message Recording Service
Recognizing that embedded systems may not be able to display or print messages,
KADAK provides an alternate message recording service. This service is provided in
module KNRECORD.C which is located in the toolset dependent installation directory
TOOLXXX\SAM_COMN (see Chapter 3.6).
The
KwikNet message recording service, used by all KwikNet sample programs, accepts a
message contained in a KwikNet log buffer. The message is copied from the log buffer
into a memory array and the log buffer is released.
The messages are stored sequentially in a character array called kn_records[]. As each
message is recorded, a pointer to the copy of the message is stored into the next available
entry in variable kn_recordlist[], an array of string pointers. The list of string pointers
is terminated with a NULL string pointer. Message recording ceases as soon as either
array becomes full.
Procedure kn_loginit() in module KNRECORD.C must be called by your application
before the message recording service can be used by KwikNet. For this reason, your
main() function should call kn_loginit() as one of its earliest operations.
Once the service is ready, procedure kn_logmsg() can be called to record a message
contained in a KwikNet log buffer. The Application OS Interface module KNSAMOS.C used
by KwikNet sample programs provides an example. The data log function sam_record()
in that module ensures that each KwikNet log buffer is eventually delivered to procedure
kn_logmsg() which records the message and releases the log buffer.
The data recording service can be adapted to your needs by editing the definitions in the
sample program's application header file KNZZZAPP.H. A unique header file is provided
with each KwikNet sample program. Symbol KN_REC_MEMORY must be set to 1 to enable
recording of messages into character array kn_records[]. Symbol KN_REC_MEMSIZE
defines the size of that array. Symbol KN_REC_NUM defines the maximum number of
message string pointers which can be recorded into array kn_recordlist[]. If symbol
KN_REC_CONSOLE is set to 1, each recorded message will also be echoed to the KwikNet
console driver as described in Chapter 1.8.
Some of the
KwikNet sample programs implement a dump command to display the
recorded messages. These applications call procedure kn_loggets() to extract each
message string from the recording array. After displaying all messages in the order in
which they were recorded, procedure
kn_loginit() is called to reset the array.
Also note that some debuggers will allow you to dump the strings in text form in a
display window by viewing the array variable kn_recordlist[] .
Warning
The procedures in the recording module KNRECORD.C are
NOT reentrant. Hence, in multitasking systems, you must
ensure that, if one task calls any one of these procedures,
no other task can execute any of the procedures until that
task completes its use of the recording service.