サイト内検索

検索

Shares

Table of Content

CAN.beginTransmission()

[CANBus]

説明

Initialize transmission state.
Note: Usage for this function is similar to the beginTransmission() function for Wire. Immediately after calling this function, the write() 入力と endTransmission() functions must be called to complete the transmission task.

構文

CAN.beginTransmission(id)
CAN.beginTransmission(id, ext)

媒介変数

  • id: External CAN device ID
  • ext: Data transmission format. This parameter is not needed for the function to work. When not set, the default, CAN_STDID, is used.
    • CAN_STDID: Standard data frame, comply with CAN 2.0A standard. ID range: 0 ~ 0x7FF
    • CAN_EXTID: Extended data frame, based on CAN 2.0B standard. ID range: 0 ~ 0x1FFFFFFF
    • CAN_STDID_REMOTE: Standard data frame, comply with CAN 2.0A standard. ID range: 0 ~ 0x7FF
    • CAN_EXTID_REMOTE: Extended data frame, comply with CAN 2.0B standard. ID range: 0 ~ 0x1FFFFFF

戻り値

None

事例

#include <CANBus.h>
unsigned char buf[8] = {0, 1, 2, 3, 4, 5, 6, 7};
 
void setup() {
    Serial.begin(115200);
    CAN.begin(CAN_500KBPS); // Configure CAN bus transmission speed to 500KBPS
}
 
void loop() {
    CAN.beginTransmission(0x00);               // Set the CAN device ID to 0x00, using standard data grame.
    CAN.write(buf, 8);                         // Sent 8 bytes of data
    CAN.endTransmission();                     // End transmission
    delay(10);
}

See also


Libraries Reference Home

86Duino のリファレンスのテキストは Arduino レファレンス を編集したもので、 Creative Commons Attribution-ShareAlike 3.0 License下でライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。

上部へスクロール