Skip to content

Instantly share code, notes, and snippets.

@avtehnik
Created September 19, 2019 21:43
Show Gist options
  • Save avtehnik/ee943c3d635a6725687d11ea05ef5295 to your computer and use it in GitHub Desktop.
Save avtehnik/ee943c3d635a6725687d11ea05ef5295 to your computer and use it in GitHub Desktop.
socketcan sender receiver
var can = require('socketcan');
var channel = can.createRawChannel("can0", true);
channel.addListener("onMessage", function(msg) {
console.log(msg.data.toString());
});
channel.start();
var can = require('socketcan');
var channel = can.createRawChannel("can1", true);
var canId = 233688064;
var data = Buffer.from(new Date().toLocaleString().toString());
var index = 0;
setInterval(function(){
var data = Buffer.from(index+"");
channel.send({ id: canId, length: data.length, data: data, ext: true })
console.log(index);
index++;
}, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment