API Details
This chapter explains each API provided by this product.
Legend
Each API is described using the following table format.
| Format | [Return type] [Function name]([arguments], ...) | |||
|---|---|---|---|---|
| Argument | [Type] | [Name] | [in/out] | [Description] |
| Return value | [Type] | [Return code] | [Description of return code] | |
| Function | [Explanation of what the function does] | |||
| Notes | [Supplementary information] | |||
If an argument type is a structure, refer to Structure Definitions (struct) for details on the values to set or read.
[in/out] indicates whether the argument is provided by the caller (in) or set by the API (out).
API Details
MPXGetAPIVersion
Retrieves the version information of this API.
| Format | ER MPXGetAPIVersion(StMPXAPIVersion * Version) | |||
|---|---|---|---|---|
| Argument | StMPXAPIVersion * | Version | out | API version information |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter (such as NULL pointer) | |||
| Function | Retrieves the version information of this API. | |||
MPXOpen
Detects MicroPeckerX units connected to the PC.
| Format | ER MPXOpen(StMPXDeviceInfo * Devices, unsigned char * Count) | |||
|---|---|---|---|---|
| Argument | StMPXDeviceInfo * | Devices | out | Information about detected MicroPeckerX units |
| unsigned char * | Count | out | Number of detected MicroPeckerX units | |
| Return value | ER | E_OK | Completed successfully | |
| E_DEVICE | No device found | |||
| E_COMM | Communication error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Detects MicroPeckerX units connected to the PC and returns the number of units and their device information. | |||
| Notes | If multiple MicroPeckerX units are connected, up to four units can be detected simultaneously. You cannot specify which units are detected. | |||
MPXClose
Releases all detected MicroPeckerX units.
| Format | ER MPXClose(void) | |||
|---|---|---|---|---|
| Return value | ER | E_OK | Completed successfully | |
| Function | Releases all currently detected MicroPeckerX units. | |||
MPXSetLED
Controls the LEDs on a MicroPeckerX unit.
| Format | ER MPXSetLED(unsigned long Serial, unsigned char LEDRed, unsigned char LEDGreen, unsigned char LEDGreenBlink, unsigned char LEDYellow, unsigned char LEDYellowBlink) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | LEDRed | in | Red LED setting (see LED Settings) | |
| unsigned char | LEDGreen | in | Green LED setting (see LED Settings) | |
| unsigned char | LEDGreenBlink | in | Green LED blink setting (see LED Settings) | |
| unsigned char | LEDYellow | in | Yellow LED setting (see LED Settings) | |
| unsigned char | LEDYellowBlink | in | Yellow LED blink setting (see LED Settings) | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Controls the LEDs on the MicroPeckerX unit specified by Serial. Setting LEDRed to MPX_LED_ON turns on the red LED; MPX_LED_OFF turns it off. LEDGreen controls the green LED in the same way, while LEDGreenBlink causes the green LED to blink regardless of the LEDGreen value. LEDYellow controls the yellow LED, and LEDYellowBlink causes it to blink regardless of LEDYellow. | |||
MPXGetStatus
Retrieves the status of each channel on a MicroPeckerX unit.
| Format | ER MPCANGetStatus(unsigned long Serial, unsigned short * StatusCh1, unsigned short * StatusCh2) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned short * | StatusCh1 | out | Status of CH1 (see MicroPeckerX Status) | |
| unsigned short * | StatusCh2 | out | Status of CH2 (see MicroPeckerX Status) | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Retrieves the status of each channel on the MicroPeckerX unit specified by Serial. | |||
MPXMonitorStart
Starts monitoring.
| Format | ER MPXMonitorStart(unsigned long Serial, unsigned char SyncMode) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | SyncMode | in | Sync mode (see Sync Modes) | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Starts monitoring on the MicroPeckerX unit specified by Serial. MPX_SYNC_MASTER starts master mode; MPX_SYNC_SLAVE starts slave mode. If slots are configured with MPXSetSlot, frames with MPX_CAN_FRAME_TYPE_PERIODIC or MPX_CAN_FRAME_TYPE_EVENTPERIODIC start transmitting when monitoring begins. | |||
| Notes | Call MPXSetCANParam to configure communication parameters before starting monitoring. When using multiple units, start monitoring on all slave units first, then start the master unit. | |||
MPXMonitorStop
Stops monitoring.
| Format | ER MPXMonitorStop(unsigned long Serial, unsigned long * mSec, unsigned short * uSec) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned long * | mSec | out | Timestamp (milliseconds) | |
| unsigned short * | uSec | out | Timestamp (microseconds) | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Stops monitoring on the MicroPeckerX unit specified by Serial and returns the timestamp at the moment monitoring stopped. The returned timestamp guarantees the log content up to that point. | |||
| Notes | When operating multiple units, stop the master unit first, then stop each slave unit in order. | |||
MPXGetTimeStamp
Retrieves the current timestamp.
| Format | ER MPXGetTimeStamp(unsigned long Serial, unsigned long * mSec, unsigned short * uSec) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned long * | mSec | out | Timestamp (milliseconds) | |
| unsigned short * | uSec | out | Timestamp (microseconds) | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Retrieves the timestamp of the MicroPeckerX unit specified by Serial. | |||
| Notes | This API can be called only while monitoring, simulation, or log replay is running. | |||
MPXSetGetLogMode
Configures how log information is acquired.
| Format | ER MPXSetGetLogMode(unsigned long Serial, unsigned char InnerCh, unsigned char Mode) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | InnerCh | in | Channel (1 or 2) | |
| unsigned char | Mode | in | Log acquisition mode (see Log Acquisition Modes) | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Configures how log information is acquired for the specified channel on the MicroPeckerX unit specified by Serial. | |||
MPXSetLogCallBack
Registers the callback function used to receive log information.
| Format | ER MPXSetLogCallBack(unsigned long Serial, unsigned char InnerCh, void * Context, unsigned char ** Log1, unsigned char ** Log2, void (*LogCallBack)(unsigned long Serial, unsigned char InnerCh, void * Context, unsigned char BufferNo, unsigned short Count)) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | InnerCh | in | Channel (1 or 2) | |
| void * | Context | in | User-defined context pointer passed to the callback | |
| unsigned char ** | Log1 | in | Pointer to the first log buffer | |
| unsigned char ** | Log2 | in | Pointer to the second log buffer | |
| void (*)(unsigned long, unsigned char, void *, unsigned char, unsigned short) | LogCallBack | in | Callback function pointer | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| Function | Registers the callback function used to acquire log information for the channel specified by Serial and InnerCh. Log1 and Log2 point to the buffers in which log data is stored. | |||
| Notes | This API is effective only when log acquisition mode is set to callback mode. The callback receives the following arguments: • Argument 1 (unsigned long): Serial number of the MicroPeckerX unit • Argument 2 (unsigned char): Channel number (1 or 2) • Argument 3 (void *): Context pointer specified in this API • Argument 4 (unsigned char): Log buffer index (1 for Log1, 2 for Log2) • Argument 5 (unsigned short): Number of valid log entries | |||
MPXGetLog
Retrieves log information by returning a pointer to the DLL-managed buffer.
| Format | ER MPXGetLog(unsigned long Serial, unsigned char InnerCh, StMPXCANLog ** Log, unsigned short * Count, unsigned char * BufferOver) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | InnerCh | in | Channel (1 or 2) | |
| StMPXCANLog ** | Log | out | Pointer to the log buffer | |
| unsigned short * | Count | out | Number of log entries retrieved | |
| unsigned char * | BufferOver | out | Buffer overrun flag (see Buffer Overrun Flag) | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| Function | Retrieves log information for the specified channel. The pointer returned in Log refers to the buffer inside the DLL. Count holds the number of log entries. If a buffer overrun occurs, BufferOver is set to MPX_LOG_BUFOVER_TRUE. | |||
| Notes | Available only when log acquisition mode is set to API mode. The caller does not need to allocate an array to store the retrieved log data. | |||
MPXGetLogEx
Retrieves log information and stores it in an array prepared by the caller.
| Format | ER MPXGetLogEx(unsigned long Serial, unsigned char InnerCh, StMPXCANLog * Log, unsigned short Num, unsigned short * Count, unsigned char * BufferOver) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | InnerCh | in | Channel (1 or 2) | |
| StMPXCANLog * | Log | in/out | Array to receive the log information | |
| unsigned short | Num | in | Number of elements in the array | |
| unsigned short * | Count | out | Number of log entries stored | |
| unsigned char * | BufferOver | out | Buffer overrun flag (see Buffer Overrun Flag) | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| Function | Retrieves log information for the specified channel and stores it in the array provided by the caller. Specify the array and its number of elements in Log and Num. The number of stored entries is returned in Count. If Count exceeds Num, BufferOver is set to MPX_LOG_BUFOVER_TRUE. | |||
| Notes | Available only when log acquisition mode is set to API mode. Prepare the array to store log information before calling this API. | |||
MPXSetCANParam
Configures communication parameters for a channel.
| Format | ER MPXSetCANParam(unsigned long Serial, unsigned char InnerCh, StMPXCANParam * Param) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | InnerCh | in | Channel (1 or 2) | |
| StMPXCANParam * | Param | in | Communication parameters | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Configures the communication parameters for the specified channel of the MicroPeckerX unit specified by Serial. | |||
MPXSetSlot
Configures slot information before monitoring starts.
| Format | ER MPXSetSlot(unsigned long Serial, unsigned char InnerCh, StMPXCANSlot * Slots, unsigned char SlotCount) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | InnerCh | in | Channel (1 or 2) | |
| StMPXCANSlot * | Slots | in | Slot information | |
| unsigned char | SlotCount | in | Number of slots to configure | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Configures CAN or CAN FD slot information for the channel specified by Serial and InnerCh before monitoring starts. Prepare an array of slot information structures in Slots for the number of slots you want to configure, and specify the array length in SlotCount. | |||
| Notes | Use this API to configure slot information before monitoring starts. To change slot information while monitoring is running, call MPXChangeSlot. | |||
MPXChangeSlot
Updates slot information while monitoring is running.
| Format | ER MPCANChangeSlotData(unsigned long Serial, unsigned char InnerCh, unsigned char SlotNo, unsigned char SlotEnabled, unsigned char ReqInfo, StMPXCANFrame * Frame) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | InnerCh | in | Channel (1 or 2) | |
| unsigned char | SlotNo | in | Slot number (1–28) | |
| unsigned char | SlotEnabled | in | Slot enable/disable flag (see Slot Enable) | |
| unsigned char | ReqInfo | in | Request information for slot change (see Slot Change Request) | |
| StMPXCANFrame * | Frame | in | Frame information | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_TRG_BUSY | Trigger configuration failed | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Updates the slot specified by SlotNo on the designated channel. | |||
| Notes | Use this API to change slot settings during monitoring. To configure slots before monitoring starts, use MPXSetSlot. | |||
MPXSendSlot
Requests transmission from a slot.
| Format | ER MPXSendSlot(unsigned long Serial, unsigned char InnerCh, unsigned char SlotNo) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | InnerCh | in | Channel (1 or 2) | |
| unsigned char | SlotNo | in | Slot number (1–28) | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Triggers transmission of the specified slot on the MicroPeckerX unit specified by Serial. | |||
| Notes | Available when slot transmission is enabled for the specified slot. | |||
MPXDirectSend
Transmits a frame immediately.
| Format | ER MPXDirectSend(unsigned long Serial, unsigned char InnerCh, StMPXCANDirect * Direct) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | InnerCh | in | Channel (1 or 2) | |
| StMPXCANDirect * | Direct | in | Frame to transmit | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Transmits the specified frame immediately. | |||
| Notes | Available when communication parameters configured by MPXSetCANParam are set to an operating mode that supports transmission (e.g., monitoring with ACK, simulation, or log replay). | |||
MPXSetLogRequestCallBack
Registers the callback function that supplies log replay data when requested.
| Format | ER MPXSetLogRequestCallBack(unsigned long Serial, unsigned char InnerCh, void * Context, void (*RequestCallBack)(unsigned long Serial, unsigned char InnerCh, void * Context, unsigned char ShortageFlag, unsigned short AcceptSize)) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | InnerCh | in | Channel (1 or 2) | |
| void * | Context | in | User-defined context pointer passed to the callback | |
| void (*)(unsigned long, unsigned char, void *, unsigned char, unsigned short) | RequestCallBack | in | Callback function pointer | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Registers the callback function that is called when additional log replay data is requested while operating in log replay mode or burst transfer mode (log replay). | |||
| Notes | The callback receives the following arguments: • Argument 1 (unsigned long): Serial number • Argument 2 (unsigned char): Channel (1 or 2) • Argument 3 (void *): Context pointer specified in this API • Argument 4 (unsigned char): Log depletion flag (1 when a shortage occurred) • Argument 5 (unsigned short): Acceptable log size in bytes Effective only when communication parameters configured by MPXSetCANParam specify MPX_MODE_CAN_LOGREPLAY or MPX_MODE_CAN_BURST_LOG. | |||
MPXSetLogReplayData
Supplies log replay data.
| Format | ER MPXSetLogReplayData(unsigned long Serial, unsigned char InnerCh, unsigned char * Data, unsigned long Size) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | InnerCh | in | Channel (1 or 2) | |
| unsigned char * | Data | in | Log replay data | |
| unsigned long | Size | in | Data size (bytes) | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_LOG_OVER | Log replay data overflow | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Provides log replay data to the specified channel. | |||
| Notes | Log replay data consists of consecutive frame information structures. See StMPXCANReplayLog; data bytes (D1–D64) are variable length. If a frame has an odd number of data bytes, append one byte of padding after the data (value is arbitrary). The maximum size per call is 16,384 bytes. Effective only when communication parameters configured by MPXSetCANParam specify MPX_MODE_CAN_LOGREPLAY or MPX_MODE_CAN_BURST_LOG. | |||
MPXSetBurstLog
Configures frame information for burst mode (single frame).
| Format | ER MPXSetBurstLog(unsigned long Serial, unsigned char InnerCh, StMPXCANSlot * Frame) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | InnerCh | in | Channel (1 or 2) | |
| StMPXCANSlot * | Frame | in | Frame information | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Configures the frame used for burst transfer mode (single frame). | |||
| Notes | Effective only when communication parameters configured by MPXSetCANParam specify MPX_MODE_CAN_BURST_FRM. | |||
MPXSetLogReplayTrigger
Configures the trigger for starting log replay.
| Format | ER MPXSetLogReplayTrigger(unsigned long Serial, unsigned char InnerCh, unsigned char TriggerType, StMPXCANID TriggerID) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | InnerCh | in | Channel (1 or 2) | |
| unsigned char | TriggerType | in | Trigger type (see Trigger Type) | |
| StMPXCANID | TriggerID | in | Trigger ID | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Configures the trigger condition that starts log replay for the specified channel. | |||
| Notes | Effective only when communication parameters configured by MPXSetCANParam specify MPX_MODE_CAN_LOGREPLAY or MPX_MODE_CAN_BURST_LOG. Do not call this API when the operating mode is MPX_MODE_CAN_BURST_FRM. | |||
MPXLogReplayStart
Starts log replay or burst transfer.
| Format | ER MPXLogReplayStart(unsigned long Serial, unsigned char InnerCh) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | InnerCh | in | Channel (1 or 2) | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_TRG_BUSY | Trigger configuration failed | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Starts log replay mode or burst transfer mode on the specified channel. | |||
| Notes | If transmission must begin immediately after monitoring starts, call this API before starting monitoring. Effective only when communication parameters configured by MPXSetCANParam specify MPX_MODE_CAN_LOGREPLAY, MPX_MODE_CAN_BURST_FRM, or MPX_MODE_CAN_BURST_LOG. | |||
MPXLogReplayStop
Stops log replay or burst transfer.
| Format | ER MPXLogReplayStop(unsigned long Serial, unsigned char InnerCh) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of the target MicroPeckerX unit |
| unsigned char | InnerCh | in | Channel (1 or 2) | |
| Return value | ER | E_OK | Completed successfully | |
| E_PARAM | Invalid parameter | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Stops log replay mode or burst transfer mode on the specified channel. | |||
| Notes | Effective only when communication parameters configured by MPXSetCANParam specify MPX_MODE_CAN_LOGREPLAY, MPX_MODE_CAN_BURST_FRM, or MPX_MODE_CAN_BURST_LOG. | |||