Skip to content

Instantly share code, notes, and snippets.

@alan707
Last active December 21, 2020 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alan707/f954ce02eb4a2134e2ea66d64331ec46 to your computer and use it in GitHub Desktop.
Save alan707/f954ce02eb4a2134e2ea66d64331ec46 to your computer and use it in GitHub Desktop.
Simple Python CAN Bridge (a.k.a CAN Gateway)
import can
from time import sleep
can_bus_a = can.Bus('can0', bustype='socketcan')
can_bus_b = can.Bus('can1', bustype='socketcan')
try:
for message in can_bus_a:
can_bus_b.send(message)
while True:
sleep(1)
except KeyboardInterrupt:
print("\nProgram Ended")
exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment