API Details (CAN)
This page describes details of CAN-specific APIs available in this product.
Read This First
- If you need task-based API mapping: CAN API Mapping
- If you need common API prerequisites first: Common API by Task
- If you need CAN constants: Constant Definitions (CAN)
- If you need CAN structures: Structure Definitions (CAN)
API Quick Reference (Constants / Structures / Preconditions / Minimal Examples)
| API | Constants used by this API | Structures used by this API | Callable precondition status | Minimal code examples (C++/C#/VBA) |
|---|---|---|---|---|
| MPXCANSetParam | CAN Operation Mode, CAN Arbitration Baudrate | StMPXCANParam | RUN | CAN Monitor Sample (C++), CAN Simulation (C#), CAN Simulation (VBA) |
| MPXCANGetLogEx | Buffer Overrun Presence | StMPXCANLog | NONE/MON/SIM | CAN Monitor Sample (C++) |
| MPXCANSetSlot | CAN Frame Type, CAN Transmission Trigger Type | StMPXCANSlot | PARAM/SYNC | CAN Simulation (C++) |
| MPXCANChangeSlot | CAN Slot Enable/Disable, CAN Slot Change Request Info | StMPXCANFrame | SIM | CAN Simulation (C++) |
| MPXCANSendSlot | CAN Frame Type | - | SIM | CAN Simulation (C++) |
| MPXCANDirectSend | CAN ID Format, CAN Remote Transmission Request | StMPXCANDirect | SIM | CAN 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.
| Format | ER MPXCANSetParam(unsigned long Serial, unsigned char InnerCh, StMPXCANParam * Param) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of target MicroPeckerX device |
| unsigned char | InnerCh | in | Target CH number (1 or 2) | |
| StMPXCANParam * | Param | in | Pointer to parameter setting structure | |
| Return value | ER | E_OK | Success | |
| E_PARAM | Parameter error | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Sets CAN or CAN FD communication parameters on the CH specified by Serial and InnerCh, using values in Param. | |||
| Note | Calling 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.
| Format | ER MPXCANGetLogEx(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 target MicroPeckerX device |
| unsigned char | InnerCh | in | Target CH number (1 or 2) | |
| StMPXCANLog * | Log | in/out | Log information structure array | |
| unsigned short | Num | in | Number of elements in log structure array | |
| unsigned short * | Count | out | Number of acquired logs | |
| unsigned char * | BufferOver | out | Buffer overrun (see Buffer Overrun Presence) | |
| Return value | ER | E_OK | Success | |
| E_PARAM | Parameter error | |||
| E_DEVICE | Device not found | |||
| Function | Acquires 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. | |||
| Note | This 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.
| Format | ER MPXCANSetSlot(unsigned long Serial, unsigned char InnerCh, StMPXCANSlot * Slots, unsigned char SlotCount) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of target MicroPeckerX device |
| unsigned char | InnerCh | in | Target CH number (1 or 2) | |
| StMPXCANSlot * | Slots | in | Slot information | |
| unsigned char | SlotCount | in | Number of slots to configure | |
| Return value | ER | E_OK | Success | |
| E_PARAM | Parameter error | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Sets 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. | |||
| Note | This 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.
| Format | ER MPXCANChangeSlot(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 target MicroPeckerX device |
| unsigned char | InnerCh | in | Target CH number (1 or 2) | |
| unsigned char | SlotNo | in | Target slot number (1 to 28) | |
| unsigned char | SlotEnabled | in | Slot enable/disable (see CAN Slot Enable/Disable) | |
| unsigned char | ReqInfo | in | Request information for slot change (see CAN Slot Change Request Info) | |
| StMPXCANFrame * | Frame | in | Pointer to frame attribute structure | |
| Return value | ER | E_OK | Success | |
| E_PARAM | Parameter error | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_TRG_BUSY | Trigger configuration failed | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Changes CAN or CAN FD slot information specified by SlotNo on the CH specified by Serial and InnerCh. | |||
| Note | This 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.
| Format | ER MPXCANSendSlot(unsigned long Serial, unsigned char InnerCh, unsigned char SlotNo) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of target MicroPeckerX device |
| unsigned char | InnerCh | in | Target CH number (1 or 2) | |
| unsigned char | SlotNo | in | Target slot number (1 to 28) | |
| Return value | ER | E_OK | Success | |
| E_PARAM | Parameter error | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_TRG_BUSY | Trigger configuration failed | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Issues a send request to the slot specified by SlotNo on the CH specified by Serial and InnerCh. | |||
| Note | This 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.
| Format | ER MPXCANDirectSend(unsigned long Serial, unsigned char InnerCh, StMPXCANDirect * Frame) | |||
|---|---|---|---|---|
| Argument | unsigned long | Serial | in | Serial number of target MicroPeckerX device |
| unsigned char | InnerCh | in | Target CH number (1 or 2) | |
| StMPXCANDirect * | Frame | in | Transmit frame | |
| Return value | ER | E_OK | Success | |
| E_PARAM | Parameter error | |||
| E_DEVICE | Device not found | |||
| E_COMM | Communication error | |||
| E_DCT_FULL | No free buffer for direct transmission | |||
| E_STATUS | Status error | |||
| E_TIMEOUT | Communication timeout | |||
| Function | Issues a direct transmission request for the frame specified by Frame on the CH specified by Serial and InnerCh, without using slots. | |||