Просмотр исходного кода

make hid_generic_inout tester have reportLength-sized buffer, since some OSes need that

Tod E. Kurt 7 лет назад
Родитель
Сommit
f4dcc08de3
1 измененных файлов с 7 добавлено и 2 удалено
  1. 7 2
      examples/device/hid_generic_inout/hid_test.js

+ 7 - 2
examples/device/hid_generic_inout/hid_test.js

@@ -4,14 +4,19 @@ var deviceInfo = devices.find( function(d) {
     var isNRF = d.vendorId===0Xcafe && d.productId===0X4004;
     return isNRF;
 });
+var reportLen = 64;
 if( deviceInfo ) {
 	console.log(deviceInfo)
 	var device = new HID.HID( deviceInfo.path );
-	device.on("data", function(data) {console.log(data)});
+	device.on("data", function(data) { console.log(data.toString('hex')); });
 
 	device.on("error", function(err) {console.log(err)});
 
 	setInterval(function () {
-		device.write([0x00, 0x01, 0x01, 0x05, 0xff, 0xff]);
+		var buf = Array(reportLen);
+		for( var i=0; i<buf.length; i++) {
+			buf[i] = 0x30 + i; // 0x30 = '0'
+		}
+		device.write(buf);
 	},500)
 }