Comparing version 0.0.3 to 0.0.4
81
index.js
@@ -46,43 +46,42 @@ const events = require('events'); | ||
this.hid = new HID.HID(this.vendorId, this.productId); | ||
let message = Buffer.from([]); | ||
this.hid.on('data', data => { | ||
clearTimeout(this.timeout); | ||
switch (this.expectedAnswer) { | ||
case 'monitoringData': | ||
if (this.callback) { | ||
this.callback(null, this.parseMonitoringData(data)); | ||
this.callback = null; | ||
} | ||
break; | ||
case 'configuration': | ||
if (this.callback) { | ||
message = Buffer.concat([message, data]); | ||
if (message.length >= this.configurationLength) { | ||
this.callback(null, this.parseConfiguration(message)); | ||
this.callback = null; | ||
} | ||
} | ||
break; | ||
case 'screenshot': | ||
if (this.callback) { | ||
message = Buffer.concat([message, data]); | ||
if (message.length >= 0x400) { | ||
this.callback(null, message); | ||
this.callback = null; | ||
} | ||
} | ||
break; | ||
default: | ||
} | ||
}); | ||
this.hid.on('error', err => { | ||
this.emit('error', err); | ||
// This.disconnect(); | ||
}); | ||
this.connected = true; | ||
this.emit('connect'); | ||
} catch (err) { | ||
this.disconnect(); | ||
return; | ||
} | ||
let message = Buffer.from([]); | ||
this.hid.on('data', data => { | ||
clearTimeout(this.timeout); | ||
switch (this.expectedAnswer) { | ||
case 'monitoringData': | ||
if (this.callback) { | ||
this.callback(null, this.parseMonitoringData(data)); | ||
this.callback = null; | ||
} | ||
break; | ||
case 'configuration': | ||
if (this.callback) { | ||
message = Buffer.concat([message, data]); | ||
if (message.length >= this.configurationLength) { | ||
this.callback(null, this.parseConfiguration(message)); | ||
this.callback = null; | ||
} | ||
} | ||
break; | ||
case 'screenshot': | ||
if (this.callback) { | ||
message = Buffer.concat([message, data]); | ||
if (message.length >= 0x400) { | ||
this.callback(null, message); | ||
this.callback = null; | ||
} | ||
} | ||
default: | ||
} | ||
}); | ||
this.hid.on('error', err => { | ||
this.emit('error', err); | ||
// This.disconnect(); | ||
}); | ||
this.connected = true; | ||
this.emit('connect'); | ||
} | ||
@@ -102,3 +101,3 @@ | ||
// See https://github.com/TBXin/NFirmwareEditor/blob/master/src/NCore/USB/HidConnector.cs#L324 | ||
let arr = [ | ||
const arr = [ | ||
commandCode, | ||
@@ -612,4 +611,4 @@ | ||
const payload = [ | ||
y & 0xff, | ||
(y & 0xff00) >> 8, | ||
y & 0xFF, | ||
(y & 0xFF00) >> 8, | ||
date.getMonth() + 1, | ||
@@ -616,0 +615,0 @@ date.getDate(), |
{ | ||
"name": "arcticfox", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Module that abstracts the HID communication with the ArcticFox firmware", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "xo --space 4" | ||
"test": "camo-purge; xo --space 4 --ignore test.js" | ||
}, | ||
@@ -9,0 +9,0 @@ "author": "Sebastian Raff <hq@ccu.io>", |
# arcticfox | ||
[![NPM version](https://badge.fury.io/js/arcticfox.svg)](http://badge.fury.io/js/arcticfox) | ||
[![Dependency Status](https://img.shields.io/gemnasium/hobbyquaker/arcticfox.svg?maxAge=2592000)](https://gemnasium.com/github.com/hobbyquaker/arcticfox) | ||
[![Build Status](https://travis-ci.org/hobbyquaker/arcticfox.svg?branch=master)](https://travis-ci.org/hobbyquaker/arcticfox) | ||
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo) | ||
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0) | ||
> Node module that abstracts the HID communication with the ArcticFox firmware | ||
@@ -11,5 +18,3 @@ | ||
Work in progress: Until now I only implemented what is needed for | ||
[arcticfox-monitor](https://github.com/hobbyquaker/arcticfox-monitor), other toolbox features like configuration and | ||
firmware update etc are still missing. | ||
Work in progress... See [test.js](test.js) for examples... | ||
@@ -16,0 +21,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
55864
24
0