Skip to content

Commit ae1d8f4

Browse files
authored
Merge pull request #699 from RoboroboLab/develop-hw
robokit rs 동작 오류 수정 및 리팩터링
2 parents 26d11fa + 838af54 commit ae1d8f4

7 files changed

+3554
-3896
lines changed

app/firmwares/roborobo_cube.hex

+1,671-2,013
Large diffs are not rendered by default.

app/firmwares/roborobo_robokit_rs.hex

+1,845-1,852
Large diffs are not rendered by default.

app/modules/roborobo_base.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class ArduinoBase extends BaseModule {
134134
* 이 두 함수가 정의되어있어야 로직이 동작합니다. 필요없으면 작성하지 않아도 됩니다.
135135
*/
136136
requestInitialData () {
137-
return this.getRequestAllVersionCommand();
137+
return this._getRequestAllVersionCommand();
138138
}
139139

140140
/**
@@ -178,7 +178,7 @@ class ArduinoBase extends BaseModule {
178178
if (time >= 3000) {
179179
this._serialPort.close();
180180
} else if (time >= 1000) {
181-
buffer.push(...this.requestInitialData());
181+
buffer.push(...this._getConnectionCheckCommand());
182182
}
183183
return buffer;
184184
}
@@ -187,7 +187,6 @@ class ArduinoBase extends BaseModule {
187187
handleLocalData (data) {
188188
this._receiveBuffer.push(...data);
189189
this._lastTime = Date.now();
190-
191190
while (this._receiveBuffer.length > 0) {
192191
const length = this._receiveBuffer.length;
193192
this._processReceiveData(this._receiveBuffer);
@@ -272,6 +271,10 @@ class ArduinoBase extends BaseModule {
272271
throw new Error('재정의 필요');
273272
}
274273

274+
_getConnectionCheckCommand () {
275+
return this._getRequestBatteryVoltageCommand();
276+
}
277+
275278
/**
276279
* 장치 초기화 명령어 반환
277280
*/
@@ -296,7 +299,7 @@ class ArduinoBase extends BaseModule {
296299
/**
297300
* 전체 버전 요청
298301
*/
299-
getRequestAllVersionCommand () {
302+
_getRequestAllVersionCommand () {
300303
return [SysexCMD.START, SysexCMD.GET, Instruction.GET_VERSION, 0x00, SysexCMD.END];
301304
}
302305

app/modules/roborobo_cube.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,8 @@ class Cube extends ArduinoBase {
3333
this._setSensorMode(0);
3434
}
3535

36-
/**
37-
* @override
38-
*/
3936
requestInitialData () {
40-
return this.getRequestAllVersionCommand();
37+
return super.requestInitialData();
4138
}
4239

4340
checkInitialData (data, config) {
@@ -92,7 +89,14 @@ class Cube extends ArduinoBase {
9289
* @override
9390
*/
9491
get targetVersion () {
95-
return {model: 65, hardware: 1, firmware: 16};
92+
return {model: 65, hardware: 1, firmware: 18};
93+
}
94+
95+
/**
96+
* @override
97+
*/
98+
_getConnectionCheckCommand () {
99+
return this._getRequestAllVersionCommand();
96100
}
97101

98102
/**

app/modules/roborobo_robokit_rs.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ class RobokitRS extends ArduinoBase {
109109
* @override
110110
*/
111111
get targetVersion () {
112-
return {model: 0, hardware: 10, firmware: 28}
112+
return {model: 0, hardware: 10, firmware: 30};
113+
}
114+
115+
_getConnectionCheckCommand () {
116+
return super._getConnectionCheckCommand();
113117
}
114118

115119
/**
@@ -308,7 +312,7 @@ class State extends ArduinoStateBase {
308312
z: 0
309313
},
310314
shake: 0,
311-
}
315+
};
312316
}
313317
}
314318

app/modules/roborobo_roduino.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Roduino extends ArduinoBase {
3030
}
3131

3232
requestInitialData () {
33-
return this.getRequestAllVersionCommand();
33+
return super.requestInitialData();
3434
}
3535

3636
checkInitialData (data, config) {
@@ -83,6 +83,13 @@ class Roduino extends ArduinoBase {
8383
return {model: 1, hardware: 1, firmware: 2};
8484
}
8585

86+
/**
87+
* @override
88+
*/
89+
_getConnectionCheckCommand () {
90+
return this._getRequestAllVersionCommand();
91+
}
92+
8693
/**
8794
* @override
8895
*/

app/modules/roborobo_roe.js

+8-19
Original file line numberDiff line numberDiff line change
@@ -86,26 +86,8 @@ class RoE extends ArduinoBase {
8686
return super.validateLocalData(data);
8787
}
8888

89-
/**
90-
* @override
91-
*/
9289
requestLocalData () {
93-
const buffer = [];
94-
for (let i = 0; i < this._sendBuffer.length; i++) {
95-
const bytes = this._sendBuffer.shift();
96-
if (bytes && bytes.length > 0) {
97-
buffer.push(...bytes);
98-
}
99-
}
100-
101-
// 연결 상태 유지
102-
const time = Date.now() - this._lastTime;
103-
if (time >= 3000) {
104-
this._serialPort.close();
105-
} else if (time >= 1000) {
106-
buffer.push(...this.getRequestAllVersionCommand());
107-
}
108-
return buffer;
90+
return super.requestLocalData();
10991
}
11092

11193
handleLocalData (data) {
@@ -165,6 +147,13 @@ class RoE extends ArduinoBase {
165147
return {model: 64, hardware: 1, firmware: 26};
166148
}
167149

150+
/**
151+
* @override
152+
*/
153+
_getConnectionCheckCommand () {
154+
return this._getRequestAllVersionCommand();
155+
}
156+
168157
/**
169158
* 실시간: 0, 카드리더모드: 3, 정지:5, 컬러보정모드:6, 자이로센서 기본자세:7, 라인트레이싱: 8, 연결해제: 127
170159
* @param {any} mode

0 commit comments

Comments
 (0)