Skip to content

Observable can bus driver, created to speed up development and to provide callbacks to canbus data

Notifications You must be signed in to change notification settings

Huracan-Marine-s-r-l/observable_canbusdriver

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Observable CAN BUS Driver

  • This is a linux "driver" that can be used to listen to can bus events
  • The notification follows the Observer design pattern
  • The canlistener runs in a separate thread

usage

# motor example
from listener import listener, motor
from canobservable import canlisten

# connect to canbus interface
canbus = canlisten(
    interface   = "can",
    baudrate    = 250000
)

# listening the motor at this channels
m = motor(
    desc        = "motor", 
    on          = [0x00, 0x11, 0x55, 0x88]
)

canbus.add_listener(m)

# log
print(canbus)
input("PRESS RETURN to continue :>")

# create can thread
canbus.start()

Replay

  • You can replay canbus logs using canfilereplay
from canfilereplay import *

canreplay = canlistenfromfile(
    pathtofile = "{___PATH_TO_FILE__}",
    replayfrequency = 0.1
)

canreplay.add_listener(
    motor(
        desc = "motor", 
        on = [0x500, 0x460]
    )
)

print(canreplay)
canreplay.start()

run

sudo pip install python-can
sudo python3 main.py 

About

Observable can bus driver, created to speed up development and to provide callbacks to canbus data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.7%
  • C++ 0.3%