[CANBus]
説明
Transmit data to remote CAN device. (This function is created referencing the CAN bus library from Seeed Studio, Depending on your preferences, you can use this function to transmit data instead of the beginTransmission() and write() functions.)
構文
CAN.sendMsgBuf(id, ext, len, buf)
媒介変数
- id: Device ID for the remote CAN device
- ext: Data transmission format
CAN_STDID
: Standard data frame, comply with CAN 2.0A standard. ID range: 0 ~ 0x7FFCAN_EXTID
: Extended data frame, based on CAN 2.0B standard. ID range: 0 ~ 0x1FFFFFFFCAN_STDID_REMOTE
: Standard data frame, comply with CAN 2.0A standard. ID range: 0 ~ 0x7FFCAN_EXTID_REMOTE
: Extended data frame, comply with CAN 2.0B standard. ID range: 0 ~ 0x1FFFFFF
- len: size of the array
- buf: data array
戻り値
CAN_OK: Data transmitted
CAN_FAIL: Data transmission failed.
事例
#include <CANBus.h> unsigned char buf[8] = {0, 1, 2, 3, 4, 5, 6, 7}; void setup(){ Serial.begin(115200); CAN.begin(CAN_500KBPS); } void loop(){ CAN.sendMsgBuf(0x00, CAN_STDID, 8, buf); // Transmit data // Set remote CAN device ID to 0x00 // Using standard data format //8 bytes of data // buf: data array delay(10); }
See also
Libraries Reference Home
86Duino のリファレンスのテキストは Arduino レファレンス を編集したもので、 Creative Commons Attribution-ShareAlike 3.0 License下でライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。