@@ -345,15 +345,18 @@ Module.prototype.requestLocalData = function () {
345
345
/*
346
346
ff 55 idx size data a
347
347
*/
348
+
349
+ // 펌웨어에서 입력된 값을 처리하는 Buffer
348
350
Module . prototype . handleLocalData = function ( data ) {
349
351
const self = this ;
350
352
const datas = this . getDataByBuffer ( data ) ;
351
-
353
+ // console.log(datas);
352
354
datas . forEach ( ( data ) => {
353
355
if ( data . length <= 4 || data [ 0 ] !== 255 || data [ 1 ] !== 85 ) {
354
356
return ;
355
357
}
356
358
const readData = data . subarray ( 2 , data . length ) ;
359
+ // console.log(readData);
357
360
let value ;
358
361
switch ( readData [ 0 ] ) {
359
362
case self . sensorValueSize . FLOAT : {
@@ -380,7 +383,10 @@ Module.prototype.handleLocalData = function (data) {
380
383
381
384
const type = readData [ readData . length - 1 ] ;
382
385
const port = readData [ readData . length - 2 ] ;
383
-
386
+ // if(port == 9)
387
+ // {
388
+ // console.log(readData);
389
+ // }
384
390
switch ( type ) {
385
391
case self . sensorTypes . DIGITAL : {
386
392
self . sensorData . DIGITAL [ port ] = value ;
@@ -408,8 +414,6 @@ Module.prototype.handleLocalData = function (data) {
408
414
}
409
415
case self . sensorTypes . ULTRASONIC : {
410
416
self . sensorData . ULTRASONIC [ port ] = value ;
411
- // console.log(port);
412
- // console.log(self.sensorData.ULTRASONIC[port]);
413
417
break ;
414
418
}
415
419
case self . sensorTypes . DUST : {
@@ -426,14 +430,12 @@ Module.prototype.handleLocalData = function (data) {
426
430
}
427
431
case self . sensorTypes . RFIDTAP : {
428
432
self . sensorData . RFIDTAP = value ;
429
- // console.log('RFIDTAP');
430
- // console.log(value);
431
433
break ;
432
434
}
433
435
case self . sensorTypes . RFIDVALUE : {
434
436
value = value . substring ( 0 , value . length - 1 ) ; //마지막에 쓰레기값 출력X
435
437
self . sensorData . RFIDVALUE = value ;
436
- // console.log(value );
438
+ // console.log(readData );
437
439
break ;
438
440
}
439
441
case self . sensorTypes . MLXOBJ : {
@@ -455,20 +457,17 @@ Module.prototype.handleLocalData = function (data) {
455
457
ff 55 len idx action device port slot data a
456
458
0 1 2 3 4 5 6 7 8
457
459
*/
458
-
460
+ // 엔트리 블럭 화면에서 입력에 해당하는 블럭을 사용했을 때, 펌웨어쪽으로 보내는 Buffer
459
461
Module . prototype . makeSensorReadBuffer = function ( device , port , data ) {
460
462
let buffer ;
461
463
const dummy = new Buffer ( [ 10 ] ) ;
462
464
if ( device == this . sensorTypes . DIGITAL ) {
463
465
//data 2: pull up, 0: normal
464
- //console.log(data)
465
466
buffer = new Buffer ( [ 255 , 85 , 6 , sensorIdx , this . actionTypes . GET , device , port , data , 10 ] ) ;
466
467
} else if ( device == this . sensorTypes . PULLUP ) {
467
468
//data 2: pull up, 0: normal
468
- //console.log(data)
469
469
//pullup인 경우
470
470
buffer = new Buffer ( [ 255 , 85 , 6 , sensorIdx , this . actionTypes . GET , device , port , data , 10 ] ) ;
471
- //console.log(buffer);
472
471
} else if ( device == this . sensorTypes . RFIDTAP ) {
473
472
buffer = new Buffer ( [ 255 , 85 , 5 , sensorIdx , this . actionTypes . GET , device , port , 10 ] ) ;
474
473
} else if ( device == this . sensorTypes . ULTRASONIC ) {
@@ -524,6 +523,8 @@ Module.prototype.makeSensorReadBuffer = function (device, port, data) {
524
523
} ;
525
524
526
525
//0xff 0x55 0x6 0x0 0x1 0xa 0x9 0x0 0x0 0xa
526
+
527
+ // 엔트리 블럭 화면에서 출력에 해당하는 블럭을 사용했을 때, 펌웨어쪽으로 보내는 Buffer
527
528
Module . prototype . makeOutputBuffer = function ( device , port , data ) {
528
529
let buffer ;
529
530
const value = new Buffer ( 2 ) ;
@@ -684,13 +685,12 @@ Module.prototype.makeOutputBuffer = function (device, port, data) {
684
685
685
686
// buffer = Buffer.from([255, 85, 26, sensorIdx, this.actionTypes.MODUEL, device, port]);
686
687
// buffer = Buffer.concat([buffer, fndBlockIndex, fndClk, fndDio, fndBrightnessLev, fndOnOff, fndDisplayStrLength, fndDisplayStr0, fndDisplayStr1, fndDisplayStr2, fndDisplayStr3, fndDelayMs, dummy]);
687
- // console.log(buffer);
688
+
688
689
// break;
689
690
// }
690
691
691
692
692
693
case this . sensorTypes . NEOPIXELINIT : {
693
- console . log ( 'NEOPIXELINIT' ) ;
694
694
value . writeInt16LE ( data ) ;
695
695
buffer = new Buffer ( [ 255 , 85 , 6 , sensorIdx , this . actionTypes . SET , device , port ] ) ;
696
696
buffer = Buffer . concat ( [ buffer , value , dummy ] ) ;
@@ -914,7 +914,6 @@ Module.prototype.makeOutputBuffer = function (device, port, data) {
914
914
case this . sensorTypes . DOTMATRIXCLEAR : {
915
915
buffer = new Buffer ( [ 255 , 85 , 4 , sensorIdx , this . actionTypes . SET , device , port ] ) ;
916
916
buffer = Buffer . concat ( [ buffer , dummy ] ) ;
917
- console . log ( buffer ) ;
918
917
break ;
919
918
}
920
919
case this . sensorTypes . LCDINIT : {
@@ -946,7 +945,6 @@ Module.prototype.makeOutputBuffer = function (device, port, data) {
946
945
947
946
if ( $ . isPlainObject ( data ) ) {
948
947
textLen = ( '' + data . text ) . length ;
949
- // console.log(textLen);
950
948
text = Buffer . from ( '' + data . text , 'ascii' ) ;
951
949
line . writeInt16LE ( data . line ) ;
952
950
textLenBuf . writeInt16LE ( textLen ) ;
@@ -1064,7 +1062,6 @@ Module.prototype.makeOutputBuffer = function (device, port, data) {
1064
1062
} else {
1065
1063
num . writeFloatLE ( 0 ) ;
1066
1064
}
1067
- console . log ( num ) ;
1068
1065
buffer = new Buffer ( [ 255 , 85 , 8 , sensorIdx , this . actionTypes . SET , device , port ] ) ;
1069
1066
buffer = Buffer . concat ( [ buffer , num , dummy ] ) ;
1070
1067
@@ -1096,6 +1093,9 @@ Module.prototype.getDataByBuffer = function (buffer) {
1096
1093
if ( value == 13 && buffer [ idx + 1 ] == 10 ) {
1097
1094
datas . push ( buffer . subarray ( lastIndex , idx ) ) ;
1098
1095
lastIndex = idx + 2 ;
1096
+ // if(buffer[idx-1] == 9)
1097
+ // console.log(datas);
1098
+
1099
1099
}
1100
1100
} ) ;
1101
1101
@@ -1119,4 +1119,4 @@ Module.prototype.reset = function () {
1119
1119
1120
1120
Module . prototype . lostController = function ( ) { } ;
1121
1121
1122
- module . exports = new Module ( ) ;
1122
+ module . exports = new Module ( ) ;
0 commit comments