Skip to main content

Python wrapper for zlgcan-driver-rs.

Project description

ZLGCAN驱动及集成到python-can(因内存模型不同,目前Windows下32位python会报内存非法访问的错误)

  1. 安装python-can

    pip install python-can
    
  2. 找到python-can安装路径

    1. windows下一般不用虚拟环境安装则在python安装路径下Lib/site-packages
    2. linux下一般不用虚拟环境安装则在用户home目录./locals/lib/PythonVersion/Lib目录下
    3. 使用虚拟环境则在虚拟环境下Lib/site-packages
  3. 修改python-can路径下的can/interfaces/__init__.py文件, 在BACKENDS字典中添加一行:

    "zlgcan": ("can.interfaces.zlgcan", "ZCanBus"),
    
    
  4. zlgcan文件夹拷贝到can/interfaces/文件夹下

  5. 安装zlgcan-driver-py库:

    pip install zlgcan-driver-py
    
  6. libary文件夹及bitrate.cfg.yaml文件拷贝到当前工程根目录下

  7. 使用:

    import can
    from can.interfaces.zlgcan import ZCanTxMode, ZCANDeviceType
    
    with can.Bus(interface="zlgcan", device_type=ZCANDeviceType.ZCAN_USBCANFD_200U,
                 configs=[{'bitrate': 500000, 'resistance': 1}, {'bitrate': 500000, 'resistance': 1}]) as bus:
        bus.send(can.Message(
            arbitration_id=0x123,
            is_extended_id=False,
            channel=0,
            data=[0x01, 0x02, 0x03, ],
            dlc=3,
        ), tx_mode=ZCanTxMode.SELF_SR)
    
        # time.sleep(0.1)
        _msg = bus.recv()
        print(_msg)
    
  8. CAN测试列表:

    • USBCAN-I-mini - ZCAN_USBCAN1, ZCAN_USBCAN2
    • USBCAN-4E-U - ZCAN_USBCAN_4E_U
    • USBCANFD-100U-mini - ZCAN_USBCANFD_MINI
    • USBCANFD-100U - ZCAN_USBCANFD_100U
    • USBCANFD-200U - ZCAN_USBCANFD_200U
    • USBCANFD-800U - ZCAN_USBCANFD_800U
  9. 注意事项:

    • ZCAN_USBCAN1及ZCAN_USBCAN2类型的设备无论是windows还是Linux, 波特率支持均在bitrate.cfg.yaml中配置
    • 其他CANFD类型的CAN卡仅仅在Linux上使用时bitrate.cfg.yaml中配置
      • 此时计算相关值可以通过ZCANPRO软件
    • 在Linux上使用ZCAN_USBCAN1衍生CAN卡时, 请在初始化时候设置ZCanDeriveInfo信息
    • 该库主要依赖zlgcan-driver-rs,如有问题,请提issue
  10. 官方工具及文档:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zlgcan_driver_py-0.1.4.tar.gz (16.7 kB view hashes)

Uploaded Source

Built Distributions

zlgcan_driver_py-0.1.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

zlgcan_driver_py-0.1.4-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

zlgcan_driver_py-0.1.4-cp312-none-win_amd64.whl (289.3 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

zlgcan_driver_py-0.1.4-cp312-none-win32.whl (285.5 kB view hashes)

Uploaded CPython 3.12 Windows x86

zlgcan_driver_py-0.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

zlgcan_driver_py-0.1.4-cp311-none-win_amd64.whl (290.3 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

zlgcan_driver_py-0.1.4-cp311-none-win32.whl (286.1 kB view hashes)

Uploaded CPython 3.11 Windows x86

zlgcan_driver_py-0.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

zlgcan_driver_py-0.1.4-cp310-none-win_amd64.whl (290.5 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

zlgcan_driver_py-0.1.4-cp310-none-win32.whl (286.3 kB view hashes)

Uploaded CPython 3.10 Windows x86

zlgcan_driver_py-0.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

zlgcan_driver_py-0.1.4-cp39-none-win_amd64.whl (289.5 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

zlgcan_driver_py-0.1.4-cp39-none-win32.whl (286.8 kB view hashes)

Uploaded CPython 3.9 Windows x86

zlgcan_driver_py-0.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

zlgcan_driver_py-0.1.4-cp38-none-win_amd64.whl (289.3 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

zlgcan_driver_py-0.1.4-cp38-none-win32.whl (287.3 kB view hashes)

Uploaded CPython 3.8 Windows x86

zlgcan_driver_py-0.1.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page