Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop hw #647

Merged
merged 2 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added app/firmwares/DynamixelCsDll.dll
Binary file not shown.
Binary file added app/firmwares/OpenCM7.0.bin
Binary file not shown.
Binary file added app/firmwares/opencm7Dfu.exe
Binary file not shown.
8 changes: 8 additions & 0 deletions app/modules/robotis_openCM70EDU.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
"win32-x64": "ROBOTIS/ROBOTIS CDC Driver.bat"
},
"selectPort" : true,
"firmware": {
"type": "opencm7",
"offset": "0x8004000",
"name": "OpenCM7.0",
"translate" : "실과로봇 펌웨어 업데이트",
"latest_version": 21
},
"firmwareBaudRate": 57600,
"hardware": {
"type": "serial",
"control": "slave",
Expand Down
98 changes: 98 additions & 0 deletions app/src/main/core/serial/flasher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,102 @@ class Flasher {
});
}

private _flashOpenCM7(
firmware: IOpenCM7TypeFirmware,
port: string,
options: {
baudRate?: number;
MCUType?: string;
}
): Promise<any[]> {
return new Promise((resolve) => {
const cmd = [
'opencm7Dfu.exe',
' opencm7',
` ${port}`,
` ${firmware.name}.bin`,
].join('');

logger.info(`OpenCM7.0 board firmware requested.\nparameter is ${cmd}`);
try {
this.flasherProcess = exec(
cmd,
{
cwd: directoryPaths.firmware(),
},
(...args) => {
resolve(args);
}
).on('exit', code => {
if (code != null)
{
if (code > 2147483647)
{
code = code - 4294967296;
}
}
console.log('final exit code is', code);
}
);
}
catch (error) {

}
});
}

checkOpenCM7Version(
port: string,
latest_version: number,
): Promise<any[]> {
return new Promise((resolve) => {
const cmd = [
'opencm7Dfu.exe',
' opencm7',
` ${port}`,
' version',
].join('');

logger.info(`Read OpenCM7.0 board firmware version.\nparameter is ${cmd}`);
try {
this.flasherProcess = exec(
cmd,
{
cwd: directoryPaths.firmware(),
},
(...args) => {
resolve(args);
}
).on('exit', code => {
if (code != null)
{
console.log('code is', code);
if (code > 2147483647)
{
code = code - 4294967296;
}
}
if (code)
{
if (code < latest_version)
{
dialog.showMessageBox({
type: 'info',
title: `펌웨어 업데이트 안내 (v${latest_version})`,
message: '새로운 펌웨어가 배포되었습니다.\n펌웨어를 업데이트 해주세요.\nNew firmware is available.\nPlease update the firmware.\n'
});
}
}
console.log('final exit code is', code);
}
);
}
catch (error) {

}
});
}

flash(
firmware: IFirmwareInfo,
port: string,
Expand All @@ -149,6 +245,8 @@ class Flasher {
return this._flashCopy(firmware as ICopyTypeFirmware);
} else if ((firmware as IESP32TypeFirmware).type === 'esp32') {
return this._flashESP(firmware as IESP32TypeFirmware, port, options);
} else if ((firmware as IOpenCM7TypeFirmware).type === 'opencm7') {
return this._flashOpenCM7(firmware as IOpenCM7TypeFirmware, port, options);
} else {
return Promise.reject(new Error());
}
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/core/serial/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {CloudModeTypes} from '../../../common/constants';
import BaseScanner from '../baseScanner';
import SerialConnector from './connector';
import createLogger from '../../electron/functions/createLogger';
import Flasher from './flasher';

const logger = createLogger('core/SerialScanner.ts');

Expand All @@ -18,6 +19,7 @@ const logger = createLogger('core/SerialScanner.ts');
*/
class SerialScanner extends BaseScanner<SerialConnector> {
private isScanning = false;
private flasher = new Flasher();

static get SCAN_INTERVAL_MILLS() {
return 1500;
Expand Down Expand Up @@ -100,6 +102,20 @@ class SerialScanner extends BaseScanner<SerialConnector> {
return;
}


const firmware = this.config.firmware;

if (firmware)
{
if ((firmware as IOpenCM7TypeFirmware).type === 'opencm7')
{
if (selectedPorts[0] != null)
{
await this.flasher.checkOpenCM7Version(selectedPorts[0], (this.config.firmware as IOpenCM7TypeFirmware).latest_version);
}
}
}

const electedConnector = await electPort(selectedPorts, hardware, this.hwModule,
(connector) => {
if (this.config && this.config.firmware) {
Expand Down
11 changes: 10 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,20 @@ declare type IESP32TypeFirmware = {
afterDelay?: number;
translate?: string;
};
declare type IOpenCM7TypeFirmware = {
type: string;
offset: string;
name: string;
latest_version: number;
afterDelay?: number;
translate?: string;
};
declare type IFirmwareInfo =
| string
| [{ name: string; translate: string }]
| ICopyTypeFirmware
| IESP32TypeFirmware;
| IESP32TypeFirmware
| IOpenCM7TypeFirmware;
declare type ICustomButtonInfo =
| string
| { key: string; translate: string }
Expand Down
Loading