9.3.2 How to Use the API for the MPLAB X IDE Event Recorder

Three functions are available for use in your application:

  • EventRecord2() → send two integers
  • EventRecord4() → send four integers
  • EventRecordData() → send more than four integers

Documentation on the above functions can be found at Event Recorder and Component Viewer: Event Data Recording (keil.com).

In a debug session, MPLAB X IDE collects data generated by a device. The data can be:

  1. An event record containing data sent by EventRecord2(), EventRecord4(), or EventRecordData(). An event contains a timestamp (64-bit), an ID (32-bit), and a list of 32-bit integers sent by your application.
  2. The status of Event Recorder. The event status tells you the status of event recorder, it gives you information like how many records have been written, how many records has been dumped(so here you need to be aware that records can be dumped by the application running on your device)

To obtain data from Java code:

import com.microchip.mplab.mdbcore.event.recorder.EventRecorderConstants.EventRecord;
import com.microchip.mplab.mdbcore.event.recorder.EventRecorderConstants.EventStatus;
import com.microchip.mplab.mdbcore.streamingdataprocessing.eventrecorder.EventRecorderEventListener;
import com.microchip.mplab.mdbcore.streamingdataprocessing.eventrecorder.EventRecorderEventMediator;
import org.openide.util.Lookup;
 
public final class MyClass {
    private EventRecorderEventMediator eventMediator;
    private EventRecorderEventListener eventListener;
 
    public MyClass() {
        eventMediator = Lookup.getDefault().lookup(EventRecorderEventMediator.class);
        eventListener = this::handleEvent;
        eventMediator.addListener(eventListener);
    }
 
    public void handleEvent(Object event) {
        if (event instanceof EventRecord) {
            // do something, e.g. you can access "record.ts", "record.id", "record.values"   
        }
        else if (event instanceof EventStatus) {
            // do something, e.g. you can access "status.state", "status.context", "stats.infoCrc", etc
        }
        events.add(event);
    }
 
}

To obtain data from Python code, you need to create an autoload.py file in your project and add the following callback function in it.

def on_event_recorder_record(record):
    # do something, e.g. you can access "record.ts", "record.id", "record.values"
    pass
 
def on_event_recorder_status(status):
    # do something, e.g. you can access "status.state", "status.context", "stats.infoCrc", etc
    pass