Performs CAN or CAN FD transmission.
Ret = CanTransmit ( Id , ChannelNo , MessageNum , MessageType , CanId , DataLength , Data )
Id
[ VB.NET: Short ] [ C, C++: short ] [ C#: short ] [ Python: ctypes.c_short ]
Specify the device ID retrieved from CanInit.
ChannelNo
[ VB.NET: UShort ] [ C, C++: unsigned short ] [ C#: ushort ] [ Python: ctypes.c_ushort ]
Specify the channel number.
MessageNum
[ VB.NET: UInteger ] [ C, C++: unsigned long ] [ C#: uint ] [ Python: ctypes.c_uint ]
Specify the number of messages to send.
For details, please refer to the Specifications based on devices section.
MessageType
[ VB.NET: UInteger ] [ C, C++: unsigned long * ] [ C#: ref uint
] [ Python: ctypes.POINTER(ctypes.c_uint) ]
Specify the send message type in a one-dimensional array.
When specifying multiple message types, perform bitwise operations using
logical OR.
Definition |
Value |
Description |
CCAN_MSG_TYPE_CAN |
0x01 |
CAN message |
CCAN_MSG_TYPE_CAN_FD |
0x02 |
CAN FD message |
CCAN_MSG_TYPE_REMOTE_FRAME |
0x04 |
Remote frame. *Only CAN can be enabled |
CCAN_MSG_TYPE_BITRATE_SWITCH |
0x08 |
Bitrate switch. *Only CAN FD can be enabled |
CCAN_MSG_TYPE_EXTENDED_FORMAT |
0X20 |
Extended format |
CanId [
VB.NET: UInteger ] [ C, C++: unsigned long * ] [ C#: ref uint ] [ Python: ctypes.POINTER(ctypes.c_uint) ]
Specify the transmission CAN ID in a one-dimensional array.
If standard format is specified, specify
with base ID (11bit).
Valid specification range is 0x000 to 0x7FF.
If extended format is specified, specify
it as extended ID + base ID (29 bits in total).
Valid specification range is 0x000 to 0x1FFFFFFF.
CanId bit number |
31 |
30 |
29 |
28 |
27 |
26 |
25 |
24 |
23 |
22 |
21 |
20 |
19 |
18 |
17 |
16 |
15 |
14 |
13 |
12 |
11 |
10 |
09 |
08 |
07 |
06 |
05 |
04 |
03 |
02 |
01 |
00 |
Extended ID/Base ID |
- |
- |
- |
Extended ID |
Base ID |
|||||||||||||||||||||||||||
Bit number of each ID |
- |
- |
- |
17 |
16 |
15 |
14 |
13 |
12 |
11 |
10 |
09 |
08 |
07 |
06 |
05 |
04 |
03 |
02 |
01 |
00 |
10 |
09 |
08 |
07 |
06 |
05 |
04 |
03 |
02 |
01 |
00 |
DataLength
[ VB.NET: UShort ] [ C, C++: unsigned short * ] [ C#: ref ushort
] [ Python: ctypes.POINTER(ctypes.c_ushort) ]
Specify the sending message data length in a one-dimensional array.
If CAN communication is specified, valid
specification ranges are 0 to 8.
If CAN FD communication is specified, valid specification ranges are 0
to 8, and 12, 16, 20, 24, 32, 48, 64.
Data [
VB.NET: Byte ] [ C, C++: unsigned char * ] [ C#: ref byte ] [ Python: ctypes.POINTER(ctypes.c_ubyte) ]
Specify the sending data in a two-dimensional array.
The number of elements (number of columns) of the two-dimensional array
is 64.
If the data length (DataLength) of all messages
is 0, specify the NULL character.
Ret [ VB.NET: Integer ] [ C, C++: long ] [ C#: int ] [ Python: ctypes.c_long ]
Definition |
Value |
Description |
CAN_ERR_SUCCESS |
0 |
Normality completion |
CAN_ERR_SYS_RECOVERED_FROM_STANDBY |
7 |
Execute CanResetDevice function because the device has recovered from standby mode. |
CAN_ERR_DLL_INVALID_ID |
10001 |
Invalid ID specified. |
CAN_ERR_DLL_CALL_DRIVER |
10002 |
Driver can't be called (Failed in the device I/O control). |
CAN_ERR_DLL_BUFF_ADDRESS |
10100 |
Invalid data buffer address. |
CAN_ERR_SYS_CH_NO |
20101 |
Channel number is outside the settable range |
CAN_ERR_SYS_MESSAGE_NUM |
20150 |
The number of messages is outside the settable range. |
CAN_ERR_SYS_MESSAGE_TYPE |
20151 |
The messages type is outside the settable range. |
CAN_ERR_SYS_DATA_LEN |
20160 |
Data length is outside the settable range. |
CAN_ERR_SYS_CAN_ID |
20170 |
CAN ID is outside the settable range. |
CAN_ERR_SYS_TIMEOUT_TIME |
20180 |
The timeout time is outside the settable range. |
CAN_ERR_SYS_BUSOFF |
20201 |
Cannot execute because the bus is off. |
CAN_ERR_SYS_BUS_DISCONNECT |
20202 |
Cannot execute because the bus is disconnected. |
CAN_ERR_SYS_TIMEOUT |
20250 |
A timeout occurred |
The others (See also: Details of Error Code)
None
Performs CAN or CAN FD transmission.
For message type (MessageType), CAN ID (CanId),
and data length (DataLength), allocate memory in a one-dimensional array,
specify numerical values, and take the start addresses as arguments.
Image of one-dimensional array:
Array variable name[message number] |
Element value (example) |
MessageType[0] |
CCAN_MSG_TYPE_CAN |
MessageType[1] |
CCAN_MSG_TYPE_CAN |
MessageType[2] |
CCAN_MSG_TYPE_CAN |
MessageType[3] |
CCAN_MSG_TYPE_CAN |
・・・ |
・・・ |
MessageType[MessageNum - 1] |
CCAN_MSG_TYPE_CAN |
Memory is allocated for the sending data
(Data) as a two-dimensional array with 64 elements, and the start address
is taken as an argument.
Image of two-dimensional array:
Array variable name[message number][(element number)] |
Value of element 01 |
Value of element 02 |
Value of element 03 |
・・・ |
Value of element 64 |
Data[0][] |
Data[0][0] |
Data[0][1] |
Data[0][2] |
・・・ |
Data[0][63] |
Data[1][] |
Data[1][0] |
Data[1][1] |
Data[1][2] |
・・・ |
Data[1][63] |
Data[2][] |
Data[2][0] |
Data[2][1] |
Data[2][2] |
・・・ |
Data[2][63] |
Data[3][] |
Data[3][0] |
Data[3][1] |
Data[3][2] |
・・・ |
Data[3][63] |
・・・ |
・・・ |
・・・ |
・・・ |
・・・ |
・・・ |
Data[MessageNum - 1][] |
Data[MessageNum - 1][0] |
Data[MessageNum - 1][1] |
Data[MessageNum - 1][2] |
・・・ |
Data[MessageNum - 1][63] |
Model No. |
Arguments |
Content |
CAN-4P-PE |
MessageNum |
The setting should be 1 only. |
CAN-2-USB |
MessageNum |
The setting range is 1 to 90. |
Perform CAN transmission from ChannelNo = 1. MessageNum =1, MessageType = CCAN_MSG_TYPE_CAN, CAN ID = 0x11c, DataLength = 1, Data = 0xff
VB.NET |
Dim Ret As Integer Dim MessageType(0) As UInteger Dim CanId(0) As UInteger Dim DataLength(0) As UShort Dim Data(0)(63) As Byte
MessageType(0) = CCAN_MSG_TYPE_CAN CanId(0) = &H11C Data(0)(0) = &HFF
Ret = CanTransmit ( Id
, 1 , 1 , MessageType , CanId , Data ) |
C, C++ |
long Ret; unsinged long MessageType[1]; unsinged long CanId[1]; unsinged short DataLength[1]; unsinged char Data[1][64];
MessageType[0] = CCAN_MSG_TYPE_CAN; CanId[0] = 0x11c; Data[0][0] = 0xff;
|
C# |
int Ret; uint[] MessageType = new unit[1]; uint[] CanId = new uint[1]; ushort[] DataLength = new ushort[1]; ubyte[,] Data = new ubyte[1,64];
MessageType[0] = CCAN_MSG_TYPE_CAN; CanId[0] = 0x11c; Data[0,0] = 0xff;
|
Python |
Ret = ctypes.c_long() MessageTypeType = ctypes.c_uint() * 1 MessageType = MessageTypeType() CanIdType = ctypes.c_uint() * 1 CanId = CanIdType() DataLengthType = ctypes.c_ushort() *1 DataLength = DataLengthType() SingleDataType = ctypes.c_ubyte() * 64 DataType = ctypes.SingleDataType * 1 Data = DataType()
MessageType[0] = ccan.CCAN_MSG_TYPE_CAN CanId[0] = 0x11c Data[0][0] = 0xff
Ret.value = ccan.CanTransmit ( Id , 1 , 1 , MessageType , CanId , Data )
|