Skip to content

Commit

Permalink
Merge pull request #699 from RoboroboLab/develop-hw
Browse files Browse the repository at this point in the history
robokit rs 동작 오류 수정 및 리팩터링
  • Loading branch information
Tnks2U authored Jan 18, 2024
2 parents 26d11fa + 838af54 commit ae1d8f4
Show file tree
Hide file tree
Showing 7 changed files with 3,554 additions and 3,896 deletions.
3,684 changes: 1,671 additions & 2,013 deletions app/firmwares/roborobo_cube.hex

Large diffs are not rendered by default.

3,697 changes: 1,845 additions & 1,852 deletions app/firmwares/roborobo_robokit_rs.hex

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions app/modules/roborobo_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class ArduinoBase extends BaseModule {
* 이 두 함수가 정의되어있어야 로직이 동작합니다. 필요없으면 작성하지 않아도 됩니다.
*/
requestInitialData () {
return this.getRequestAllVersionCommand();
return this._getRequestAllVersionCommand();
}

/**
Expand Down Expand Up @@ -178,7 +178,7 @@ class ArduinoBase extends BaseModule {
if (time >= 3000) {
this._serialPort.close();
} else if (time >= 1000) {
buffer.push(...this.requestInitialData());
buffer.push(...this._getConnectionCheckCommand());
}
return buffer;
}
Expand All @@ -187,7 +187,6 @@ class ArduinoBase extends BaseModule {
handleLocalData (data) {
this._receiveBuffer.push(...data);
this._lastTime = Date.now();

while (this._receiveBuffer.length > 0) {
const length = this._receiveBuffer.length;
this._processReceiveData(this._receiveBuffer);
Expand Down Expand Up @@ -272,6 +271,10 @@ class ArduinoBase extends BaseModule {
throw new Error('재정의 필요');
}

_getConnectionCheckCommand () {
return this._getRequestBatteryVoltageCommand();
}

/**
* 장치 초기화 명령어 반환
*/
Expand All @@ -296,7 +299,7 @@ class ArduinoBase extends BaseModule {
/**
* 전체 버전 요청
*/
getRequestAllVersionCommand () {
_getRequestAllVersionCommand () {
return [SysexCMD.START, SysexCMD.GET, Instruction.GET_VERSION, 0x00, SysexCMD.END];
}

Expand Down
14 changes: 9 additions & 5 deletions app/modules/roborobo_cube.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ class Cube extends ArduinoBase {
this._setSensorMode(0);
}

/**
* @override
*/
requestInitialData () {
return this.getRequestAllVersionCommand();
return super.requestInitialData();
}

checkInitialData (data, config) {
Expand Down Expand Up @@ -92,7 +89,14 @@ class Cube extends ArduinoBase {
* @override
*/
get targetVersion () {
return {model: 65, hardware: 1, firmware: 16};
return {model: 65, hardware: 1, firmware: 18};
}

/**
* @override
*/
_getConnectionCheckCommand () {
return this._getRequestAllVersionCommand();
}

/**
Expand Down
8 changes: 6 additions & 2 deletions app/modules/roborobo_robokit_rs.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ class RobokitRS extends ArduinoBase {
* @override
*/
get targetVersion () {
return {model: 0, hardware: 10, firmware: 28}
return {model: 0, hardware: 10, firmware: 30};
}

_getConnectionCheckCommand () {
return super._getConnectionCheckCommand();
}

/**
Expand Down Expand Up @@ -308,7 +312,7 @@ class State extends ArduinoStateBase {
z: 0
},
shake: 0,
}
};
}
}

Expand Down
9 changes: 8 additions & 1 deletion app/modules/roborobo_roduino.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Roduino extends ArduinoBase {
}

requestInitialData () {
return this.getRequestAllVersionCommand();
return super.requestInitialData();
}

checkInitialData (data, config) {
Expand Down Expand Up @@ -83,6 +83,13 @@ class Roduino extends ArduinoBase {
return {model: 1, hardware: 1, firmware: 2};
}

/**
* @override
*/
_getConnectionCheckCommand () {
return this._getRequestAllVersionCommand();
}

/**
* @override
*/
Expand Down
27 changes: 8 additions & 19 deletions app/modules/roborobo_roe.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,8 @@ class RoE extends ArduinoBase {
return super.validateLocalData(data);
}

/**
* @override
*/
requestLocalData () {
const buffer = [];
for (let i = 0; i < this._sendBuffer.length; i++) {
const bytes = this._sendBuffer.shift();
if (bytes && bytes.length > 0) {
buffer.push(...bytes);
}
}

// 연결 상태 유지
const time = Date.now() - this._lastTime;
if (time >= 3000) {
this._serialPort.close();
} else if (time >= 1000) {
buffer.push(...this.getRequestAllVersionCommand());
}
return buffer;
return super.requestLocalData();
}

handleLocalData (data) {
Expand Down Expand Up @@ -165,6 +147,13 @@ class RoE extends ArduinoBase {
return {model: 64, hardware: 1, firmware: 26};
}

/**
* @override
*/
_getConnectionCheckCommand () {
return this._getRequestAllVersionCommand();
}

/**
* 실시간: 0, 카드리더모드: 3, 정지:5, 컬러보정모드:6, 자이로센서 기본자세:7, 라인트레이싱: 8, 연결해제: 127
* @param {any} mode
Expand Down

0 comments on commit ae1d8f4

Please sign in to comment.