candle(gs_usb)windows驱动程序的python包装器。
candle-driver的Python项目详细描述
蜡烛驱动程序
candle(gs-usb)windows驱动程序的python包装器,该驱动程序已发布here。
用于与烛光通信,CANable(与烛光通信firmware)can-usb适配器。
示例用法
importcandle_driver# lists all available candle devicesdevices=candle_driver.list_devices()ifnotlen(devices):print('No candle devices found.')exit()print('Found {} candle devices.'.format(len(devices)))# use first availabel devicedevice=devices[0]print('Device path: {}'.format(device.path()))print('Device name: {}'.format(device.name()))print('Device channels: {}'.format(device.channel_count()))# open device (blocks other processes from using it)device.open()print('Device timestamp: %d'%device.timestamp())# in usec# open first channelch=device.channel(0)ch.set_bitrate(1000000)# or# ch.set_timings(prop_seg=1, phase_seg1=12, phase_seg2=2, sjw=1, brp=3)# start receiving datach.start()# normal framech.write(10,b'abcdefgh')# extended framech.write(10235|candle_driver.CANDLE_ID_EXTENDED,b'abcdefgh')# wait 1000ms for datatry:frame_type,can_id,can_data,extended,ts=ch.read(1000)print('Received {} from ID {} at {}'.format(can_data,can_id,ts))exceptTimeoutError:print('CAN read timeout')# close everythingch.stop()device.close()
许可证
这个项目是在麻省理工学院的许可下授权的-请参阅LICENSE.md文件了解详细信息。
windows c driver是在gplv3许可下获得许可的-有关详细信息,请参见LICENSE文件。
致谢
- Hubert Denkmair用于windows c驱动程序。