@libs-scripts-mep/grav-fw-pvi 2.0.1 → 2.1.1

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.
Files changed (3) hide show
  1. package/README.md +78 -19
  2. package/grav-fw-pvi.js +45 -41
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -26,41 +26,100 @@ npm uninstall @libs-scripts-mep/grav-fw-pvi
26
26
  | Renesas | Renesas Flash Programmer | ✔️ |
27
27
  | Nuvoton | JLink v7.82 | ✔️ |
28
28
 
29
- ## Exemplo de Utilização de Buffers
29
+ ## Exemplo de Utilização do Modulo
30
30
 
31
+ ### STM8
31
32
  ```js
32
33
 
33
- static async GravaFirmware(ObjParams) {
34
+ static async GravaFirmware(dirFirm, dirOpt) {
34
35
 
35
- return new Promise(async (resolve) => {
36
+ const ObjParams = {
37
+
38
+ objArguments: {
39
+ verbose: true,
40
+ Device: "STM8S003F3",
41
+ },
42
+ timeOut : 4000
36
43
 
37
- if(await ExecGravacao(dirFirm, dirOpt, modelo_uC, ObjParams)){
38
- console.log("GRAVOU")
39
- }else{
40
- console.log("NÃO GRAVOU")
41
44
  }
42
45
 
43
- async function ExecGravacao(dirFirm, dirOpt, modelo_uC, ObjParams) {
46
+ return new Promise(async (resolve) => {
44
47
 
45
- let RetornoGravacao = await GravaFW.STM8(dirFirm, dirOpt, modelo_uC, ObjParams.timeOut)
48
+ let RetornoGravacao = await GravaFW.STM8(dirFirm, dirOpt, ObjParams.objArguments, ObjParams.timeOut)
46
49
 
47
50
  if (RetornoGravacao.sucess) {
48
51
 
49
- return true
52
+ console.log("GRAVOU")
50
53
 
51
54
  } else {
52
55
 
53
- if (ObjParams.Tentativa >= ObjParams.MaxTentativas) {
54
- return false
55
- } else {
56
- ObjParams.Tentativa++
57
- return ExecGravacao(dirFirm, dirOpt, modelo_uC, ObjParams)
58
- }
59
-
56
+ console.log("NÃO GRAVOU")
60
57
  }
61
58
 
62
- }
63
- }
59
+ })
60
+
61
+ }
64
62
 
65
63
  ```
66
64
 
65
+ #### <h3> Possíveis valores para os argumentos da gravação <h3>
66
+
67
+
68
+ ```js
69
+ [-BoardName=STxxx] ==========> Programming Tool name (ST-LINK, RLINK, STICE, ...)
70
+ [-Tool_ID=x] ================> ST-LINK Programming Tool ID (0, 1, 2...)
71
+ [-NbTools=x] ================> Number of ST-LINK Tools with same device connected (Tool_ID is automatically incremented)
72
+ [-Port=xxx] =================> Communication Port (USB, LPT1)
73
+ [-ProgMode=xxx] =============> Programming mode or protocol (SWIM, JTAG, SWD)
74
+ [-Device=STxxx] =============> Device name (exact same name as in STVP)
75
+ [-version] ==================> Display version of this application
76
+ [-verbose] ==================> Display messages, warnings, errors
77
+ [-log] ======================> Generate or append Result.log log file
78
+ [-loop] =====================> Loop on actions until 'Space' key hit
79
+ [-progress] =================> Display progress of each action
80
+ [-warn_protect] =============> Message Box if programming Option Byte protection
81
+ [-no_progProg] ==============> Do not program PROGRAM MEMORY (used to verify device from a file)
82
+ [-no_progData] ==============> Do not program DATA MEMORY (used to verify device from a file)
83
+ [-no_progOption] ============> Do not program OPTION BYTE (used to verify device from a file)
84
+ [-readProg] =================> Read PROGRAM MEMORY
85
+ [-readData] =================> Read DATA MEMORY
86
+ [-readOption] ===============> Read OPTION BYTE
87
+ [-erase] ====================> Erase the device (before programming)
88
+ [-blank] ====================> Blank Check the device (before programming)
89
+ [-verif] ====================> Verify the device after programming
90
+ [-FileProg=fname.hex/s19] ===> File name to program PROGRAM MEMORY area (hex or s19)
91
+ [-FileData=fname.hex/s19] ===> File name to program DATA MEMORY area (hex or s19)
92
+ [-FileOption=fname.hex/s19] => File name to program OPTION BYTE area (hex or s19)
93
+
94
+
95
+
96
+ objArguments = {
97
+
98
+ log: true or false
99
+ loop: true or false
100
+ erase: true or false
101
+ blank: true or false
102
+ verif: true or false
103
+ verbose: true or false
104
+ version: true or false
105
+ progress: true or false
106
+ readProg: true or false
107
+ readData: true or false
108
+ readOption: true or false
109
+ no_progProg: true or false
110
+ warn_protect: true or false
111
+ no_progOption: true or false
112
+ verbose: true or false,
113
+
114
+ Port:"USB",
115
+ ProgMode:"SWIM",
116
+ NbTools:"1",
117
+ Tool_ID:"0",
118
+ BoardName:"ST-LINK",
119
+ Device: "STM8S003F3",
120
+ FileData: ""
121
+
122
+ },
123
+
124
+
125
+ ```
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, modelo_uC = null, timeOut = 5000) {
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, modelo_uC)
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
- async function defineWriteSTM8(dirFirm, dirOpt, modelo_uC) {
66
-
67
- return new Promise((resolve) => {
68
-
69
- if (dirFirm != null && dirOpt != null) {
70
-
71
- dirFirm = dirFirm.replace(/[\\]/g, `\/`).replace(/\.stp|\.STP/, `.HEX`)
72
- dirOpt = dirOpt.replace(/[\\]/g, `\/`).replace(/\.stp|\.STP/, `.HEX`)
73
-
74
- resolve({
75
- sucess: true,
76
- commandLineArguments: `-BoardName=ST-LINK -Tool_ID=0 -NbTools=1 -Port=USB -ProgMode=SWIM -Device=${modelo_uC} -verbose -no_loop -no_warn_protect -FileProg=${dirFirm} -FileOption=${dirOpt}`,
77
- })
78
-
79
- } else if (dirFirm != null) {
80
-
81
- dirFirm = dirFirm.replace(/[\\]/g, `\/`).replace(/\.stp|\.STP/, `.HEX`)
82
-
83
- resolve({
84
- sucess: true,
85
- commandLineArguments: `-BoardName=ST-LINK -Tool_ID=0 -NbTools=1 -Port=USB -ProgMode=SWIM -Device=${modelo_uC} -verbose -no_loop -no_warn_protect -FileProg=${dirFirm}`,
86
- })
87
-
88
- } else if (dirOpt != null) {
89
-
90
- dirOpt = dirOpt.replace(/[\\]/g, `\/`).replace(/\.stp|\.STP/, `.HEX`)
91
-
92
- resolve({
93
- sucess: true,
94
- commandLineArguments: `-BoardName=ST-LINK -Tool_ID=0 -NbTools=1 -Port=USB -ProgMode=SWIM -Device=${modelo_uC} -verbose -no_loop -no_warn_protect -FileOption=${dirOpt}`,
95
- })
96
-
97
- } else {
98
- resolve({
99
- sucess: false,
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libs-scripts-mep/grav-fw-pvi",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "Auxilia na gravação de microcontroladores por linha de comando através do PVI",
5
5
  "main": "grav-fw-pvi.js",
6
6
  "scripts": {