@libs-scripts-mep/grav-fw-pvi 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/grav-fw-pvi.js +96 -11
- package/package.json +1 -1
package/grav-fw-pvi.js
CHANGED
|
@@ -37,12 +37,28 @@ class GravaFW {
|
|
|
37
37
|
|
|
38
38
|
resolve({ sucess: null, msg: `Gravador não respondeu` })
|
|
39
39
|
|
|
40
|
+
} else if (param[0].includes(`(API) ERROR`)) {
|
|
41
|
+
|
|
42
|
+
PVI.FWLink.globalDaqMessagesObservers.remove(id)
|
|
43
|
+
clearTimeout(timeOutGravacao)
|
|
44
|
+
|
|
45
|
+
resolve({ sucess: null, msg: `Não foi possível realizara a gravação` })
|
|
46
|
+
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
}, "sniffer.exec")
|
|
45
52
|
|
|
53
|
+
let timeOutGravacao = setTimeout(() => {
|
|
54
|
+
|
|
55
|
+
console.log(`%cLog Program:\n\n${logGravacao}`, ' color: #EE0033')
|
|
56
|
+
PVI.FWLink.globalDaqMessagesObservers.remove(id)
|
|
57
|
+
|
|
58
|
+
resolve({ sucess: false, msg: `Falha na gravação do firmware final` })
|
|
59
|
+
|
|
60
|
+
}, timeOut)
|
|
61
|
+
|
|
46
62
|
} else {
|
|
47
63
|
console.log(`%cNenhum diretório de firmware ou option byte informado`, ' color: #EE0033')
|
|
48
64
|
resolve({ sucess: false, msg: `Nenhum diretório de firmware ou option byte informado` })
|
|
@@ -50,15 +66,6 @@ class GravaFW {
|
|
|
50
66
|
|
|
51
67
|
pvi.runInstructionS("EXEC", [`C:/Program Files (x86)/STMicroelectronics/st_toolset/stvp/STVP_CmdLine.exe`, ObjWriteSTM8.commandLineArguments, "true", "true"])
|
|
52
68
|
|
|
53
|
-
let timeOutGravacao = setTimeout(() => {
|
|
54
|
-
|
|
55
|
-
console.log(`%cLog Program:\n\n${logGravacao}`, ' color: #EE0033')
|
|
56
|
-
PVI.FWLink.globalDaqMessagesObservers.remove(id)
|
|
57
|
-
|
|
58
|
-
resolve({ sucess: false, msg: `Falha na gravação do firmware final` })
|
|
59
|
-
|
|
60
|
-
}, timeOut)
|
|
61
|
-
|
|
62
69
|
})
|
|
63
70
|
|
|
64
71
|
/**
|
|
@@ -114,7 +121,7 @@ class GravaFW {
|
|
|
114
121
|
* @param {string} dirProject Formato esperado: "I:\\\Documentos\\\Softwares\\\RENESAS\\\R5F51303ADFL\\\INV-301\\\301v06\\\301v06.rpj"
|
|
115
122
|
* @param {number} timeOut
|
|
116
123
|
*/
|
|
117
|
-
static Renesas(dirProject = null, timeOut = 5000) {
|
|
124
|
+
static async Renesas(dirProject = null, timeOut = 5000) {
|
|
118
125
|
|
|
119
126
|
return new Promise((resolve) => {
|
|
120
127
|
|
|
@@ -179,7 +186,7 @@ class GravaFW {
|
|
|
179
186
|
* @param {string} device modelo do micrcontrolador
|
|
180
187
|
* @param {number} timeOut
|
|
181
188
|
*/
|
|
182
|
-
static JLink_v7(dirProject = null, commandFile = null, device, timeOut = 10000) {
|
|
189
|
+
static async JLink_v7(dirProject = null, commandFile = null, device, timeOut = 10000) {
|
|
183
190
|
|
|
184
191
|
let logGravacao = ""
|
|
185
192
|
|
|
@@ -217,4 +224,82 @@ class GravaFW {
|
|
|
217
224
|
}, timeOut)
|
|
218
225
|
|
|
219
226
|
}
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
static async ESP32(sessionStorageTag, appPath, isBatFile, betweenMsgTimeout) {
|
|
230
|
+
|
|
231
|
+
return new Promise((resolve) => {
|
|
232
|
+
|
|
233
|
+
console.time("WriteFirmware")
|
|
234
|
+
|
|
235
|
+
if (!appPath) {
|
|
236
|
+
resolve({ sucess: false, msg: "Caminho de arquivo para gravação não especificado" }); return
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
let portsFound = null, tryingPorts = [], lastTimeMsg = new Date().getTime()
|
|
240
|
+
|
|
241
|
+
const betweenMsgMonitor = setInterval(() => {
|
|
242
|
+
|
|
243
|
+
if (new Date().getTime() - lastTimeMsg > betweenMsgTimeout) {
|
|
244
|
+
clearInterval(betweenMsgMonitor)
|
|
245
|
+
PVI.FWLink.globalDaqMessagesObservers.remove(id)
|
|
246
|
+
resolve({ sucess: false, msg: "esptool.py encontrou um problema e teve que ser finalizado." }); return
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
}, 1000)
|
|
250
|
+
|
|
251
|
+
const id = PVI.FWLink.globalDaqMessagesObservers.add((filter, message) => {
|
|
252
|
+
|
|
253
|
+
const info = message[0]
|
|
254
|
+
lastTimeMsg = new Date().getTime()
|
|
255
|
+
console.log(`%cLog Program: ${message}`, ' color: #87CEEB')
|
|
256
|
+
|
|
257
|
+
if (info.includes("Found")) {
|
|
258
|
+
const splittedInfo = info.split(" ")
|
|
259
|
+
portsFound = parseInt(splittedInfo[1])
|
|
260
|
+
|
|
261
|
+
} else if (info.includes("Serial port")) {
|
|
262
|
+
const splittedInfo = info.split(" ")
|
|
263
|
+
tryingPorts.push(splittedInfo[2])
|
|
264
|
+
UI.setMsg(`Tentando gravar na porta ${splittedInfo[2]}`)
|
|
265
|
+
|
|
266
|
+
} else if (info.includes("failed to connect")) {
|
|
267
|
+
if (tryingPorts.length >= portsFound) {
|
|
268
|
+
PVI.FWLink.globalDaqMessagesObservers.remove(id)
|
|
269
|
+
resolve({ sucess: false, msg: "Gravador não conseguiu se conectar com o ESP32" }); return
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
} else if (info.includes("%")) {
|
|
273
|
+
UI.setMsg(info)
|
|
274
|
+
|
|
275
|
+
} else if (info.includes("Hard resetting via RTS pin...")) {
|
|
276
|
+
sessionStorage.getItem(sessionStorageTag) == null ? sessionStorage.setItem(sessionStorageTag, tryingPorts.pop()) : null
|
|
277
|
+
PVI.FWLink.globalDaqMessagesObservers.remove(id)
|
|
278
|
+
resolve({ sucess: true, msg: "Gravação bem sucedida" })
|
|
279
|
+
console.timeEnd("WriteFirmware")
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
}, "PVI.Sniffer.sniffer.exec_return.data")
|
|
283
|
+
|
|
284
|
+
console.log("writeFirmware ID", id)
|
|
285
|
+
|
|
286
|
+
let pythonPath = "C:/esp-idf/Python/python.exe"
|
|
287
|
+
let espToolPath = "C:/esp-idf/components/esptool_py/esptool/esptool.py"
|
|
288
|
+
let port = ""
|
|
289
|
+
|
|
290
|
+
sessionStorage.getItem(sessionStorageTag) != null ? port = `-p${sessionStorage.getItem(sessionStorageTag)}` : null
|
|
291
|
+
|
|
292
|
+
const args = `${espToolPath} ${port} -b 480600 --before default_reset --after hard_reset --chip esp32 write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x0000 ${appPath}`
|
|
293
|
+
|
|
294
|
+
if (isBatFile) {
|
|
295
|
+
console.log(`Executando batch: ${appPath} args: ${port}`)
|
|
296
|
+
pvi.runInstructionS("EXEC", [appPath, port, "true", "true", "true"])
|
|
297
|
+
} else {
|
|
298
|
+
console.log(`Executando python: ${pythonPath} args: ${args}`)
|
|
299
|
+
pvi.runInstructionS("EXEC", [pythonPath, args, "true", "true", "true"])
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
})
|
|
303
|
+
}
|
|
304
|
+
|
|
220
305
|
}
|