Git Product home page Git Product logo

node-can4linux's Introduction

can4linux for Node.js

Dependency Status


This is simple wrapper for can4linux library. It provides methods only for reading and sending CAN messages. There is no option for setting baud rate etc. For support you can open a github issue.

Installation Instructions

You have to have everything in place for compiling native modules for node. Of course you also have to compile and start can4linux kernel module. Then installation is easy:

npm install can4linux

Usage

var Can = require('can4linux');

var can = new Can({
  device: '/dev/can0', //CAN device to use, can be omitted
  self: false, // turn to true to see message send by this device (with false only incomming messages are shown), can be omitted
});

can.on('data', function(data){
  console.log(data.id);   // CAN id
  console.log(data.ext);  // Is this extended id?
  console.log(data.rtr);  // Is this RTR message
  console.log(data.data); // Array with CAN data
  console.log(data.self); // Is this message send by this device?
  console.log(data.timestamp.sec + "s " + data.timestamp.usec + "us") // Timestamp
});

can.on('error', function(err){
  console.log("Error received", err);
  can.close();
});

can.send({
  id: 5,          // CAN id
  ext: false,     // Is this extended id?
  rtr: false,     // Is this RTR message
  data: [1,2,3]   // Max 8 bytes unless you have CAN FD enabled, can be omitted
});

Tested on BananaPi M1

node-can4linux's People

Contributors

probakowski avatar

Watchers

 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.