Skip to main content

API Details (Common)

This page describes details of common APIs available in this product.

Read This First

API Quick Reference (Constants / Structures / Preconditions / Minimal Examples)

APIConstants used by this APIStructures used by this APICallable precondition statusMinimal code examples (C++/C#/VBA)
MPXGetAPIVersionAPI Return ValuesStMPXAPIVersionNot recognized / RecognizedCommon First
MPXOpenAPI Return ValuesStMPXDeviceInfoNot recognizedCommon First
MPXCloseAPI Return Values-RecognizedCommon First
MPXSetLEDLED Settings-RUN/PARAMCommon First
MPXGetStatusMicroPeckerX Status-RecognizedCommon First
MPXMonitorStartSync Mode, MicroPeckerX Status-PARAMCommon First
MPXMonitorStopAPI Return Values-SYNC/NONE/MON/SIMCommon First
MPXGetTimeStampAPI Return Values-NONE/MON/SIMCommon First
MPXSetGetLogModeLog Acquisition Mode-RUN/PARAMCAN C# Sample, LIN VBA Sample
MPXSetLogCallBackLog Acquisition ModeStMPXLogCBRUN/PARAMCAN C++ Sample, LIN C++ Sample
MPXGetLogBuffer Overrun PresenceStMPXLogNONE/MON/SIMCAN C++ Sample, LIN C++ Sample

Notation

On this page, each API is described in the following format.

Format[Function type] [Function name]([argument], ...)
Argument[Argument type][Argument name][in/out][Argument description]
Return value[Return type][Return value (error code)][Description of return value (error code)]
Function[Function behavior]
Note[Supplementary information]

If an argument type is a structure, refer to Structure Definitions (struct) for values to set or values that are set.

For [in/out], in means set by caller before invocation, and out means set by the function during processing.

API Details

MPXGetAPIVersion

Gets version information of this API.

FormatER MPXGetAPIVersion(StMPXAPIVersion * Version)
ArgumentStMPXAPIVersion *VersionoutAPI version information
Return valueERE_OKSuccess
E_PARAMParameter error (for example, NULL pointer)
FunctionGets version information of this API.

MPXOpen

Detects connected MicroPeckerX device(s).

FormatER MPXOpen(StMPXDeviceInfo * Devices, unsigned char Num, unsigned char * Count)
ArgumentStMPXDeviceInfo *Devicesin/outDevice information structure array
unsigned charNuminNumber of elements in device information structure array
unsigned char *CountoutNumber of detected MicroPeckerX devices
Return valueERE_OKSuccess
E_DEVICEDevice not found
E_COMMCommunication error
E_TIMEOUTCommunication timeout
FunctionDetects MicroPeckerX devices connected to the PC.
Set Devices to a structure array for storing detected device information, and set Num to the array length.
Number of acquired device entries is returned in Count.
NoteIf multiple MicroPeckerX devices are connected, up to Num devices (maximum 4) can be detected at the same time. However, you cannot arbitrarily choose which specific devices are detected.

MPXClose

Releases detection of MicroPeckerX device(s).

FormatER MPXClose(void)
Return valueERE_OKSuccess
FunctionReleases all currently detected MicroPeckerX devices.

MPXSetLED

Controls LEDs on MicroPeckerX.

FormatER MPXSetLED(unsigned long Serial, unsigned char LEDRed, unsigned char LEDGreen, unsigned char LEDGreenBlink, unsigned char LEDYellow, unsigned char LEDYellowBlink)
Argumentunsigned longSerialinSerial number of target MicroPeckerX device
unsigned charLEDRedinRed LED on/off (see LED Settings)
unsigned charLEDGreeninGreen LED on/off (see LED Settings)
unsigned charLEDGreenBlinkinGreen LED blinking on/off (see LED Settings)
unsigned charLEDYellowinYellow LED on/off (see LED Settings)
unsigned charLEDYellowBlinkinYellow LED blinking on/off (see LED Settings)
Return valueERE_OKSuccess
E_PARAMParameter error
E_DEVICEDevice not found
E_COMMCommunication error
E_TIMEOUTCommunication timeout
FunctionControls LEDs of the device specified by Serial.
Red LED turns on with MPX_LED_ON and off with MPX_LED_OFF.
Green LED turns on with MPX_LED_ON and off with MPX_LED_OFF. If LEDGreenBlink is MPX_LED_ON, it blinks regardless of LEDGreen.
Yellow LED turns on with MPX_LED_ON and off with MPX_LED_OFF. If LEDYellowBlink is MPX_LED_ON, it blinks regardless of LEDYellow.

MPXGetStatus

Gets status of MicroPeckerX device.

FormatER MPXGetStatus(unsigned long Serial, unsigned short * StatusCh1, unsigned short * StatusCh2)
Argumentunsigned longSerialinSerial number of target MicroPeckerX device
unsigned short *StatusCh1outStatus of CH1 (see MicroPeckerX Status)
unsigned short *StatusCh2outStatus of CH2 (see MicroPeckerX Status)
Return valueERE_OKSuccess
E_PARAMParameter error
E_DEVICEDevice not found
E_COMMCommunication error
E_TIMEOUTCommunication timeout
FunctionGets status of each channel for the device specified by Serial.

MPXMonitorStart

Starts monitoring.

FormatER MPXMonitorStart(unsigned long Serial, unsigned char SyncMode)
Argumentunsigned longSerialinSerial number of target MicroPeckerX device
unsigned charSyncModeinSync mode (see Sync Mode)
Return valueERE_OKSuccess
E_PARAMParameter error
E_DEVICEDevice not found
E_COMMCommunication error
E_STATUSStatus error
E_TIMEOUTCommunication timeout
FunctionStarts monitoring on the device specified by Serial.
MPX_SYNC_MASTER runs in master mode, and MPX_SYNC_SLAVE runs in slave mode.
For CAN communication, if slot information has been set by MPXCANSetSlot, frame transmission also starts for slots whose frame type is MPX_CAN_FRAME_TYPE_PERIODIC or MPX_CAN_FRAME_TYPE_EVENTPERIODIC.
For LIN communication, if master simulation has been set by MPXLINSetMasterSim, frame transmission also starts using the schedule selected by MPXLINChangeMasterSchedule.
NoteBefore calling this API, you must set communication parameters by calling MPXCANSetParam or MPXLINSetParam.
When operating multiple devices, start monitoring on all slave-mode devices first, then start monitoring on master-mode devices.

MPXMonitorStop

Stops monitoring.

FormatER MPXMonitorStop(unsigned long Serial, unsigned long * mSec, unsigned short * uSec)
Argumentunsigned longSerialinSerial number of target MicroPeckerX device
unsigned long *mSecoutTimestamp (milliseconds)
unsigned short *uSecoutTimestamp (microseconds)
Return valueERE_OKSuccess
E_PARAMParameter error
E_DEVICEDevice not found
E_COMMCommunication error
E_STATUSStatus error
E_TIMEOUTCommunication timeout
FunctionStops monitoring on the device specified by Serial and gets timestamp at that point.
Timestamp values in mSec and uSec indicate that logs received up to that point are guaranteed.
NoteWhen operating multiple devices, stop monitoring on master-mode devices first, then stop monitoring on slave-mode devices in sequence.

MPXGetTimeStamp

Gets timestamp.

FormatER MPXGetTimeStamp(unsigned long Serial, unsigned long * mSec, unsigned short * uSec)
Argumentunsigned longSerialinSerial number of target MicroPeckerX device
unsigned long *mSecoutTimestamp (milliseconds)
unsigned short *uSecoutTimestamp (microseconds)
Return valueERE_OKSuccess
E_PARAMParameter error
E_DEVICEDevice not found
E_COMMCommunication error
E_STATUSStatus error
E_TIMEOUTCommunication timeout
FunctionGets current timestamp of the device specified by Serial.
Acquired timestamp is set to mSec and uSec.
NoteTimestamp values set to mSec and uSec may have time lag from actual function call timing.

MPXSetGetLogMode

Sets how to acquire monitoring log data (TX/RX data).

FormatER MPXSetGetLogMode(unsigned long Serial, unsigned char InnerCh, unsigned char Mode)
Argumentunsigned longSerialinSerial number of target MicroPeckerX device
unsigned charInnerChinTarget CH number (1 or 2)
unsigned charModeinLog acquisition mode (see Log Acquisition Mode)
Return valueERE_OKSuccess
E_PARAMParameter error
E_DEVICEDevice not found
FunctionSets log receiving method from the channel specified by Serial and InnerCh.
If Mode is MPX_GETLOG_CALLBACK, callback mode is used. If Mode is MPX_GETLOG_GETLOGAPI, log acquisition API mode is used.
NoteIn callback mode, you must call MPXSetLogCallBack to set callback function.
In log acquisition API mode, you must periodically call one of MPXGetLog, MPXCANGetLogEx, or MPXLINGetLogEx.

MPXSetLogCallBack

Sets callback function used to acquire monitoring log data (TX/RX data).

FormatER MPXSetLogCallBack(unsigned long Serial, unsigned char InnerCh, void * Self, unsigned char ** Log1, unsigned char ** Log2, void (* CallBack) (unsigned long, unsigned char, void *, unsigned char, unsigned short))
Argumentunsigned longSerialinSerial number of target MicroPeckerX device
unsigned charInnerChinTarget CH number (1 or 2)
void *SelfinCaller class pointer
unsigned char **Log1inPointer to array storing logs
unsigned char **Log2inPointer to array storing logs
Function pointerCallBackinPointer to callback function
Return valueERE_OKSuccess
E_PARAMParameter error
E_DEVICEDevice not found
FunctionSets callback function for acquiring logs from the channel specified by Serial and InnerCh.
Arguments of callback function specified by CallBack are as follows.
[1st argument: unsigned long] Serial number of target MicroPeckerX
[2nd argument: unsigned char] Target CH number (1 or 2)
[3rd argument: void *] Caller class pointer
[4th argument: unsigned char] Destination log buffer (1 for Log1, 2 for Log2)
[5th argument: unsigned short] Number of valid logs (not byte size)
NoteThis API is valid only in callback mode.

MPXGetLog

Gets monitoring log data (TX/RX data) from log structure buffer allocated inside DLL.

FormatER MPXGetLog(unsigned long Serial, unsigned char InnerCh, StMPXLog ** Log, unsigned short * Count, unsigned char * BufferOver)
Argumentunsigned longSerialinSerial number of target MicroPeckerX device
unsigned charInnerChinTarget CH number (1 or 2)
StMPXLog **LogoutPointer to log structure array
unsigned short *CountoutNumber of acquired logs
unsigned char *BufferOveroutBuffer overrun (see Buffer Overrun Presence)
Return valueERE_OKSuccess
E_PARAMParameter error
E_DEVICEDevice not found
FunctionGets logs from channel specified by Serial and InnerCh.
Pointer to start of internal DLL log buffer is set to Log, and number of logs is set to Count.
If buffer overrun occurs, BufferOver is set to MPX_LOG_BUFOVER_TRUE.
NoteThis API is valid only in log acquisition API mode.
No caller-side log structure array preparation is required for this API.