Skip to content

Commit

Permalink
Merge pull request #746 from entrylabs/develop-hw
Browse files Browse the repository at this point in the history
1.9.55 PR
  • Loading branch information
Tnks2U authored Jun 20, 2024
2 parents b9e4768 + 73e3c3d commit 1cbdb5c
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 29 deletions.
64 changes: 42 additions & 22 deletions app/modules/pingpong_base.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const BaseModule = require('./baseModule');
const { app } = require('electron');
const { dialog } = require('electron');

//1.9.19 이후 여러번 패킷 전송을 막기 위한 변수
var checkMultiroleAction = false;
let checkMultiroleAction = false;

class PingpongBase extends BaseModule {
constructor(cubeCnt) {
Expand All @@ -28,6 +29,7 @@ class PingpongBase extends BaseModule {
}

makePackets(method, grpid = 0) {
console.log('makePackets');
//console.log('..make_packet: ' + method);

// CUBE_ID[0:3] / ASSIGNED_ID[4:5] / OPCODE[6] / SIZE[7:8] / OPT[9..11]
Expand Down Expand Up @@ -93,31 +95,35 @@ class PingpongBase extends BaseModule {
return result;
}

isPingpongConnected(packet) {}
isPingpongConnected(packet) {
console.log('isPingpongConnected');
}

setSerialPort(sp) {
console.log('setSerialPort');
this.sp = sp;
}

// 연결 후 초기에 송신할 데이터가 필요한 경우 사용합니다.
requestInitialData(sp, payload) {
console.log('requestInitialData');
const 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);

if(checkMultiroleAction==false){
checkMultiroleAction=true;
return this.makePackets('setMultirole', grpno);
if (checkMultiroleAction == false) {
checkMultiroleAction = true;
return this.makePackets('setMultirole', grpno);
} else {
return null;
}

}

dbgHexstr(data) {
console.log('dbgHexstr');
let output = '';
data.map((item) => {
let number = item.toString(16);
Expand Down Expand Up @@ -155,7 +161,7 @@ class PingpongBase extends BaseModule {
console.log('send get Sensor Data.');
});
}, 500);
// YIM's getsensor 명령얼 보내야 할 곳으로 보임..
// YIM's getsensor 명령얼 보내야 할 곳으로 보임..
return true;
} //YIM's G2~4 까지는 checkInitialData 리턴이 true 가 되지 않음 , 이 때 firmwarecheck 설정이 true이면 문제가 됨 ???

Expand All @@ -169,12 +175,14 @@ class PingpongBase extends BaseModule {

// optional. 하드웨어에서 받은 데이터의 검증이 필요한 경우 사용합니다.
validateLocalData(data) {
console.log('validateLocalData');
//console.log('P:validateLocalData: '+data.length);
return true;
}

// 엔트리에서 받은 데이터에 대한 처리
handleRemoteData(handler) {
console.log('handleRemoteData');
this.send_cmd = handler.read('COMMAND');
if (this.send_cmd) {
if (this.send_cmd.id == -1) {
Expand All @@ -190,6 +198,7 @@ class PingpongBase extends BaseModule {

// 하드웨어 기기에 전달할 데이터
requestLocalData() {
console.log('requestLocalData');
const self = this;
if (!this.isDraing && this.sendBuffer.length > 0) {
this.isDraing = true;
Expand All @@ -208,16 +217,16 @@ class PingpongBase extends BaseModule {

// 하드웨어에서 온 데이터 처리
handleLocalData(data) {
console.log('handleLocalData');
if (!this.isConnected) {
}

if (data.length >= 9) {
const packetSize = data.readInt16BE(7);
const opcode = data[6];

if(opcode == 0xb8 && this.cubeCount * 20 == data.length){
for(let x = 0; x < this.cubeCount; x++){

if (opcode == 0xb8 && this.cubeCount * 20 == data.length) {
for (let x = 0; x < this.cubeCount; x++) {
// 센서 패킷은 20개씩 들어옴
const cubeid = Number(data[0+(20*x)].toString(16).slice(1, 2));

Expand Down Expand Up @@ -253,14 +262,15 @@ class PingpongBase extends BaseModule {
} else {
sensor.AIN = 0;
}
}
console.log("handleLocalData : ", this._sensorData);
}
console.log('handleLocalData : ', this._sensorData);
}
}
}

// 엔트리로 전달할 데이터
requestRemoteData(handler) {
console.log('requestRemoteData');
const self = this;
Object.keys(this.readValue).forEach((key) => {
if (self.readValue[key] !== undefined) {
Expand Down Expand Up @@ -296,30 +306,40 @@ class PingpongBase extends BaseModule {
// 하드웨어 연결 해제 시 호출됩니다.
disconnect(connect) {
console.log('P:disconnect: ');

dialog.showMessageBox({
title: '핑퐁 로봇',
message: '3초 후 재시작 됩니다.',
});

checkMultiroleAction = false;

if (this.sp) {

if (this.sp) {
this.sp.write(this.makePackets('disconnect'), (err) => {
console.log('disconnect error', err);
if (this.sp.isOpen) {
console.log('Disconnect');
connect.close();
setTimeout(() => {
connect.close();
}, 1000);
}
this.sp = null;
});
} else {
connect.close();
}

app.relaunch();
app.exit(0);

setTimeout(() => {
connect.close();
}, 1000);
}

setTimeout(() => {
app.relaunch();
app.exit(0);
}, 3000);
}

// 엔트리와의 연결 종료 후 처리 코드입니다.
reset() {
//console.log('P:reset: ');
console.log('P:reset: ');
}
}

Expand Down
1 change: 1 addition & 0 deletions app/modules/robotis_RB100.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Module.prototype.requestInitialData = function() {
this.robotisBuffer.push([INST_WRITE, 21, 2, 20]);
this.robotisBuffer.push([INST_WRITE, 19, 1, 1]); // bypass 모드 켜기
this.robotisBuffer.push([INST_WRITE, 20, 1, 0]); // bypass port를 BLE로 설정
this.robotisBuffer.push([INST_WRITE, 23, 1, 0]); // auto report 끄기
this.robotisBuffer.push([INST_WRITE, 4250, 1, 1]); // huskylens 텍스트 지우기
this.robotisBuffer.push([INST_WRITE, 722, 1, 0]); // dxl 토크 끄기

Expand Down
26 changes: 26 additions & 0 deletions app/modules/robotis_RB100_Koala.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"id": "070C01",
"name": {
"en": "KoalaBot",
"ko": "코알라봇"
},
"category": "module",
"platform": ["win32"],
"icon" : "robotis_RB100im_koala.png",
"module": "robotis_RB100_practice.js",
"url": "http://www.robotis.com",
"email": "[email protected]",
"reconnect" : true,
"driver": {
"win32-ia32": "ROBOTIS/ROBOTIS CDC Driver.bat",
"win32-x64": "ROBOTIS/RobotisDriverInstaller.exe"
},
"selectPort" : false,
"hardware": {
"type": "serial",
"control": "slave",
"vendor": "ROBOTIS",
"duration": 15,
"baudRate": 57600
}
}
10 changes: 5 additions & 5 deletions app/modules/robotis_RB100_practice.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ Module.prototype.requestRemoteData = function(handler) {
handler.write('PIR_100_BRIGHTNESS', this.pirBrightness[0]);

// ID 110인 거리+버튼+조도센서
handler.write('DIST_110_DISTANCE', this.dataBuffer[148] + (this.dataBuffer[149] << 8));
handler.write('DIST_110_BUTTON', this.dataBuffer[150]);
handler.write('DIST_110_BRIGHTNESS', this.dataBuffer[151]);
handler.write('DIST_110_DISTANCE', this.distanceDistance[0]);
handler.write('DIST_110_BUTTON', this.distanceButton[0]);
handler.write('DIST_110_BRIGHTNESS', this.distanceBrightness[0]);
//실과형
//console.log("###### value : " + this.detectedSound);
/*
Expand Down Expand Up @@ -586,8 +586,8 @@ Module.prototype.handleLocalData = function(data) { // data: Native Buffer
this.pirBrightness[0] = rxPacket.data[2 + 147];

// 거리+버튼+조도센서값
this.distanceDistance[0] = rxPacket.data[2 + 148];
this.distanceButton[0] = rxPacket.data[2 + 150] + (rxPacket.data[2 + 150] << 8);
this.distanceDistance[0] = rxPacket.data[2 + 148] + (rxPacket.data[2 + 149] << 8);
this.distanceButton[0] = rxPacket.data[2 + 150];
this.distanceBrightness[0] = rxPacket.data[2 + 151];

for (let i = 0; i < addrMap2.length; i++) {
Expand Down
3 changes: 3 additions & 0 deletions app/modules/robotis_RB100_usb.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ Module.prototype.requestInitialData = function() {
this.robotisBuffer.push([INST_WRITE, 21, 2, 20]);
this.robotisBuffer.push([INST_WRITE, 19, 1, 1]); // bypass 모드 켜기
this.robotisBuffer.push([INST_WRITE, 20, 1, 1]); // bypass port를 USB로 설정
this.robotisBuffer.push([INST_WRITE, 23, 1, 0]); // auto report 끄기
this.robotisBuffer.push([INST_WRITE, 4250, 1, 1]); // huskylens 텍스트 지우기
this.robotisBuffer.push([INST_WRITE, 722, 1, 0]); // dxl 토크 끄기

return this.readPacket(200, 0, 2);
};
Expand Down
Binary file added app/modules/robotis_RB100im_koala.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion build/entry-hw.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
!define PRODUCT_NAME "Entry_HW"
!define PROTOCOL_NAME "entryhw"
!define APP_NAME "Entry_HW.exe"
!define PRODUCT_VERSION "1.9.54"
!define PRODUCT_VERSION "1.9.55"
!define PRODUCT_PUBLISHER "EntryLabs"
!define PRODUCT_WEB_SITE "https://www.playentry.org/"

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "entry-hw",
"version": "1.9.54",
"version": "1.9.55",
"description": "엔트리 하드웨어 연결 프로그램",
"author": "EntryLabs",
"main": "./app/src/index.bundle.js",
Expand Down

0 comments on commit 1cbdb5c

Please sign in to comment.