New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

socketcan

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

socketcan - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

tests/test-parsing.js

30

docs/data.json

@@ -41,3 +41,3 @@ {

"file": "socketcan.js",
"line": 205,
"line": 203,
"description": "The Signals modules provides an interface to access the values/signals\nencoded in CAN messages."

@@ -82,3 +82,3 @@ }

"file": "socketcan.js",
"line": 136,
"line": 134,
"description": "Just a container to keep the Signals."

@@ -97,3 +97,3 @@ },

"file": "socketcan.js",
"line": 205,
"line": 203,
"description": "A DatabaseService is usually generated once per bus to collect signals\ncoded in the CAN messages according a DB description.",

@@ -172,3 +172,3 @@ "is_constructor": 1,

"file": "socketcan.js",
"line": 97,
"line": 95,
"description": "Keep track of listeners who want to be notified if this signal changes",

@@ -188,3 +188,3 @@ "itemtype": "method",

"file": "socketcan.js",
"line": 107,
"line": 105,
"description": "Set new value of this signal. Any local registered clients will\nreceive a notification. Please note, no CAN message is actually\nsend to the bus (@see DatabaseServer::send)",

@@ -205,3 +205,3 @@ "itemtype": "method",

"file": "socketcan.js",
"line": 142,
"line": 140,
"description": "CAN identifier",

@@ -216,3 +216,3 @@ "itemtype": "attribute",

"file": "socketcan.js",
"line": 149,
"line": 147,
"description": "Extended Frame Format used",

@@ -227,3 +227,3 @@ "itemtype": "attribute",

"file": "socketcan.js",
"line": 156,
"line": 154,
"description": "Symbolic name",

@@ -238,3 +238,3 @@ "itemtype": "attribute",

"file": "socketcan.js",
"line": 163,
"line": 161,
"description": "Length in bytes of resulting CAN message",

@@ -249,3 +249,3 @@ "itemtype": "attribute",

"file": "socketcan.js",
"line": 171,
"line": 169,
"description": "This is the time frame that the message gets generated",

@@ -260,3 +260,3 @@ "itemtype": "attribute",

"file": "socketcan.js",
"line": 179,
"line": 177,
"description": "This is tells us the message is mutliplexed.",

@@ -271,3 +271,3 @@ "itemtype": "attribute",

"file": "socketcan.js",
"line": 187,
"line": 185,
"description": "Named array of signals within this message. Accessible via index and name.",

@@ -283,3 +283,3 @@ "itemtype": "attribute",

"file": "socketcan.js",
"line": 218,
"line": 216,
"description": "Named array of known messages. Accessible via index and name.",

@@ -294,3 +294,3 @@ "itemtype": "attribute",

"file": "socketcan.js",
"line": 282,
"line": 279,
"description": "Construct a CAN message and encode all related signals according\nthe rules. Finally send the message to the bus.",

@@ -310,3 +310,3 @@ "itemtype": "method",

"file": "socketcan.js",
"line": 346,
"line": 343,
"itemtype": "method",

@@ -313,0 +313,0 @@ "name": "parseNetworkDescription",

@@ -8,3 +8,3 @@ {

"description": "A SocketCAN abstraction layer for NodeJS.",
"version": "2.1.2",
"version": "2.1.3",
"license": "MIT",

@@ -11,0 +11,0 @@ "repository": {

@@ -31,5 +31,5 @@ /* Copyright Sebastian Haas <sebastian$sebastianhaas.info>. All rights reserved.

var data = fs.readFileSync(file);
var parser = new xml2js.Parser({explicitArray: true});
parser.parseString(data, function(e, i) {

@@ -42,7 +42,7 @@ result.nodes = {};

var node = d['Node'][n]['$'];
result.nodes[node['id']] = {};
result.nodes[node['id']].name = node['name'];
result.nodes[node['id']].buses = {};
result.nodes[node['id']].device = node['device'];
result.nodes[node['id']].device = node['device'];
result.nodes[node['id']].J1939 = {

@@ -55,3 +55,3 @@ 'AAC' : node['J1939AAC'],

'System' : node['J1939System'],
'Manufacture': node['J1939ManufacturerCode'],
'Manufacture': node['J1939ManufacturerCode'],
getName : function(){

@@ -61,20 +61,20 @@ var name = new Buffer(8);

name[6] = (this.System) << 1 & 0xFE;
name[5] = this.Function & 0xFF;
name[4] = 0; // function Instance & ECU instance
name[5] = this.Function & 0xFF;
name[4] = 0; // function Instance & ECU instance
name[3] = (this.Manufacture >> 3) & 0xFF ;
name[2] = ((this.Manufacture & 0x7) << 5) | ( (this.Identity >> 16) & 0x1F );
name[1] = (this.Identity >> 8 ) & 0xFF;
name[0] = this.Identity & 0xFF;
name[2] = ((this.Manufacture & 0x7) << 5) | ( (this.Identity >> 16) & 0x1F );
name[1] = (this.Identity >> 8 ) & 0xFF;
name[0] = this.Identity & 0xFF;
return name;
},
},
}
}
result.buses = {};
for (b in d['Bus']) {
var bus = d['Bus'][b]['$'];
result.buses[bus['name']] = {};

@@ -87,6 +87,5 @@ var new_bus = result.buses[bus['name']];

var producers = d['Bus'][b]['Message'][m]['Producer'];
var consumers = d['Bus'][b]['Message'][m]['Consumer'];
var multiplex = d['Bus'][b]['Message'][m]['Multiplex'];
var _m = {

@@ -102,49 +101,36 @@ name: message.name,

// Add messages going out and from whom.
// Add messages going out and from whom.
for (p in producers) {
for (n in producers[p]['NodeRef']) {
var id = producers[p]['NodeRef'][n]['$']['id'];
if (result.nodes[id])
{
if (result.nodes[id].buses[bus['name']] == undefined)
result.nodes[id].buses[bus['name']] = { produces: [], consume: []}
result.nodes[id].buses[bus['name']].produces.push(_m);
result.nodes[id].buses[bus['name']] = { produces: [], consumes: []}
result.nodes[id].buses[bus['name']].produces.push(_m.id);
}
}
}
// Add listeners / targets for the message.
for (c in consumers) {
for (n in consumers[c]['NodeRef']) {
var id = consumers[c]['NodeRef'][n]['$']['id'];
if (result.nodes[id])
{
if (result.nodes[id].buses[bus['name']] == undefined)
result.nodes[id].buses[bus['name']] = { produces: [], consume: []}
result.nodes[id].buses[bus['name']].consumes.push(_m);
}
}
}
if (!_m.interval)
_m.interval = 0;
new_bus['messages'].push(_m);
_m.signals = [];
var maxOffset = 0;
// look for multiplexed messages
// look for multiplexed messages
for ( mux in multiplex ){
for (mg in multiplex[mux]['MuxGroup'] ){
var muxmsg = multiplex[mux]['MuxGroup'][mg]['$'];
for (s in multiplex[mux]['MuxGroup'][mg]['Signal']) {
var signal = multiplex[mux]['MuxGroup'][mg]['Signal'][s]['$'];
var value = multiplex[mux]['MuxGroup'][mg]['Signal'][s]['Value'];
var labelset = multiplex[mux]['MuxGroup'][mg]['Signal'][s]['LabelSet'];
var _s = {

@@ -157,8 +143,8 @@ name: signal.name,

labels : {},
};
// add Values from the database
};
// add Values from the database
if (Array.isArray(value)) {
_s.slope = value[0]['$'].slope ? parseFloat(value[0]['$'].slope) : 1.0;
_s.intercept = value[0]['$'].intercept ? parseFloat(value[0]['$'].intercept) : 0.0;
_s.units = value[0]['$'].units ? value[0]['$'].units : "";
_s.unit = value[0]['$'].unit ? value[0]['$'].unit : "";
_s.minValue = value[0]['$'].min ? value[0]['$'].min : undefined;

@@ -168,12 +154,12 @@ _s.maxValue = value[0]['$'].max ? value[0]['$'].max : undefined;

_s.defaultValue = value[0]['$'].defaultValue ? parseFloat(value[0]['$'].defaultValue) : 0.0 ;
// add label sets from the database.
if( Array.isArray( value[0].LabelSet )){
var labels = value[0].LabelSet[0]['Label'];
for ( var i =0 ; i < labels.length; i++ ){
_s.labels[labels[i]['$'].value] = labels[i]['$'].name ;
}
}
// add label sets from the database.
if (Array.isArray(labelset)) {
var labels = labelset[0]['Label'];
for ( var i = 0 ; i < labels.length; i++ ) {
_s.labels[labels[i]['$'].value] = labels[i]['$'].name;
}
}
var offset_num = parseInt(signal.offset) + _s.bitLength;

@@ -185,14 +171,15 @@

_s.bitOffset = parseInt(signal.offset);
_m.signals.push(_s);
}
}
}
for (s in d['Bus'][b]['Message'][m]['Signal']) {
var signal = d['Bus'][b]['Message'][m]['Signal'][s]['$'];
var value = d['Bus'][b]['Message'][m]['Signal'][s]['Value'];
var labelset = d['Bus'][b]['Message'][m]['Signal'][s]['LabelSet'];
var consumers = d['Bus'][b]['Message'][m]['Signal'][s]['Consumer'];
var _s = {

@@ -205,7 +192,7 @@ name: signal.name,

};
// add Values from the database
// add Values from the database
if (Array.isArray(value)) {
_s.slope = value[0]['$'].slope ? parseFloat(value[0]['$'].slope) : 1.0;
_s.intercept = value[0]['$'].intercept ? parseFloat(value[0]['$'].intercept) : 0.0;
_s.units = value[0]['$'].units ? value[0]['$'].units : "";
_s.unit = value[0]['$'].unit ? value[0]['$'].unit : "";
_s.minValue = value[0]['$'].min ? value[0]['$'].min : undefined;

@@ -215,11 +202,27 @@ _s.maxValue = value[0]['$'].max ? value[0]['$'].max : undefined;

_s.defaultValue = value[0]['$'].defaultValue ? parseFloat(value[0]['$'].defaultValue) : 0.0 ;
// add label sets from the database.
if( Array.isArray( value[0].LabelSet )){
var labels = value[0].LabelSet[0]['Label'];
for ( var i =0 ; i < labels.length; i++ ){
_s.labels[labels[i]['$'].value] = labels[i]['$'].name ;
}
// add label sets from the database.
if (Array.isArray(labelset)) {
var labels = labelset[0]['Label'];
for ( var i = 0 ; i < labels.length; i++ ){
_s.labels[labels[i]['$'].value] = labels[i]['$'].name;
}
}
// Add listeners / targets for the message.
for (c in consumers) {
for (n in consumers[c]['NodeRef']) {
var id = consumers[c]['NodeRef'][n]['$']['id'];
if (result.nodes[id])
{
if (result.nodes[id].buses[bus['name']] == undefined)
result.nodes[id].buses[bus['name']] = { produces: [], consumes: []}
result.nodes[id].buses[bus['name']].consumes.push({ id: _m.id, signal_name: _s.name });
}
}
}
var offset_num = parseInt(signal.offset) + _s.bitLength;

@@ -234,3 +237,3 @@

}
if (!_m.length) {

@@ -246,4 +249,4 @@ _m.length = parseInt(maxOffset / 8);

// NOTE: Not sure if it is safe here to access result, but I guess parsing the XML file is more or less synchronous.
return result;
}

@@ -72,3 +72,3 @@ /* Copyright Sebastian Haas <sebastian@sebastianhaas.info>. All rights reserved.

this.units = desc['units'];
this.unit = desc['unit'];

@@ -91,5 +91,3 @@ /**

*/
this.value = desc['defaultValue'];
if (!this.value)
this.value = 0;
this.value = null;

@@ -252,3 +250,2 @@ this.listeners = [];

{
console.log("Message ID " + msg.id + " not found");
return;

@@ -255,0 +252,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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc