diff --git a/README.md b/README.md index f72084486..506d8646b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ ![Entry Logo](app/src/renderer/images/about/logo.png) -1.9.20 - ## [![Action Build Status](https://github.com/entrylabs/entry-hw/workflows/Build%20%26%20Deploy/badge.svg)](https://github.com/entrylabs/entry-hw/actions?query=workflow%3A"Build+%26+Deploy") ## What is Entry Hardware diff --git a/app/modules/etboard.js b/app/modules/etboard.js index 90fda25c0..5e68e8b8b 100644 --- a/app/modules/etboard.js +++ b/app/modules/etboard.js @@ -7,12 +7,11 @@ function Module() { PWM: 3, SERVO_PIN: 4, TONE: 5, - PULSEIN: 6, + PULSEIN: 6, ULTRASONIC: 7, TIMER: 8, OLED: 241, - COM: 242, - NEOPIXEL: 243 + COM: 242 } this.actionTypes = { @@ -121,12 +120,12 @@ Module.prototype.requestRemoteData = function(handler) { Object.keys(this.sensorData).forEach(function (key) { if(self.sensorData[key] != undefined) { handler.write(key, self.sensorData[key]); - if (key == "DIGITAL") - { - var dObj = self.sensorData["DIGITAL"]; - //console.log("send : sensorData = " + dObj[6]); + if (key == "DIGITAL") + { + var dObj = self.sensorData["DIGITAL"]; + //console.log("send : sensorData = " + dObj[6]); } - + } }) }; @@ -171,7 +170,7 @@ Module.prototype.handleRemoteData = function(handler) { buffer = Buffer.concat([buffer, self.makeSensorReadBuffer(key, dataObj.port, dataObj.data)]); } } - }); + }); } if(setDatas) { @@ -188,7 +187,6 @@ Module.prototype.handleRemoteData = function(handler) { data: data.data } buffer = Buffer.concat([buffer, self.makeOutputBuffer(data.type, port, data.data)]); - console.log(buffer); } } } @@ -202,14 +200,14 @@ Module.prototype.handleRemoteData = function(handler) { Module.prototype.isRecentData = function(port, type, data) { var isRecent = false; - /* - if(type == this.sensorTypes.ULTRASONIC) + /* + if(type == this.sensorTypes.ULTRASONIC) { isRecent = false; return isRecent; } */ - if(type == this.sensorTypes.COM) + if(type == this.sensorTypes.COM) { isRecent = false; return isRecent; @@ -226,7 +224,7 @@ Module.prototype.isRecentData = function(port, type, data) { Module.prototype.requestLocalData = function() { var self = this; - + if(!this.isDraing && this.sendBuffers.length > 0) { this.isDraing = true; this.sp.write(this.sendBuffers.shift(), function () { @@ -235,7 +233,7 @@ Module.prototype.requestLocalData = function() { self.isDraing = false; }); } - }); + }); } return null; @@ -250,7 +248,7 @@ Module.prototype.handleLocalData = function(data) { datas.forEach(function (data) { if(data.length <= 4) {// || data[0] === 255 && data[1] === 86 ) { - return; + return; } if(data[0] === 255 && data[1] === 85) { @@ -260,22 +258,22 @@ Module.prototype.handleLocalData = function(data) { } else { return; } - + }); - + }; /* Original Parsing FF 55 ~ */ Module.prototype.originParsing = function(data) { var self = this; - var readData = data.subarray(2, data.length); + var readData = data.subarray(2, data.length); var value; switch(readData[0]) { case self.sensorValueSize.FLOAT: { value = new Buffer(readData.subarray(1, 5)).readFloatLE(); - value = Math.round(value * 100) / 100; + value = Math.round(value * 100) / 100; break; } case self.sensorValueSize.SHORT: { @@ -293,11 +291,11 @@ Module.prototype.originParsing = function(data) { switch(type) { case self.sensorTypes.DIGITAL: { - self.sensorData.DIGITAL[port] = value; + self.sensorData.DIGITAL[port] = value; break; } case self.sensorTypes.ANALOG: { - self.sensorData.ANALOG[port] = value; + self.sensorData.ANALOG[port] = value; break; } case self.sensorTypes.PULSEIN: { @@ -312,10 +310,6 @@ Module.prototype.originParsing = function(data) { self.sensorData.TIMER = value; break; } - case self.sensorTypes.NEOPIXEL: { - self.sensorData.NEOPIXEL = value; - break; - } default: { break; } @@ -325,28 +319,28 @@ Module.prototype.originParsing = function(data) { /* K-Board Parsing FF 56 ~ */ Module.prototype.kParsing = function(data) { var self = this; - var readData = data.subarray(2, data.length); + var readData = data.subarray(2, data.length); var value; - - - + + + for(var i = 0; i<8; i++) { if(bit_test(readData[0], i)) { - self.sensorData.DIGITAL[i + 2] = 1; + self.sensorData.DIGITAL[i + 2] = 1; } else { - self.sensorData.DIGITAL[i + 2] = 0; + self.sensorData.DIGITAL[i + 2] = 0; } } var index = 0; for(var i = 1; i<19; i = i + 2){ value = new Buffer(readData.subarray(i, i+2)).readInt16LE(); - value = Math.round(value * 100) / 100; + value = Math.round(value * 100) / 100; if( value > 1023 || value < 0) value = 0; - + if(index != 8) { if(index == 0) @@ -354,13 +348,13 @@ Module.prototype.kParsing = function(data) { if((1023 - (value * 1.72)) > 0) self.sensorData.ANALOG[index] = parseInt(Math.abs(1023 - (value * 1.72))); else - self.sensorData.ANALOG[index] = 0; + self.sensorData.ANALOG[index] = 0; } else - self.sensorData.ANALOG[index] = value; + self.sensorData.ANALOG[index] = value; //console.log("self.sensorData.ANALOG" + index + " = " + self.sensorData.ANALOG[index]); } else { - self.sensorData.ULTRASONIC = value; + self.sensorData.ULTRASONIC = value; //console.log("self.sensorData.ULTRASONIC" + index + " = " + self.sensorData.ULTRASONIC); } @@ -368,10 +362,10 @@ Module.prototype.kParsing = function(data) { index = index + 1; } + - - - + + }; function bit_test(num, bit){ @@ -416,6 +410,7 @@ Module.prototype.makeOutputBuffer = function(device, port, data) { value.writeInt16LE(data); buffer = new Buffer([255, 85, 6, sensorIdx, this.actionTypes.SET, device, port]); buffer = Buffer.concat([buffer, value, dummy]); + console.log(buffer); break; } case this.sensorTypes.TONE: { @@ -436,7 +431,7 @@ Module.prototype.makeOutputBuffer = function(device, port, data) { case this.sensorTypes.OLED: { var arr = []; var i; - data = data.toString(); + data = data.toString(); for(i=0; i 0) { result[2] = grpid; result[9] = 0x1a; @@ -98,12 +69,12 @@ class PingpongBase extends BaseModule { // 연결 후 초기에 송신할 데이터가 필요한 경우 사용합니다. requestInitialData(sp, payload) { //console.log('P:requestInitialData: '); - const grpid = payload.match(/[0-7]{1,2}$/g); + let grpid = payload.match(/[0-7]{1,2}$/g); if (grpid == null) { console.warn('Wrong group id inputted', payload); return null; } - const grpno = parseInt(grpid[0], 16); + let grpno = parseInt(grpid[0], 16); return this.makePackets('setMultirole', grpno); } @@ -129,7 +100,7 @@ class PingpongBase extends BaseModule { this.checkBuffer = Buffer.from(data); } - const payload = this.checkBuffer; + let payload = this.checkBuffer; if (payload.length >= 9) { const packetSize = payload.readInt16BE(7); @@ -158,36 +129,24 @@ class PingpongBase extends BaseModule { // 엔트리에서 받은 데이터에 대한 처리 handleRemoteData(handler) { + //console.log('P:handle RemoteData: ', handler); + this.send_cmd = handler.read('COMMAND'); if (this.send_cmd) { - //console.log('P:handleRemoteData: ', this.send_cmd); - if (this.send_cmd.id == -1) { - this.cmd_seq = 0; - //console.log('P:handleRemoteData RD: CLEAR'); - } else if (this.send_cmd.id != this.cmd_seq) { + if (this.send_cmd.id > this.cmd_seq) { this.cmd_seq = this.send_cmd.id; - this.sendBuffer.push(Buffer.from(this.send_cmd.data)); - //const sendBuffer = Buffer.from(this.send_cmd.data); + const sendBuffer = Buffer.from(this.send_cmd.data); + this.sp.write(sendBuffer); + //console.log('D:send PACKET: %s ', this.dbgHexstr(sendBuffer)); + } else if (this.send_cmd.id == -1) { + this.cmd_seq = 0; + //console.log('P:handle RD: CLEAR'); } } } // 하드웨어 기기에 전달할 데이터 requestLocalData() { - const self = this; - if (!this.isDraing && this.sendBuffer.length > 0) { - this.isDraing = true; - const msg = this.sendBuffer.shift(); - //console.log('P:requestLocalData() : ', msg, this.sendBuffer.length); - this.sp.write(msg, () => { - if (self.sp) { - self.sp.drain(() => { - self.isDraing = false; - }); - } - }); - } - return null; } diff --git a/app/modules/pingpong_g1.js b/app/modules/pingpong_g1.js index d2d9f5f48..c30e194c0 100644 --- a/app/modules/pingpong_g1.js +++ b/app/modules/pingpong_g1.js @@ -8,9 +8,6 @@ class PingpongG1 extends BaseModule { this.send_cmd = {}; this.cmd_seq = 0; - this.isDraing = false; - this.sendBuffer = []; - this.sp = null; this.isCubeConnecting = false; this.isCheckConnecting = false; @@ -44,32 +41,27 @@ class PingpongG1 extends BaseModule { let result = null; if (method === 'connect') { - result = Buffer.from([ - 0xdd, - 0xdd, - grpid, - 0x00, - 0x00, - 0x00, - 0xda, - 0x00, - 0x0b, - 0x00, - 0x00, - ]); + result = Buffer.from([0xdd, 0xdd, grpid, 0x00, 0x00, 0x00, 0xda, 0x00, 0x0b, 0x00, 0x00]); //result[2] = this.groupId; } else if (method === 'disconnect') { result = Buffer.from([0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xa8, 0x00, 0x0a, 0x01]); //result = Buffer.from('ffffffff0000a8000a01', 'hex'); } else if (method === 'checkdongle') { - result = Buffer.from([ - 0xdd, 0xdd, 0xdd, 0xdd, 0x00, 0x01, 0xda, 0x00, 0x0b, 0x00, 0x0d, - ]); + result = Buffer.from([0xdd, 0xdd, 0xdd, 0xdd, 0x00, 0x01, 0xda, 0x00, 0x0b, 0x00, 0x0d]); } else if (method === 'setColorLed') { result = Buffer.from('ffff00070000ce000e0200000750', 'hex'); } else if (method === 'getSensorData') { result = Buffer.from([ - 0xff, 0xff, 0xff, 0xff, 0x00, 0xc8 /* continuous sampling*/, 0xb8, 0x00, 0x0b, 20, + 0xff, + 0xff, + 0xff, + 0xff, + 0x00, + 0xc8 /* continuous sampling*/, + 0xb8, + 0x00, + 0x0b, + 20, 0x01, ]); } @@ -122,18 +114,18 @@ class PingpongG1 extends BaseModule { // 연결 후 초기에 송신할 데이터가 필요한 경우 사용합니다. requestInitialData(sp, payload) { //console.log('P:requestInitialData: '); - const grpid = payload.match(/[0-7]{1,2}$/g); + let grpid = payload.match(/[0-7]{1,2}$/g); if (grpid == null) { console.warn('Wrong group id inputted', payload); return null; } - const grpno = parseInt(grpid[0], 16); + let grpno = parseInt(grpid[0], 16); return this.makePackets('connect', grpno); } dbgHexstr(data) { let output = ''; - data.map((item) => { + data.map(item => { let number = item.toString(16); if (number.length < 2) { number = `0${number}`; @@ -163,34 +155,48 @@ class PingpongG1 extends BaseModule { this.send_cmd = handler.read('COMMAND'); if (this.send_cmd) { - if (this.send_cmd.id == -1) { - this.cmd_seq = 0; - //console.log('P:handle RD: CLEAR'); - } else if (this.send_cmd.id != this.cmd_seq) { + if (this.send_cmd.id > this.cmd_seq) { this.cmd_seq = this.send_cmd.id; - this.sendBuffer.push(Buffer.from(this.send_cmd.data)); + const sendBuffer = Buffer.from(this.send_cmd.data); + this.sp.write(sendBuffer); //console.log('D:send PACKET: %s ', this.dbgHexstr(sendBuffer)); + } else if (this.send_cmd.id == -1) { + this.cmd_seq = 0; + //console.log('P:handle RD: CLEAR'); } } } // 하드웨어 기기에 전달할 데이터 requestLocalData() { - const self = this; - if (!this.isDraing && this.sendBuffer.length > 0) { - this.isDraing = true; - const msg = this.sendBuffer.shift(); - //console.log('P:requestLocalData() : ', msg, this.sendBuffer.length); - this.sp.write(msg, () => { - if (self.sp) { - self.sp.drain(() => { - self.isDraing = false; - }); - } - }); - } + /* + var isSendData = false; + var sendBuffer; + + if (this.send_cmd && this.send_cmd.id > this.cmd_seq) { + isSendData = true; + //console.log('P:request LD: ', this.send_cmd); + this.cmd_seq = this.send_cmd.id; + sendBuffer = Buffer.from(this.send_cmd.data); + } + + if (isSendData) { + console.log('P:request LD: '); + return sendBuffer; + } + */ return null; + + /* + const header = new Buffer([0xff, 0xff, 0xff]); + const position = new Buffer([0xff]); + const data = new Buffer([0x00, 0xc8, 0xb8, 0x00, 0x0b]); + const interval = new Buffer([10]); + const tail = new Buffer([0x01]); + + return Buffer.concat([header, position, data, interval, tail]); + */ } // 하드웨어에서 온 데이터 처리 @@ -248,14 +254,14 @@ class PingpongG1 extends BaseModule { requestRemoteData(handler) { //console.log('P:request RD: '); const self = this; - Object.keys(this.readValue).forEach((key) => { + Object.keys(this.readValue).forEach(key => { if (self.readValue[key] !== undefined) { handler.write(key, self.readValue[key]); } }); //XXX: entryjs의 monitorTemplate 사용하려면 트리상단에 PORT 정보 보내야함 - Object.keys(this._sensorData).forEach((key) => { + Object.keys(this._sensorData).forEach(key => { if (self._sensorData[key] !== undefined) { //console.log(" --handler.write (%s) = %j ", key, self._sensorData[key]); handler.write(key, self._sensorData[key]); @@ -271,7 +277,7 @@ class PingpongG1 extends BaseModule { }, 500); setTimeout(() => { - this.sp.write(this.makePackets('getSensorData'), (err) => { + this.sp.write(this.makePackets('getSensorData'), err => { console.log('done.........'); }); }, 1000); @@ -288,7 +294,7 @@ class PingpongG1 extends BaseModule { // getSensor disable //this.sp.write( Buffer.from('ffffffff00c8b8000b0001', 'hex') ); - this.sp.write(this.makePackets('disconnect'), (err) => { + this.sp.write(this.makePackets('disconnect'), err => { if (this.sp.isOpen) { console.log('Disconnect'); connect.close(); diff --git a/app/modules/pingpong_g1.json b/app/modules/pingpong_g1.json index 297bd22c4..29b29d2c2 100644 --- a/app/modules/pingpong_g1.json +++ b/app/modules/pingpong_g1.json @@ -28,7 +28,7 @@ "hardware": { "type": "bluetooth", "control": "slave", - "duration": 50, + "duration": 10000, "vendor": "Microsoft", "lostTimer": 5000, "firmwarecheck": false, diff --git a/app/modules/pingpong_g2.json b/app/modules/pingpong_g2.json index cd0e0b2fc..3a2c7fe9f 100644 --- a/app/modules/pingpong_g2.json +++ b/app/modules/pingpong_g2.json @@ -28,7 +28,7 @@ "hardware": { "type": "bluetooth", "control": "slave", - "duration": 50, + "duration": 10000, "lostTimer": 5000, "vendor": "Microsoft", "baudRate": 115200 diff --git a/app/modules/pingpong_g3.json b/app/modules/pingpong_g3.json index 1f4859fc7..7bf016ec8 100644 --- a/app/modules/pingpong_g3.json +++ b/app/modules/pingpong_g3.json @@ -28,7 +28,7 @@ "hardware": { "type": "bluetooth", "control": "slave", - "duration": 50, + "duration": 10000, "lostTimer": 5000, "vendor": "Microsoft", "baudRate": 115200 diff --git a/app/modules/pingpong_g4.json b/app/modules/pingpong_g4.json index 7061542be..56f60f822 100644 --- a/app/modules/pingpong_g4.json +++ b/app/modules/pingpong_g4.json @@ -28,7 +28,7 @@ "hardware": { "type": "bluetooth", "control": "slave", - "duration": 50, + "duration": 10000, "lostTimer": 5000, "vendor": "Microsoft", "baudRate": 115200 diff --git a/app/modules/robotry.png b/app/modules/robotry.png new file mode 100644 index 000000000..5a6588db6 Binary files /dev/null and b/app/modules/robotry.png differ diff --git a/app/modules/robotry_robitStage.json b/app/modules/robotry_robitStage.json index 622b4994e..953b1161d 100644 --- a/app/modules/robotry_robitStage.json +++ b/app/modules/robotry_robitStage.json @@ -6,7 +6,7 @@ }, "category": "board", "platform": ["win32", "darwin"], - "icon": "robotry_robitStage.png", + "icon": "robotry.png", "module": "robotry_robitStage.js", "url": "http://robotry.co.kr", "email": "hee.kim6133@robotry.co.kr", diff --git a/app/modules/robotry_robitStage.png b/app/modules/robotry_robitStage.png deleted file mode 100644 index 16678c80f..000000000 Binary files a/app/modules/robotry_robitStage.png and /dev/null differ diff --git a/package.json b/package.json index e5699b28e..182effd60 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,7 @@ "dist:mac": "cross-env BUILD_MODE=STANDALONE npm run webpack:prod && cross-env NOTARIZE=false CSC_NAME=\"Connect Foundation (DLFUSDA3L5)\" electron-builder", "dist:offline": "cross-env BUILD_MODE=OFFLINE npm run webpack:prod", "rebuild": "electron-rebuild -f -w serialport,node-hid", - "setting": "npm run rebuild && npm run webpack:dev", - "postinstall": "electron-builder install-app-deps" + "setting": "npm run rebuild && npm run webpack:dev" }, "devDependencies": { "@types/cross-spawn": "^6.0.1",