update
Took 2 minutes
This commit is contained in:
parent
59f2932809
commit
6bbde817d4
@ -15,6 +15,7 @@ export class ArduinoProxy {
|
|||||||
private static onData(data) {
|
private static onData(data) {
|
||||||
data = data.toString().trim();
|
data = data.toString().trim();
|
||||||
try {
|
try {
|
||||||
|
log("Receiving " + data);
|
||||||
let json = JSON.parse(data) as ArduinoProxyPayload;
|
let json = JSON.parse(data) as ArduinoProxyPayload;
|
||||||
if (this.callbacks[json.id]) {
|
if (this.callbacks[json.id]) {
|
||||||
this.callbacks[json.id].resolve(json);
|
this.callbacks[json.id].resolve(json);
|
||||||
@ -81,7 +82,7 @@ export class ArduinoProxy {
|
|||||||
let id = Utils.generateRandomString(8);
|
let id = Utils.generateRandomString(8);
|
||||||
request.id = id;
|
request.id = id;
|
||||||
this.callbacks[id] = {resolve: resolve, reject: reject};
|
this.callbacks[id] = {resolve: resolve, reject: reject};
|
||||||
|
log("Sending " + request);
|
||||||
this.serialPort.write(JSON.stringify(request), ArduinoProxy.encoding, (err: Error | null | undefined) => {
|
this.serialPort.write(JSON.stringify(request), ArduinoProxy.encoding, (err: Error | null | undefined) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject("I/O error on request " + id);
|
reject("I/O error on request " + id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user