Comparing version 1.1.1 to 1.2.0
@@ -26,2 +26,3 @@ /* Copyright Sebastian Haas <sebastian@sebastianhaas.info>. All rights reserved. | ||
var can = require('./build/Release/can'); | ||
var buffer = require('buffer'); | ||
@@ -153,7 +154,7 @@ // Exports | ||
rtr: false, | ||
data: [] | ||
data: new Buffer(m.length) | ||
} | ||
for (var i = 0; i < m.length; i++) | ||
canmsg.data.push(0); | ||
canmsg.data[i] = 0; | ||
@@ -160,0 +161,0 @@ for (i in m.signals) { |
@@ -8,3 +8,3 @@ { | ||
"description": "A SocketCAN abstraction layer for NodeJS.", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"repository": { | ||
@@ -11,0 +11,0 @@ "type": "git", |
var util = require('util') | ||
var can = require('can'); | ||
var buffer = require('buffer'); | ||
var cname = "vcan0" | ||
var channel = can.createRawChannel(cname, true); | ||
var c1 = can.createRawChannel("vcan0"); | ||
var c2 = can.createRawChannel("vcan0"); | ||
var counter = 0; | ||
// Log any message | ||
channel.addListener("onMessage", function(msg) { | ||
var str; | ||
c1.addListener("onMessage", function(msg) { | ||
counter++; | ||
}); | ||
util.format("%s"); | ||
setInterval(function() { | ||
console.log(counter); | ||
counter = 0; | ||
}, 1000); | ||
console.log(str); | ||
}); | ||
c1.start(); | ||
c2.start(); | ||
channel.start(); | ||
setInterval(function() { | ||
c2.send({ id: 10, data: new Buffer([1,2,3,4,5,6,7,8])}); | ||
}, 1); | ||
var can = require('can'); | ||
var buffer = require('buffer'); | ||
@@ -22,3 +23,3 @@ exports['channel_creation'] = function(test) { | ||
var canmsg = { id: 10, data: [ 0 ] }; | ||
var canmsg = { id: 10, data: new Buffer([ 0, 0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF7 ]) }; | ||
@@ -28,2 +29,3 @@ var rx_count = 0; | ||
c1.addListener("onMessage", function(msg) { | ||
console.log(msg); | ||
test.equal(msg.data[0], rx_count); | ||
@@ -30,0 +32,0 @@ rx_count++; |
var signals = require('../build/Release/can_signals'); | ||
var buffer = require('buffer') | ||
exports['little_endian_encode'] = function(test) { | ||
data = [0, 0, 0, 0, 0, 0, 0, 0]; | ||
data = new Buffer([0, 0, 0, 0, 0, 0, 0, 0]); | ||
signals.encode_signal(data, 0, 1, true, false, 1); | ||
console.log(data); | ||
signals.encode_signal(data, 1, 1, true, false, 1); | ||
signals.encode_signal(data, 2, 1, true, false, 0); | ||
console.log(data); | ||
signals.encode_signal(data, 2, 1, true, false, 0 /* set zero */); | ||
console.log(data); | ||
signals.encode_signal(data, 3, 1, true, false, 1); | ||
console.log(data); | ||
test.deepEqual(data, [0xD0, 0x00, 0x00, 0, 0, 0, 0, 0]); | ||
/* | ||
signals.encode_signal(data, 4, 8, true, false, 0xEA); | ||
@@ -20,3 +25,3 @@ test.deepEqual(data, [0xDE, 0xA0, 0x00, 0, 0, 0, 0, 0]); | ||
test.deepEqual(data, [0xDE, 0xA0, 0x00, 0, 0, 0, 0, 0], "Overwriting signal value failed"); | ||
*/ | ||
test.done(); | ||
@@ -26,3 +31,3 @@ } | ||
exports['little_endian_decode'] = function(test) { | ||
data = [0xDE, 0xAD, 0xBE, 0xEF, 0xCA, 0xFE, 0xBA, 0xBE]; | ||
data = new Buffer([0xDE, 0xAD, 0xBE, 0xEF, 0xCA, 0xFE, 0xBA, 0xBE]); | ||
@@ -46,3 +51,3 @@ test.equals(signals.decode_signal(data, 0, 8, true, false), 0xDE); | ||
exports['little_endian_signed_decode'] = function(test) { | ||
data = [0xFE, 0xFF, 0x80]; | ||
data = new Buffer([0xFE, 0xFF, 0x80]); | ||
@@ -57,3 +62,3 @@ test.equals(signals.decode_signal(data, 8, 8, true, true), -1); | ||
exports['little_endian_signed_encode'] = function(test) { | ||
data = [0, 0, 0, 0, 0, 0, 0, 0]; | ||
data = new Buffer([0, 0, 0, 0, 0, 0, 0, 0]); | ||
@@ -73,3 +78,3 @@ signals.encode_signal(data, 0, 8, true, true, -1); | ||
exports['big_endian_encode'] = function(test) { | ||
data = [0, 0, 0, 0, 0, 0, 0, 0]; | ||
data = new Buffer([0, 0, 0, 0, 0, 0, 0, 0]); | ||
@@ -95,3 +100,3 @@ signals.encode_signal(data, 0, 1, false, false, 1); | ||
exports['big_endian_decode'] = function(test) { | ||
data = [0xDE, 0xAD, 0xBE, 0xEF, 0xCA, 0xFE, 0xBA, 0xBE]; | ||
data = new Buffer([0xDE, 0xAD, 0xBE, 0xEF, 0xCA, 0xFE, 0xBA, 0xBE]); | ||
@@ -110,3 +115,3 @@ test.equals(signals.decode_signal(data, 7, 8, false, false), 0xDE); | ||
exports['big_endian_signed_encode'] = function(test) { | ||
data = [0, 0, 0, 0, 0, 0, 0, 0]; | ||
data = new Buffer([0, 0, 0, 0, 0, 0, 0, 0]); | ||
@@ -126,3 +131,3 @@ signals.encode_signal(data, 7, 8, false, true, -1); | ||
exports['big_endian_signed_decode'] = function(test) { | ||
data = [0xFF, 0xFE, 0x80 ]; | ||
data = new Buffer([0xFF, 0xFE, 0x80 ]); | ||
@@ -129,0 +134,0 @@ test.equals(signals.decode_signal(data, 7, 8, false, true), -1); |
var can = require('can'); | ||
var fs = require('fs'); | ||
var buffer = require('buffer'); | ||
@@ -14,3 +15,3 @@ exports['receive_signals'] = function(test) { | ||
var cm = { data: [ 0 ]}; | ||
var cm = { data: new Buffer([ 0 ]) }; | ||
cm.id = db.messages["CruiseControlStatus"].id; | ||
@@ -17,0 +18,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
7417427
30
509