-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFuseDevice.js
49 lines (40 loc) · 1.4 KB
/
FuseDevice.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var MessageProcessor = require('./MessageProcessor.js');
const os = require('os');
class FuseDevice {
constructor(usbDevice, messages, operators) {
this.Devices = {};
this.Presets = [];
var msgProc = new MessageProcessor(this, messages, operators);
this.msgProc = msgProc;
function sendBuffer(buffer) {
//if(os.platform() === "win32") {
buffer.unshift(0);
//}
usbDevice.write(buffer);
}
this.SendBuffer = sendBuffer;
usbDevice.on("data", msgProc.ReadMessage);
var handshake = Array(64).fill(0x00);
handshake[1] = 0xC3;
sendBuffer(handshake);
console.log("Handshake: " + new Buffer.from(usbDevice.readSync()).toString('ascii'));
var handshake2 = Array(64).fill(0x00);
handshake2[0] = 0x1A;
handshake2[1] = 0xC1;
sendBuffer(handshake2);
console.log("Handshake 2: " + new Buffer.from(usbDevice.readSync()).toString('ascii'));
var handshake3 = Array(64).fill(0x00);
handshake3[0] = 0xFF;
handshake3[1] = 0xC1;
sendBuffer(handshake3);
}
SendPatch(patchData) {
var msg = [...this.msgProc.Build(patchData)];
var msg2 = Array(64).fill(0x00);
msg2[0] = 0x1C;
msg2[1] = 0x03;
this.SendBuffer(msg);
this.SendBuffer(msg2);
}
}
module.exports = FuseDevice;