@libs-scripts-mep/grav-fw-pvi 2.0.1 → 2.1.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 +45 -41
- package/package.json +1 -1
package/grav-fw-pvi.js
CHANGED
|
@@ -6,11 +6,11 @@ class GravaFW {
|
|
|
6
6
|
* @param {string} dirOpt formato esperado: "I:\\\Documentos\\\Softwares\\\STM8\\\STM8S003F3\\\INV-173\\\173v01\\\173v01_1.50_Com.stp"
|
|
7
7
|
* @param {string} modelo_uC formato esperado: "STM8S003F3"
|
|
8
8
|
*/
|
|
9
|
-
static async STM8(dirFirm = null, dirOpt = null,
|
|
9
|
+
static async STM8(dirFirm = null, dirOpt = null, objArguments = {}, timeOut = 5000) {
|
|
10
10
|
|
|
11
11
|
return new Promise(async (resolve) => {
|
|
12
12
|
|
|
13
|
-
let ObjWriteSTM8 = await defineWriteSTM8(dirFirm, dirOpt,
|
|
13
|
+
let ObjWriteSTM8 = await defineWriteSTM8(dirFirm, dirOpt, objArguments)
|
|
14
14
|
|
|
15
15
|
let logGravacao = ""
|
|
16
16
|
|
|
@@ -61,47 +61,51 @@ class GravaFW {
|
|
|
61
61
|
|
|
62
62
|
})
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @param {string} dirFirm
|
|
67
|
+
* @param {string} dirOpt
|
|
68
|
+
* @param {object} objArguments
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
async function defineWriteSTM8(dirFirm, dirOpt, objArguments) {
|
|
72
|
+
|
|
73
|
+
return new Promise(async (resolve) => {
|
|
74
|
+
|
|
75
|
+
const log = objArguments.log == true ? "-log " : ""
|
|
76
|
+
const loop = objArguments.loop == true ? "-loop " : "-no_loop "
|
|
77
|
+
const erase = objArguments.erase == true ? "-erase " : ""
|
|
78
|
+
const blank = objArguments.blank == true ? "-blank " : ""
|
|
79
|
+
const verif = objArguments.verif == true ? "-verif " : ""
|
|
80
|
+
const verbose = objArguments.verbose == true ? "-verbose " : ""
|
|
81
|
+
const version = objArguments.version == true ? "-version " : ""
|
|
82
|
+
const progress = objArguments.progress == true ? "-progress " : ""
|
|
83
|
+
const readProg = objArguments.readProg == true ? "-readProg " : ""
|
|
84
|
+
const readData = objArguments.readData == true ? "-readData " : ""
|
|
85
|
+
const readOption = objArguments.readOption == true ? "-readOption " : ""
|
|
86
|
+
const no_progProg = objArguments.no_progProg == true ? "-no_progProg " : ""
|
|
87
|
+
const warn_protect = objArguments.warn_protect == true ? "-warn_protect " : "-no_warn_protect "
|
|
88
|
+
const no_progOption = objArguments.no_progOption == true ? "-no_progOption " : ""
|
|
89
|
+
|
|
90
|
+
const Port = objArguments.Port != undefined ? `-Port=${objArguments.Port} ` : "-Port=USB "
|
|
91
|
+
const ProgMode = objArguments.ProgMode != undefined ? `-ProgMode=${objArguments.ProgMode} ` : "-ProgMode=SWIM "
|
|
92
|
+
const Device = objArguments.Device != undefined ? `-Device=${objArguments.Device}` : ""
|
|
93
|
+
const NbTools = objArguments.NbTools != undefined ? `-NbTools=${objArguments.NbTools} ` : "-NbTools=1 "
|
|
94
|
+
const Tool_ID = objArguments.Tool_ID != undefined ? `-Tool_ID=${objArguments.Tool_ID} ` : "-Tool_ID=0 "
|
|
95
|
+
const BoardName = objArguments.BoardName != undefined ? `-BoardName=${objArguments.BoardName} ` : "-BoardName=ST-LINK ";
|
|
96
|
+
|
|
97
|
+
const FileData = objArguments.FileData != undefined ? `-FileOption=${objArguments.FileData} ` : ""
|
|
98
|
+
const FileProg = dirFirm != null ? `-FileProg=${dirFirm.replace(/[\\]/g, `\/`).replace(/\.stp|\.STP/, `.HEX`)} ` : ""
|
|
99
|
+
const FileOption = dirOpt != null ? `-FileOption=${dirOpt.replace(/[\\]/g, `\/`).replace(/\.stp|\.STP/, `.HEX`)} ` : ""
|
|
100
|
+
|
|
101
|
+
resolve({
|
|
102
|
+
sucess: true,
|
|
103
|
+
commandLineArguments: `${BoardName}${Tool_ID}${NbTools}${Port}${ProgMode}${verbose}` +
|
|
104
|
+
`${loop}${warn_protect}${erase}${blank}${verif}${FileProg}${FileOption}${FileData}` +
|
|
105
|
+
`${readProg}${readData}${readOption}${log}${progress}${no_progOption}${no_progProg}${version}${version}${Device}`,
|
|
106
|
+
})
|
|
102
107
|
|
|
103
108
|
})
|
|
104
|
-
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
|