The ilogger interface in the SDK provides the general record function for the aee layer. There are three main implementations. The application author creates an ilogger instance by using the next classid:
-Aeeclsid_logger_file: Send a log entry to the file;
-Aeeclsid_logger_serial sends log entries to the serial port;
-Aeeclsid_logger_win sends a log entry to the brew simulator output window.
Both file implementation and serial record implementation output data to their respective output media in the following packet format:
--------------------------- | Brew header file | package data | -----------------------------
However, the log packages are packaged in HDLC frames in the following format:
---------------- | Brew header file | package data | 16B FCS | 8B HDLC mark | ------------------
The 16-bit FCS (frame check sequence) is the 16-bit CRC value specified in RFC 1171, and the 8-bit HDLC value is 0x7e, if this flag exists in the brew header file, package data, or 16B FCS, it must be escaped with an 8-bit value 0x7d and operated "differently" with 0x20. In addition, if the escape value 0x7d exists, it must be escaped using the same method. For example, in the data, the values 0x7e> 0x7d, 0x5e 0x7d> 0x7d, and 0x5d in the output stream must be reversed by the Receiving Software later. When recording to the serial port, there is a delay between the ilogger interface indicating that the data packet has been successfully sent and the data packet is completely sent to the serial port, which is caused by the buffer delay introduced by the low-level serial interface.
Therefore, application developers should note that if the ilogger interface is released too quickly after the last package is sent, data packets received through the serial port may be truncated. To avoid this situation, a delay may be introduced between the last packet sent and the ilogger interface released.
The ilogger interface uses the following format to write all outgoing logs to the output window of the simulator:
Bkt: XX Typ: xx cid: xx iid: XX filename linenumber message ARGs
Where:
Bkt: log storage
Typ: Log Type
CID: classid of the currently running BREW application
IID: User-Defined instance id
Filename: Optional file name for sending logs
Linenumber: the Optional line number for sending logs
Message: User-defined text message
ARGs: optional parameter for ilogger_putmsg ()
When compiling an application of a specific version, if you define the aee_log_disable constant, the constant can use the Preprocessor to delete almost all ilogger interface functions, except for instance creation process functions, obtaining parameter functions, and Setting Parameter functions. To do this, you must define this constant before the application contains aeelogger. h.
In this way, developers can not only test applications in real time on the simulator, but also debug applications on the target mobile phone through the simulator output window and log files.