Skip to content

Instantly share code, notes, and snippets.

@chintanp
Last active February 10, 2016 20:22
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 chintanp/3c8efb788e1cb80c505d to your computer and use it in GitHub Desktop.
Save chintanp/3c8efb788e1cb80c505d to your computer and use it in GitHub Desktop.
The node implementation to interact with ELCON charger over CANBus
var can = require('socketcan');
var channel = can.createRawChannel("can0");
// id is the device id, data represents data that has to be written
var canmsg = { id: 403105268, data: new Buffer([ 0, 0xFA, 0, 0x32, 0, 0, 0, 0 ]), "ext" : true };
// Log any message
//channel.addListener("onMessage", function(msg) { console.log(msg); } );
// Reply any message
//channel.addListener("onMessage", channel.send, channel);
channel.start();
setInterval(function() {
channel.send(canmsg);
console.log("Written to CAN device");
}, 500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment