Frame 格式 | 簡稱 | WUP 序列 | 備註 |
---|---|---|---|
Classical CAN Base Frame | CBFF | 1. RTR, IDE, FDF 位元皆 Dominant 2. EOF(Recessive) 3. 再次 RTR, IDE, FDF Dominant | Dominant 脈衝 ≥ 5 µs; Recessive 脈衝 ≥ 5 µs WUP_wake_up_concept_Pra… |
Classical CAN Ext. Frame | CEFF | 1. RTR, IDE, FDF, r0 位元 Dominant 2. EOF(Recessive) 3. 再次 RTR, IDE, FDF, r0 Dominant | 同上 |
CAN-FD Base Frame | FBFF | 1. BRS + IDE 位元 Dominant 2. EOF(Recessive) 3. 再次 BRS + IDE Dominant | bit rate ≤ 400 kb/s; 需使用短濾波時間(tFilter_short) WUP_wake_up_concept_Pra… |
CAN-FD Ext. Frame | FEFF | 1. RRS 或 res 位元 Dominant 2. EOF(Recessive) 3. 再次 RRS 或 res Dominant | bit rate ≤ 200 kb/s; 僅 RRS/res 可保證 Dominant |
using System; using Peak.Can.Basic; using TPCANHandle = System.Byte; // or UInt16 depending on API wrapper using TPCANMsg = Peak.Can.Basic.TPCANMsg; using TPCANMsgFD = Peak.Can.Basic.TPCANMsgFD; using TPCANBaudrate = Peak.Can.Basic.TPCANBaudrate; using TPCANType = Peak.Can.Basic.TPCANType; using TPCANMessageType = Peak.Can.Basic.TPCANMessageType; class CanWakeupPatterns { const TPCANHandle Channel = TPCANHandle.PCAN_USBBUS1; static void Main() { // 1. 初始化 CAN 通道 var status = PCANBasic.Initialize(Channel, TPCANBaudrate.PCAN_BAUD_500K, TPCANType.PCAN_TYPE_ISA); if (status != TPCANStatus.PCAN_ERROR_OK) { Console.WriteLine("初始化失敗: " + status); return; } // 2. 送出 CBFF (Standard frame) var stdMsg = new TPCANMsg { ID = 0x100, // Example standard ID LEN = 0, // DLC = 0 MSGTYPE = TPCANMessageType.PCAN_MESSAGE_STANDARD // Standard, no RTR }; PCANBasic.Write(Channel, ref stdMsg); // 3. 送出 CEFF (Extended frame) var extMsg = new TPCANMsg { ID = 0x1ABCDEF0, // Example extended ID LEN = 0, MSGTYPE = TPCANMessageType.PCAN_MESSAGE_EXTENDED // Extended frame }; PCANBasic.Write(Channel, ref extMsg); // 4. 送出 FBFF (FD standard frame, with bitrate switch) var fdStd = new TPCANMsgFD { ID = 0x100, // Example standard ID DLC = 0, // Length = 0 MSGTYPE = TPCANMessageType.PCAN_MESSAGE_FD // FD frame | TPCANMessageType.PCAN_MESSAGE_STANDARD // Standard ID | TPCANMessageType.PCAN_MESSAGE_BITRATEFAST // Enable BRS }; PCANBasic.WriteFD(Channel, ref fdStd); // 5. 送出 FEFF (FD extended frame, with bitrate switch) var fdExt = new TPCANMsgFD { ID = 0x1ABCDEF0, // Example extended ID DLC = 0, MSGTYPE = TPCANMessageType.PCAN_MESSAGE_FD // FD frame | TPCANMessageType.PCAN_MESSAGE_EXTENDED // Extended ID | TPCANMessageType.PCAN_MESSAGE_BITRATEFAST // Enable BRS }; PCANBasic.WriteFD(Channel, ref fdExt); // 6. 最後記得釋放通道 PCANBasic.Uninitialize(Channel); } }