This logger processes log events as they are generated, stores them in
a buffer and durring idle sends a section of the buffer to the user's
transport function. If you are seeing no log events or dropping too
many events check that you are not logging too often and have enough idle
time to send. LoggerIdle is compatable with StellarisWare and MWare
devices. Example transports for UART (B92 and F28M35x) and USB (F28M35x)
as well as initialization functions are included in the evmF28M35x.c files
under the device folder in the ti.examples directory.
Configuration example: The following XDC configuration statements
create a logger module, and assign it as the default logger for all
modules.
enum LoggerIdle_TransportType |
 |
Used to specify the type of transport to use
typedef enum LoggerIdle_TransportType {
LoggerIdle_TransportType_UART,
LoggerIdle_TransportType_USB,
LoggerIdle_TransportType_ETHERNET,
LoggerIdle_TransportType_CUSTOM
} LoggerIdle_TransportType;
DETAILS
This enum is used by the instrumentation host to determine what
the transport is. It is not used by the target code.
typedef LoggerIdle_LoggerFxn |
 |
Typedef for the transport function pointer
typedef Int (*LoggerIdle_LoggerFxn)(UChar*,Int);
config LoggerIdle_bufferSize // module-wide |
 |
LoggerIdle buffer size in 32-bit words
extern const SizeT LoggerIdle_bufferSize;
config LoggerIdle_customTransportType // module-wide |
 |
Custom transport used to send the records to an instrumentation host
extern const String LoggerIdle_customTransportType;
DETAILS
If the desired transport is not in the
TransportType enum,
and
transportType is set to
TransportType_CUSTOM,
this parameter must be filled in with the correct transport name.
If
transportType is NOT set to
TransportType_CUSTOM, this parameter is ignored.
config LoggerIdle_isTimestampEnabled // module-wide |
 |
Enable or disable logging the 64b local CPU timestamp
at the start of each event
extern const Bool LoggerIdle_isTimestampEnabled;
DETAILS
Having a timestamp allows an instrumentation host (e.g.
System Analyzer) to display events with the correct system time.
config LoggerIdle_transportFxn // module-wide |
 |
User defined transport function responsible for transmitting the records
config LoggerIdle_writeWhenFull // module-wide |
 |
Allow Log writes to succeed even if the the LoggerIdle buffer is
full
extern const Bool LoggerIdle_writeWhenFull;
DETAILS
LoggerIdle maintains a circular buffer where the Log events are
written. A write pointer indicates the location in the buffer
where the next Log event can be written to, and a read pointer
indicates the location of the next Log event to be sent to the
user's transport function. Log write calls cause the write pointer
to advance, and when Log data is passed to the user's transport
function in the idle loop, the read pointer advances. If the
read pointer catches up the the write pointer, the buffer is
'empty', and if the write pointer catches up the the read pointer,
the buffer is full.
The LoggerIdle buffer will fill up, if the idle function to output
the Log data cannot keep up with the Log writes. When this happens,
if writeWhenFull is false, Log writes will not put any new data
into the buffer until the LoggerIdle transportFxn has been called
to empty some of the buffer. As a result, the most recent Log
events could be lost. This is a simple solution to dealing with a
full buffer. Since Log event sizes vary, it avoids having to
determine how much the read pointer must be adjusted to fit a new
Log event. It also allows you to send a large chunk of the buffer
to the transport function in one shot, since the data will not
be overwritten by Log writes during the transfer. If Log events
are infrequent or the idle time is sufficient to get the Log
data out, then disabling writeWhenFull may be appropriate.
When this flag is set to true, if the LoggerIdle buffer is full,
new Log data will be written over the oldest Log record(s) in the
buffer. The oldest Log records in the buffer will be lost when
this happens.
The cost of enabling writeWhenFull is an increase in Log write
times when the buffer is full, as the buffer's read pointer will
need adjusting. There is also more overhead to get the Log data
out through the transport function. When writeWhenFull is enabled,
LoggerIdle's idle function will copy one Log record at a time into
a temporary buffer, and send the temporary buffer to the user's
transport function. This is to minimize interrupt latency, as the
buffer's read pointer can now be modified by both the idle function
and Log writes, and must be protected. The advantage, though, is
that you will not lose the most recent Log data when the buffer is
full. If Log events are frequent and the idle time is insufficient
to get the Log data out, then enabling writeWhenFull may be
appropriate.
LoggerIdle_flush() // module-wide |
 |
Call the transport function to empty out the LoggerIdle buffer
DETAILS
This API is not intended for general use, but could be used for
example, in an exception handler to recover the most recent Log
data that was written after the last run of the idle loop.
NOTE: Calling LoggerIdle_flush() when the idle task was in the
middle of outputting data can result in lost data (writeWhenFull
is true), or duplicate data (writeWhenFull is false).
In the case where writeWhenFull is true, the idle function only
outputs one Log record at a time, so at most one record could
be lost. If writeWhenFull is false, Log data could be output
twice, since LoggerIdle's internal read pointers are adjusted
after the data is output.
Module-Wide Built-Ins |
 |
// Get this module's unique id
Bool LoggerIdle_Module_startupDone();
// Test if this module has completed startup
// The heap from which this module allocates memory
Bool LoggerIdle_Module_hasMask();
// Test whether this module has a diagnostics mask
Bits16 LoggerIdle_Module_getMask();
// Returns the diagnostics mask for this module
Void LoggerIdle_Module_setMask(Bits16 mask);
// Set the diagnostics mask for this module
Instance Object Types |
 |
typedef struct LoggerIdle_Object LoggerIdle_Object;
// Opaque internal representation of an instance object
// Client reference to an instance object
typedef struct LoggerIdle_Struct LoggerIdle_Struct;
// Opaque client structure large enough to hold an instance object
// Convert this instance structure pointer into an instance handle
// Convert this instance handle into an instance structure pointer
Instance Config Parameters |
 |
typedef struct LoggerIdle_Params {
// Instance config-params structure
// Common per-instance configs
} LoggerIdle_Params;
// Initialize this config-params structure with supplier-specified defaults before instance creation
Instance Creation |
 |
// Allocate and initialize a new instance object and return its handle
// Initialize a new instance object inside the provided structure
ARGUMENTS
params
per-instance config params, or NULL to select default values (target-domain only)
eb
active error-handling block, or NULL to select default policy (target-domain only)
DETAILS
The logger instance will route all log events it receives to
the Uart.
Instance Deletion |
 |
// Finalize and free this previously allocated instance object, setting the referenced handle to NULL
// Finalize the instance object inside the provided structure
LoggerIdle_disable() // instance |
 |
Disable a log
ARGUMENTS
handle
handle of a previously-created LoggerIdle instance object
DETAILS
Events written to a disabled log are silently discarded.
RETURNS
The function returns the state of the log (TRUE if enabled,
FALSE if disabled) before the call. This return value allows
clients to restore the previous state.
Note: not thread safe.
LoggerIdle_enable() // instance |
 |
Enable a log
ARGUMENTS
handle
handle of a previously-created LoggerIdle instance object
RETURNS
The function returns the state of the log (TRUE if enabled,
FALSE if disabled) before the call. This return value allows
clients to restore the previous state.
Note: not thread safe.
LoggerIdle_write0() // instance |
 |
Process a log event with 0 arguments
ARGUMENTS
handle
handle of a previously-created LoggerIdle instance object
DETAILS
Same as write4 except with 0 arguments rather than 4.
SEE
LoggerIdle_write1() // instance |
 |
Process a log event with 1 arguments
ARGUMENTS
handle
handle of a previously-created LoggerIdle instance object
DETAILS
Same as write4 except with 1 arguments rather than 4.
SEE
LoggerIdle_write2() // instance |
 |
Process a log event with 2 arguments
ARGUMENTS
handle
handle of a previously-created LoggerIdle instance object
DETAILS
Same as write4 except with 2 arguments rather than 4.
SEE
LoggerIdle_write4() // instance |
 |
Process a log event with up to 4 arguments
ARGUMENTS
handle
handle of a previously-created LoggerIdle instance object
evt
event to be logged
mid
module ID of the module which logged the event
a1
arbitrary argument passed by caller
DETAILS
The
evt argument is of type Log.Event, which encodes the
Log.EventId, the
Diags.Mask, and the
Diags.EventLevel of the event. The event ID can be obtained
via
Types.getEventId(evt), the Diags mask can be obtained via
Diags.getMask(evt), and the event level can be obtained via
Diags.getLevel(evt).
The modId argument is the module ID of the module that logged the
event.
The event information can be used by the logger to handle different
events specially. For example, the event ID can be used to compare
against other known Log.Events.
if (Log_getEventId(MY_EVENT) == Log_getEventId(evt)) {
:
}
The Diags mask and event level can be used for filtering of events
based on event level (see
IFilterLogger), or even routing
events to separate loggers based on diags category (see, for example,
LoggerBuf.statusLogger).
The Diags mask and event level are useful for handling the event, but
are generally not recorded by the logger because they are not needed in
decoding and displaying the event. A more suitable value to record is a
Types.Event, which encodes the event ID and module ID. For
example, the
Log.EventRec type stores a
Types.Event
in its record definition. A
Types.Event can be created using
the
Types.makeEvent API given the event ID and module ID.
The event ID value of
0 is used to indicate an event triggered by a
call to one of the
Log_print[0-6] methods. These
methods take a format string rather than a
Log_Event argument and,
as a result, the event ID encoded in
evt is
0 and the parameter
a1 is the format string.
Non-zero event IDs can also be used to access the
msg string
associated with the
Log.EventDesc that originally
defined the
Log event.
Log_EventId id = Log_getEventId(evt));
if (id != 0) {
String msg = Text_ropeText(id);
System_aprintf(msg, a1, a2, a3, a4);
}
This works because an event's ID is simply an offset into a table
of characters (maintained by the
Text module)
containing the event's msg string.
The arguments a1, a2, etc. are parameters that are to be interpreted
according to the message format string associated with evt.
SEE
LoggerIdle_write8() // instance |
 |
Process a log event with up to 8 arguments
Void LoggerIdle_write8(
LoggerIdle_Handle handle,
Log_Event evt,
Types_ModuleId mid,
IArg a1,
IArg a2,
IArg a3,
IArg a4,
IArg a5,
IArg a6,
IArg a7,
IArg a8);
ARGUMENTS
handle
handle of a previously-created LoggerIdle instance object
DETAILS
Same as write4 except with 8 arguments rather than 4.
SEE
Instance Convertors |
 |
// unconditionally move one level up the inheritance hierarchy
// conditionally move one level down the inheritance hierarchy; NULL upon failure
Instance Built-Ins |
 |
Int LoggerIdle_Object_count();
// The number of statically-created instance objects
// The handle of the i-th statically-created instance object (array == NULL)
// The handle of the first dynamically-created instance object, or NULL
// The handle of the next dynamically-created instance object, or NULL
// The heap used to allocate dynamically-created instance objects
// The label associated with this instance object
// The name of this instance object
enum LoggerIdle.TransportType |
 |
Used to specify the type of transport to use
values of type LoggerIdle.TransportType
const LoggerIdle.TransportType_UART;
const LoggerIdle.TransportType_USB;
const LoggerIdle.TransportType_ETHERNET;
const LoggerIdle.TransportType_CUSTOM;
DETAILS
This enum is used by the instrumentation host to determine what
the transport is. It is not used by the target code.
C SYNOPSIS
metaonly struct LoggerIdle.RecordView |
 |
var obj = new LoggerIdle.RecordView;
obj.sequence = Int ...
obj.timestampRaw = Long ...
obj.modName = String ...
obj.text = String ...
obj.eventId = Int ...
obj.eventName = String ...
obj.arg0 = IArg ...
obj.arg1 = IArg ...
obj.arg2 = IArg ...
obj.arg3 = IArg ...
obj.arg4 = IArg ...
obj.arg5 = IArg ...
obj.arg6 = IArg ...
obj.arg7 = IArg ...
config LoggerIdle.bufferSize // module-wide |
 |
LoggerIdle buffer size in 32-bit words
LoggerIdle.bufferSize = SizeT 256;
C SYNOPSIS
config LoggerIdle.customTransportType // module-wide |
 |
Custom transport used to send the records to an instrumentation host
LoggerIdle.customTransportType = String null;
DETAILS
If the desired transport is not in the
TransportType enum,
and
transportType is set to
TransportType_CUSTOM,
this parameter must be filled in with the correct transport name.
If
transportType is NOT set to
TransportType_CUSTOM, this parameter is ignored.
C SYNOPSIS
config LoggerIdle.isTimestampEnabled // module-wide |
 |
Enable or disable logging the 64b local CPU timestamp
at the start of each event
LoggerIdle.isTimestampEnabled = Bool true;
DETAILS
Having a timestamp allows an instrumentation host (e.g.
System Analyzer) to display events with the correct system time.
C SYNOPSIS
config LoggerIdle.transportFxn // module-wide |
 |
User defined transport function responsible for transmitting the records
LoggerIdle.transportFxn = Int(*)(UChar*,Int) null;
C SYNOPSIS
config LoggerIdle.writeWhenFull // module-wide |
 |
Allow Log writes to succeed even if the the LoggerIdle buffer is
full
LoggerIdle.writeWhenFull = Bool false;
DETAILS
LoggerIdle maintains a circular buffer where the Log events are
written. A write pointer indicates the location in the buffer
where the next Log event can be written to, and a read pointer
indicates the location of the next Log event to be sent to the
user's transport function. Log write calls cause the write pointer
to advance, and when Log data is passed to the user's transport
function in the idle loop, the read pointer advances. If the
read pointer catches up the the write pointer, the buffer is
'empty', and if the write pointer catches up the the read pointer,
the buffer is full.
The LoggerIdle buffer will fill up, if the idle function to output
the Log data cannot keep up with the Log writes. When this happens,
if writeWhenFull is false, Log writes will not put any new data
into the buffer until the LoggerIdle transportFxn has been called
to empty some of the buffer. As a result, the most recent Log
events could be lost. This is a simple solution to dealing with a
full buffer. Since Log event sizes vary, it avoids having to
determine how much the read pointer must be adjusted to fit a new
Log event. It also allows you to send a large chunk of the buffer
to the transport function in one shot, since the data will not
be overwritten by Log writes during the transfer. If Log events
are infrequent or the idle time is sufficient to get the Log
data out, then disabling writeWhenFull may be appropriate.
When this flag is set to true, if the LoggerIdle buffer is full,
new Log data will be written over the oldest Log record(s) in the
buffer. The oldest Log records in the buffer will be lost when
this happens.
The cost of enabling writeWhenFull is an increase in Log write
times when the buffer is full, as the buffer's read pointer will
need adjusting. There is also more overhead to get the Log data
out through the transport function. When writeWhenFull is enabled,
LoggerIdle's idle function will copy one Log record at a time into
a temporary buffer, and send the temporary buffer to the user's
transport function. This is to minimize interrupt latency, as the
buffer's read pointer can now be modified by both the idle function
and Log writes, and must be protected. The advantage, though, is
that you will not lose the most recent Log data when the buffer is
full. If Log events are frequent and the idle time is insufficient
to get the Log data out, then enabling writeWhenFull may be
appropriate.
C SYNOPSIS
metaonly config LoggerIdle.common$ // module-wide |
 |
Common module configuration parameters
DETAILS
All modules have this configuration parameter. Its name
contains the '$' character to ensure it does not conflict with
configuration parameters declared by the module. This allows
new configuration parameters to be added in the future without
any chance of breaking existing modules.
metaonly config LoggerIdle.transportType // module-wide |
 |
Transport used to send the records to an instrumentation host
DETAILS
This parameter is used to specify the transport that the
transportFxn function will use to send the buffer to
an instrumentation host (e.g. System Analyzer in CCS).
This parameter is placed into the generated UIA XML file. The
instrumentation host can use the XML file to help it auto-detect as
much as possible and act accordingly.
If the desired transport is not in the
TransportType enum,
select
TransportType_CUSTOM and set the
customTransportType string with the desired string.
metaonly LoggerIdle.getMetaArgs() // module-wide |
 |
Returns any meta data needed to support RTA
LoggerIdle.getMetaArgs(Any inst, Any instNum) returns Any
DETAILS
This meta data should be returned in the form of a structure which
can be converted into XML. This data is added to the RTA XML file
during the application's configuration, and can be accessed later
through the xdc.rta.MetaData module.
The MetaData is returned per instance of the ILogger module. The
instance object is passed to the function as the first argument.
The second argument is the index of the instance in the list of
the ILogger's static instances.
Instance Config Parameters |
 |
var params = new LoggerIdle.Params;
// Instance config-params object
Instance Creation |
 |
var params =
new LoggerIdle.
Params;
// Allocate instance config-params
params.config = ...
// Assign individual configs
var inst = LoggerIdle.create(params);
// Create an instance-object
ARGUMENTS
params
per-instance config params, or NULL to select default values (target-domain only)
eb
active error-handling block, or NULL to select default policy (target-domain only)
DETAILS
The logger instance will route all log events it receives to
the Uart.