@libs-scripts-mep/grav-fw-pvi 2.1.2 → 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 +80 -2
- package/package.json +1 -1
package/grav-fw-pvi.js
CHANGED
|
@@ -121,7 +121,7 @@ class GravaFW {
|
|
|
121
121
|
* @param {string} dirProject Formato esperado: "I:\\\Documentos\\\Softwares\\\RENESAS\\\R5F51303ADFL\\\INV-301\\\301v06\\\301v06.rpj"
|
|
122
122
|
* @param {number} timeOut
|
|
123
123
|
*/
|
|
124
|
-
static Renesas(dirProject = null, timeOut = 5000) {
|
|
124
|
+
static async Renesas(dirProject = null, timeOut = 5000) {
|
|
125
125
|
|
|
126
126
|
return new Promise((resolve) => {
|
|
127
127
|
|
|
@@ -186,7 +186,7 @@ class GravaFW {
|
|
|
186
186
|
* @param {string} device modelo do micrcontrolador
|
|
187
187
|
* @param {number} timeOut
|
|
188
188
|
*/
|
|
189
|
-
static JLink_v7(dirProject = null, commandFile = null, device, timeOut = 10000) {
|
|
189
|
+
static async JLink_v7(dirProject = null, commandFile = null, device, timeOut = 10000) {
|
|
190
190
|
|
|
191
191
|
let logGravacao = ""
|
|
192
192
|
|
|
@@ -224,4 +224,82 @@ class GravaFW {
|
|
|
224
224
|
}, timeOut)
|
|
225
225
|
|
|
226
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
|
+
|
|
227
305
|
}
|