Skip to content

Commit 818f2fb

Browse files
authored
Merge pull request #647 from irarykim/develop-hw
Develop hw
2 parents d35b302 + dffb937 commit 818f2fb

File tree

7 files changed

+132
-1
lines changed

7 files changed

+132
-1
lines changed

app/firmwares/DynamixelCsDll.dll

12 KB
Binary file not shown.

app/firmwares/OpenCM7.0.bin

39.9 KB
Binary file not shown.

app/firmwares/opencm7Dfu.exe

9.5 KB
Binary file not shown.

app/modules/robotis_openCM70EDU.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
"win32-x64": "ROBOTIS/ROBOTIS CDC Driver.bat"
1717
},
1818
"selectPort" : true,
19+
"firmware": {
20+
"type": "opencm7",
21+
"offset": "0x8004000",
22+
"name": "OpenCM7.0",
23+
"translate" : "실과로봇 펌웨어 업데이트",
24+
"latest_version": 21
25+
},
26+
"firmwareBaudRate": 57600,
1927
"hardware": {
2028
"type": "serial",
2129
"control": "slave",

app/src/main/core/serial/flasher.ts

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,102 @@ class Flasher {
135135
});
136136
}
137137

138+
private _flashOpenCM7(
139+
firmware: IOpenCM7TypeFirmware,
140+
port: string,
141+
options: {
142+
baudRate?: number;
143+
MCUType?: string;
144+
}
145+
): Promise<any[]> {
146+
return new Promise((resolve) => {
147+
const cmd = [
148+
'opencm7Dfu.exe',
149+
' opencm7',
150+
` ${port}`,
151+
` ${firmware.name}.bin`,
152+
].join('');
153+
154+
logger.info(`OpenCM7.0 board firmware requested.\nparameter is ${cmd}`);
155+
try {
156+
this.flasherProcess = exec(
157+
cmd,
158+
{
159+
cwd: directoryPaths.firmware(),
160+
},
161+
(...args) => {
162+
resolve(args);
163+
}
164+
).on('exit', code => {
165+
if (code != null)
166+
{
167+
if (code > 2147483647)
168+
{
169+
code = code - 4294967296;
170+
}
171+
}
172+
console.log('final exit code is', code);
173+
}
174+
);
175+
}
176+
catch (error) {
177+
178+
}
179+
});
180+
}
181+
182+
checkOpenCM7Version(
183+
port: string,
184+
latest_version: number,
185+
): Promise<any[]> {
186+
return new Promise((resolve) => {
187+
const cmd = [
188+
'opencm7Dfu.exe',
189+
' opencm7',
190+
` ${port}`,
191+
' version',
192+
].join('');
193+
194+
logger.info(`Read OpenCM7.0 board firmware version.\nparameter is ${cmd}`);
195+
try {
196+
this.flasherProcess = exec(
197+
cmd,
198+
{
199+
cwd: directoryPaths.firmware(),
200+
},
201+
(...args) => {
202+
resolve(args);
203+
}
204+
).on('exit', code => {
205+
if (code != null)
206+
{
207+
console.log('code is', code);
208+
if (code > 2147483647)
209+
{
210+
code = code - 4294967296;
211+
}
212+
}
213+
if (code)
214+
{
215+
if (code < latest_version)
216+
{
217+
dialog.showMessageBox({
218+
type: 'info',
219+
title: `펌웨어 업데이트 안내 (v${latest_version})`,
220+
message: '새로운 펌웨어가 배포되었습니다.\n펌웨어를 업데이트 해주세요.\nNew firmware is available.\nPlease update the firmware.\n'
221+
});
222+
}
223+
}
224+
console.log('final exit code is', code);
225+
}
226+
);
227+
}
228+
catch (error) {
229+
230+
}
231+
});
232+
}
233+
138234
flash(
139235
firmware: IFirmwareInfo,
140236
port: string,
@@ -149,6 +245,8 @@ class Flasher {
149245
return this._flashCopy(firmware as ICopyTypeFirmware);
150246
} else if ((firmware as IESP32TypeFirmware).type === 'esp32') {
151247
return this._flashESP(firmware as IESP32TypeFirmware, port, options);
248+
} else if ((firmware as IOpenCM7TypeFirmware).type === 'opencm7') {
249+
return this._flashOpenCM7(firmware as IOpenCM7TypeFirmware, port, options);
152250
} else {
153251
return Promise.reject(new Error());
154252
}

app/src/main/core/serial/scanner.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {CloudModeTypes} from '../../../common/constants';
66
import BaseScanner from '../baseScanner';
77
import SerialConnector from './connector';
88
import createLogger from '../../electron/functions/createLogger';
9+
import Flasher from './flasher';
910

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

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

2224
static get SCAN_INTERVAL_MILLS() {
2325
return 1500;
@@ -100,6 +102,20 @@ class SerialScanner extends BaseScanner<SerialConnector> {
100102
return;
101103
}
102104

105+
106+
const firmware = this.config.firmware;
107+
108+
if (firmware)
109+
{
110+
if ((firmware as IOpenCM7TypeFirmware).type === 'opencm7')
111+
{
112+
if (selectedPorts[0] != null)
113+
{
114+
await this.flasher.checkOpenCM7Version(selectedPorts[0], (this.config.firmware as IOpenCM7TypeFirmware).latest_version);
115+
}
116+
}
117+
}
118+
103119
const electedConnector = await electPort(selectedPorts, hardware, this.hwModule,
104120
(connector) => {
105121
if (this.config && this.config.firmware) {

types/index.d.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,20 @@ declare type IESP32TypeFirmware = {
2929
afterDelay?: number;
3030
translate?: string;
3131
};
32+
declare type IOpenCM7TypeFirmware = {
33+
type: string;
34+
offset: string;
35+
name: string;
36+
latest_version: number;
37+
afterDelay?: number;
38+
translate?: string;
39+
};
3240
declare type IFirmwareInfo =
3341
| string
3442
| [{ name: string; translate: string }]
3543
| ICopyTypeFirmware
36-
| IESP32TypeFirmware;
44+
| IESP32TypeFirmware
45+
| IOpenCM7TypeFirmware;
3746
declare type ICustomButtonInfo =
3847
| string
3948
| { key: string; translate: string }

0 commit comments

Comments
 (0)