Skip to content

Commit 3f7c46a

Browse files
committed
Update examples
* lsusb * kinect [untested] * removed tonelabst
1 parent 0b3939a commit 3f7c46a

File tree

5 files changed

+21
-366
lines changed

5 files changed

+21
-366
lines changed

examples/kinect/kinect.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// usage without warranty!
2-
var usb_driver = require("../../usb.js"),
2+
var usb = require("../../usb.js"),
33
assert = require('assert'),
44
http = require('http'),
55
qs = require('querystring');
@@ -21,7 +21,6 @@ LED_OPTIONS['BLINK_RED_YELLOW'] = 6;
2121
var MAX_TILT_ANGLE = 31, MIN_TILT_ANGLE = -31;
2222

2323
// Search for motor device
24-
var usb = usb_driver.create()
2524

2625
var motorDevices = usb.find_by_vid_and_pid(VID_MICROSOFT, PID_NUI_MOTOR);
2726
assert.ok((motorDevices.length >= 1));
@@ -30,12 +29,11 @@ console.log("Total motor devices found: " + motorDevices.length);
3029
var motor = motorDevices[0];
3130

3231
// get interfaces of motor
33-
var motorInterfaces = motor.getInterfaces();
34-
assert.ok((motorInterfaces.length >= 1));
35-
console.log("Motor contains interfaces: " + motorInterfaces.length);
32+
assert.ok((motor.interfaces.length >= 1));
33+
console.log("Motor contains interfaces: " + motor.interfaces.length);
3634

3735
// claim first interface
38-
var motorInterface = motorInterfaces[0];
36+
var motorInterface = motor.interfaces[0];
3937
console.log("Claiming motor interface for further actions");
4038
motorInterface.claim();
4139

@@ -59,7 +57,7 @@ http.createServer(function(req, res) {
5957
var lightId = LED_OPTIONS[light];
6058

6159
// send control information
62-
motor.controlTransfer(new Buffer(0), 0x40, 0x06, lightId, 0x0, function(data) {
60+
motor.controlTransfer(0x40, 0x06, lightId, 0x0, new Buffer(0), function(data) {
6361
console.log(" + LED toggled");
6462
});
6563
}
@@ -80,7 +78,7 @@ http.createServer(function(req, res) {
8078

8179
break;
8280
case '/getCoordinates':
83-
motor.controlTransfer(10 /* read 10 bytes */, 0xC0 /* bmRequestType */, 0x32 /* bRequest */, 0, 0, function(data) {
81+
motor.controlTransfer(0xC0 /* bmRequestType */, 0x32 /* bRequest */, 0, 0, 10 /* read 10 bytes */, function(data) {
8482
for (var i = 0; i < 10; i++) {
8583
console.log("buffer[" + i + "]: " + data[i])
8684
}

examples/lsusb/lsusb.js

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
var usb_driver = require("../../usb.js");
2-
var usb_ids = require("../../usb_ids.js");
3-
var instance = usb_driver.create()
4-
var devices = instance.getDevices();
1+
var usb = require("../../usb");
2+
var usb_ids = require("../../usb_ids");
3+
var devices = usb.devices;
54

65
function toHex(i) {
76
return Number(i).toString(16);
@@ -27,8 +26,8 @@ function toByteArray(_i) {
2726
return array.reverse();
2827
}
2928

30-
function get_extra_data(obj) {
31-
var data = obj.getExtraData(), r = "";
29+
function get_extra_data(data) {
30+
var r = "";
3231

3332
if (!max_bytes) {
3433
var max_bytes = 5;
@@ -56,8 +55,8 @@ function pad(v, len, fill) {
5655

5756
for (var i = 0; i < devices.length; i++) {
5857
var device = devices[i];
59-
var dd = device.getDeviceDescriptor();
60-
var cd = device.getConfigDescriptor();
58+
var dd = device.deviceDescriptor;
59+
var cd = device.configDescriptor;
6160

6261
console.log("Bus " + pad(device.busNumber, 3, "0") + " Device " + pad(device.deviceAddress, 3, "0") + " ID " + pad(toHex(dd.idVendor), 4, "0") + ":" + pad(toHex(dd.idProduct), 4, "0"));
6362
console.log("Device Descriptor:");
@@ -91,10 +90,10 @@ for (var i = 0; i < devices.length; i++) {
9190
console.log(" iConfiguration " + cd.iConfiguration);
9291
console.log(" bmAttributes 0x" + toHex(cd.bmAttributes));
9392
console.log(" MaxPower " + cd.MaxPower);
94-
console.log(" __extra_length " + cd.extra_length);
95-
console.log(" __extra_data (first 5b) " + get_extra_data(device));
93+
console.log(" __extra_length " + cd.extra.length);
94+
console.log(" __extra_data (first 5b) " + get_extra_data(cd.extra));
9695

97-
var interfaces = device.getInterfaces();
96+
var interfaces = device.interfaces;
9897

9998
for (var j = 0; j < interfaces.length; j++) {
10099
var interface = interfaces[j];
@@ -108,10 +107,10 @@ for (var i = 0; i < devices.length; i++) {
108107
console.log(" bInterfaceSubClass " + interface.bInterfaceSubClass);
109108
console.log(" bInterfaceProtocol " + interface.bInterfaceProtocol);
110109
console.log(" iInterface " + interface.iInterface);
111-
console.log(" __extra_length " + interface.extra_length);
112-
console.log(" __extra_data (first 5b) " + get_extra_data(interface));
110+
console.log(" __extra_length " + interface.extraData.length);
111+
console.log(" __extra_data (first 5b) " + get_extra_data(interface.extraData));
113112

114-
var endpoints = interface.getEndpoints();
113+
var endpoints = interface.endpoints;
115114

116115
for (var k = 0; k < endpoints.length; k++) {
117116
var endpoint = endpoints[k];
@@ -122,11 +121,8 @@ for (var i = 0; i < devices.length; i++) {
122121
console.log(" bmAttributes " + endpoint.bmAttributes);
123122
console.log(" wMaxPacketSize 0x" + pad(toHex(endpoint.wMaxPacketSize), 4, "0"));
124123
console.log(" bInterval " + endpoint.bInterval);
125-
console.log(" __extra_length " + endpoint.extra_length);
126-
console.log(" __extra_data (first 5b) " + get_extra_data(endpoint));
124+
console.log(" __extra_length " + endpoint.extraData.length);
125+
console.log(" __extra_data (first 5b) " + get_extra_data(endpoint.extraData));
127126
}
128127
}
129128
}
130-
131-
instance.close();
132-

examples/tonelabst/tonelab-middleware.js

Lines changed: 0 additions & 185 deletions
This file was deleted.

examples/tonelabst/tonelabst.js

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)