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 (G++), CAN Simulation (G++), CAN Simulation (Python) |
| MPXCANGetLogEx | Buffer Overrun Presence | StMPXCANLog | NONE/MON/SIM | CAN Monitor Sample (G++) |
| MPXCANSetSlot | CAN Frame Type, CAN Transmission Trigger Type | StMPXCANSlot | PARAM/SYNC | CAN Simulation (G++) |
| MPXCANChangeSlot | CAN Slot Enable/Disable, CAN Slot Change Request Info | StMPXCANFrame | SIM | CAN Simulation (G++) |
| MPXCANSendSlot | CAN Frame Type | - | SIM | CAN Simulation (G++) |
| MPXCANDirectSend | CAN ID Format, CAN Remote Transmission Request | StMPXCANDirect | SIM | CAN Simulation (G++), CAN Simulation (Python) |
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(uint32_t Serial, uint8_t InnerCh, StMPXCANParam * Param) | |||
|---|---|---|---|---|
| Argument | uint32_t | Serial | in | Serial number of target MicroPeckerX device |
| uint8_t | 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(uint32_t Serial, uint8_t InnerCh, StMPXCANLog * Log, uint16_t Num, uint16_t * Count, uint8_t * BufferOver) | |||
|---|---|---|---|---|
| Argument | uint32_t | Serial | in | Serial number of target MicroPeckerX device |
| uint8_t | InnerCh | in | Target CH number (1 or 2) | |
| StMPXCANLog * | Log | in/out | Log information structure array | |
| uint16_t | Num | in | Number of elements in log structure array | |
| uint16_t * | Count | out | Number of acquired logs | |
| uint8_t * | 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 | 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(uint32_t Serial, uint8_t InnerCh, StMPXCANSlot * Slots, uint8_t SlotCount) | |||
|---|---|---|---|---|
| Argument | uint32_t | Serial | in | Serial number of target MicroPeckerX device |
| uint8_t | InnerCh | in | Target CH number (1 or 2) | |
| StMPXCANSlot * | Slots | in | Slot information | |
| uint8_t | 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(uint32_t Serial, uint8_t InnerCh, uint8_t SlotNo, uint8_t SlotEnabled, uint8_t ReqInfo, StMPXCANFrame * Frame) | |||
|---|---|---|---|---|
| Argument | uint32_t | Serial | in | Serial number of target MicroPeckerX device |
| uint8_t | InnerCh | in | Target CH number (1 or 2) | |
| uint8_t | SlotNo | in | Target slot number (1 to 28) | |
| uint8_t | SlotEnabled | in | Slot enable/disable (see CAN Slot Enable/Disable) | |
| uint8_t | 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(uint32_t Serial, uint8_t InnerCh, uint8_t SlotNo) | |||
|---|---|---|---|---|
| Argument | uint32_t | Serial | in | Serial number of target MicroPeckerX device |
| uint8_t | InnerCh | in | Target CH number (1 or 2) | |
| uint8_t | 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(uint32_t Serial, uint8_t InnerCh, StMPXCANDirect * Frame) | |||
|---|---|---|---|---|
| Argument | uint32_t | Serial | in | Serial number of target MicroPeckerX device |
| uint8_t | 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. | |||