Skip to main content

API Details (CAN)

This page describes details of CAN-specific 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)
MPXCANSetParamCAN Operation Mode, CAN Arbitration BaudrateStMPXCANParamRUNCAN Monitor Sample (C++), CAN Simulation (C#), CAN Simulation (VBA)
MPXCANGetLogExBuffer Overrun PresenceStMPXCANLogNONE/MON/SIMCAN Monitor Sample (C++)
MPXCANSetSlotCAN Frame Type, CAN Transmission Trigger TypeStMPXCANSlotPARAM/SYNCCAN Simulation (C++)
MPXCANChangeSlotCAN Slot Enable/Disable, CAN Slot Change Request InfoStMPXCANFrameSIMCAN Simulation (C++)
MPXCANSendSlotCAN Frame Type-SIMCAN Simulation (C++)
MPXCANDirectSendCAN ID Format, CAN Remote Transmission RequestStMPXCANDirectSIMCAN Simulation (C++), CAN Simulation (C#), CAN Simulation (VBA)

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) (CAN) and Structure Definitions (struct) (common) 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

MPXCANSetParam

Sets CAN or CAN FD communication parameters from predefined options.

FormatER MPXCANSetParam(unsigned long Serial, unsigned char InnerCh, StMPXCANParam * Param)
Argumentunsigned longSerialinSerial number of target MicroPeckerX device
unsigned charInnerChinTarget CH number (1 or 2)
StMPXCANParam *ParaminPointer to parameter setting structure
Return valueERE_OKSuccess
E_PARAMParameter error
E_DEVICEDevice not found
E_COMMCommunication error
E_STATUSStatus error
E_TIMEOUTCommunication timeout
FunctionSets CAN or CAN FD communication parameters on the CH specified by Serial and InnerCh, using values in Param.
NoteCalling this API changes MicroPeckerX status to MPX_STATUS_PARAM (waiting for parameter configuration).

MPXCANGetLogEx

Gets log information (TX/RX data) during monitoring into a caller-provided CAN log structure array.

FormatER MPXCANGetLogEx(unsigned long Serial, unsigned char InnerCh, StMPXCANLog * Log, unsigned short Num, unsigned short * Count, unsigned char * BufferOver)
Argumentunsigned longSerialinSerial number of target MicroPeckerX device
unsigned charInnerChinTarget CH number (1 or 2)
StMPXCANLog *Login/outLog information structure array
unsigned shortNuminNumber of elements in 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
FunctionAcquires CAN log information from the CH specified by Serial and InnerCh.
Set Log to an array for storing acquired CAN logs, and set Num to the array length.
The number of acquired logs is returned in Count.
If Count exceeds Num, buffer overrun occurs and BufferOver is set to MPX_LOG_BUFOVER_TRUE.
NoteThis API is valid only when using log acquisition API mode.
The caller must prepare the destination structure array for acquired logs.

MPXCANSetSlot

Sets CAN or CAN FD slot information before monitoring starts.

FormatER MPXCANSetSlot(unsigned long Serial, unsigned char InnerCh, StMPXCANSlot * Slots, unsigned char SlotCount)
Argumentunsigned longSerialinSerial number of target MicroPeckerX device
unsigned charInnerChinTarget CH number (1 or 2)
StMPXCANSlot *SlotsinSlot information
unsigned charSlotCountinNumber of slots to configure
Return valueERE_OKSuccess
E_PARAMParameter error
E_DEVICEDevice not found
E_COMMCommunication error
E_STATUSStatus error
E_TIMEOUTCommunication timeout
FunctionSets CAN or CAN FD slot information on the CH specified by Serial and InnerCh.
Set Slots to an array of slot structures and SlotCount to the array length.
NoteThis API is for setting slot information before monitoring starts.
To change slot information during monitoring, call MPXCANChangeSlot.

MPXCANChangeSlot

Changes CAN or CAN FD slot information during monitoring.

FormatER MPXCANChangeSlot(unsigned long Serial, unsigned char InnerCh, unsigned char SlotNo, unsigned char SlotEnabled, unsigned char ReqInfo, StMPXCANFrame * Frame)
Argumentunsigned longSerialinSerial number of target MicroPeckerX device
unsigned charInnerChinTarget CH number (1 or 2)
unsigned charSlotNoinTarget slot number (1 to 28)
unsigned charSlotEnabledinSlot enable/disable (see CAN Slot Enable/Disable)
unsigned charReqInfoinRequest information for slot change (see CAN Slot Change Request Info)
StMPXCANFrame *FrameinPointer to frame attribute structure
Return valueERE_OKSuccess
E_PARAMParameter error
E_DEVICEDevice not found
E_COMMCommunication error
E_TRG_BUSYTrigger configuration failed
E_STATUSStatus error
E_TIMEOUTCommunication timeout
FunctionChanges CAN or CAN FD slot information specified by SlotNo on the CH specified by Serial and InnerCh.
NoteThis API changes slot enable/disable and CAN/CAN FD frame settings during monitoring.
To set slot information before monitoring starts, call MPXCANSetSlot.

MPXCANSendSlot

Issues a send request to a CAN or CAN FD slot.

FormatER MPXCANSendSlot(unsigned long Serial, unsigned char InnerCh, unsigned char SlotNo)
Argumentunsigned longSerialinSerial number of target MicroPeckerX device
unsigned charInnerChinTarget CH number (1 or 2)
unsigned charSlotNoinTarget slot number (1 to 28)
Return valueERE_OKSuccess
E_PARAMParameter error
E_DEVICEDevice not found
E_COMMCommunication error
E_TRG_BUSYTrigger configuration failed
E_STATUSStatus error
E_TIMEOUTCommunication timeout
FunctionIssues a send request to the slot specified by SlotNo on the CH specified by Serial and InnerCh.
NoteThis API is valid only when the slot frame type set by MPXCANSetSlot is MPX_CAN_FRAME_TYPE_EVENT or MPX_CAN_FRAME_TYPE_EVENTPERIODIC.

MPXCANDirectSend

Sends a CAN or CAN FD frame directly without using slots.

FormatER MPXCANDirectSend(unsigned long Serial, unsigned char InnerCh, StMPXCANDirect * Frame)
Argumentunsigned longSerialinSerial number of target MicroPeckerX device
unsigned charInnerChinTarget CH number (1 or 2)
StMPXCANDirect *FrameinTransmit frame
Return valueERE_OKSuccess
E_PARAMParameter error
E_DEVICEDevice not found
E_COMMCommunication error
E_DCT_FULLNo free buffer for direct transmission
E_STATUSStatus error
E_TIMEOUTCommunication timeout
FunctionIssues a direct transmission request for the frame specified by Frame on the CH specified by Serial and InnerCh, without using slots.