Code Monkey home page Code Monkey logo

candle_driver's Introduction

candle_driver

Python wrapper for the candle (gs_usb) windows driver which is published here.

Used to communicate with candleLight, CANable (with candleLight firmware) CAN-USB adapters.

Example usage

import candle_driver

# lists all available candle devices
devices = candle_driver.list_devices()

if not len(devices):
  print('No candle devices found.')
  exit()

print('Found {} candle devices.'.format(len(devices)))

# use first availabel device
device = 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 channel
ch = 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 data
ch.start()

# normal frame
ch.write(10, b'abcdefgh')
# extended frame
ch.write(10235 | candle_driver.CANDLE_ID_EXTENDED, b'abcdefgh')

# wait 1000ms for data
try:
  frame_type, can_id, can_data, extended, ts = ch.read(1000)
  print('Received {} from ID {} at {}'.format(can_data, can_id, ts))
except TimeoutError:
  print('CAN read timeout')

# close everything
ch.stop()
device.close()

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Windows C driver is licensed under the GPLv3 License - see the LICENSE file for details.

Acknowledgments

candle_driver's People

Contributors

chemicstry avatar tgiv014 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.