# gcan-driver **Repository Path**: blockish/gcan-driver ## Basic Information - **Project Name**: gcan-driver - **Description**: 广成USBCAN驱动,python-can集成 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 1 - **Created**: 2023-12-01 - **Last Updated**: 2026-01-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # This is the python wrapper for GCAN driver ## How To Use ### without python-can ```python from gcan import GCan, DeviceType, CAN_FRAME can = GCan(DeviceType.USBCAN2, 0) can.OpenDevice() can.InitCAN(0, bitrate=500_000) can.StartCAN(0) frames = (CAN_FRAME * 1)() frames[0].ID = 0x00 frames[0].SendType = 0x00 frames[0].RemoteFlag = 0x00 frames[0].ExternFlag = 0x01 frames[0].DataLen = 0x08 for i in range(8): frames[0].Data[i] = i can.Transmit(0, frames) # do other thing can.ResetCAN(0) can.CloseDevice() ``` ### with python-can * move `gcan.py` to python-can library path: `interfaces` * add `"gcan", ` to `interfaces/__init__.py`'s `__all__` * add `"gcan": ("can.interfaces.gcan", "GCanBus"),` to `interfaces/__init__.py`'s `BACKENDS` ```python import can from gcan import DeviceType with can.Bus(interface="gcan", device_type=DeviceType.USBCAN2, device_index=0, configs=[ {"bitrate": 500_000}, {"bitrate": 1_000_000} ]) as bus: print(bus.recv()) ```