@libs-scripts-mep/grav-fw-pvi 1.0.0 → 1.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.
Files changed (3) hide show
  1. package/README.md +39 -1
  2. package/grav-fw-pvi.js +77 -16
  3. package/package.json +25 -25
package/README.md CHANGED
@@ -23,12 +23,20 @@ npm uninstall @libs-scripts-mep/grav-fw-pvi
23
23
  | Fabricante | Ferramenta | Suporte |
24
24
  | ---------- | ------------------------ | ------- |
25
25
  | ST | STVP | ✔️ |
26
- | Renesas | Renesas Flash Programmer | |
26
+ | Renesas | Renesas Flash Programmer | ✔️ |
27
27
 
28
28
  ## Resumo da Classe
29
29
 
30
30
  ```js
31
31
 
32
+ /**
33
+ * Realiza gravacao nos microcontroladores ST atraves do PVI, via STVP command line
34
+ * @param {string} dirFirm formato esperado: "I:\\\Documentos\\\Softwares\\\STM8\\\STM8S003F3\\\INV-173\\\173v01\\\173v01_1.50_Com.stp"
35
+ * @param {string} dirOpt formato esperado: "I:\\\Documentos\\\Softwares\\\STM8\\\STM8S003F3\\\INV-173\\\173v01\\\173v01_1.50_Com.stp"
36
+ * @param {string} modelo_uC formato esperado: "STM8S003F3"
37
+ * @param {function} callback
38
+ * @param {number} timeOut
39
+ */
32
40
  GravaFW.STM8(params , callback , timeOut = 5000){
33
41
 
34
42
  //invoca o STVP passando os parametros informados
@@ -44,5 +52,35 @@ GravaFW.STM8(params , callback , timeOut = 5000){
44
52
  }
45
53
  }
46
54
 
55
+
56
+ /**
57
+ * Realiza gravacao nos microcontroladores renesas atraves do PVI, via renesas flash programmer command line
58
+ * @param {string} dirProject Formato esperado: "I:\\\Documentos\\\Softwares\\\RENESAS\\\R5F51303ADFL\\\INV-301\\\301v06\\\301v06.rpj"
59
+ * @param {function} callback
60
+ * @param {number} timeOut
61
+ */
62
+ static Renesas(params, callback, timeOut = 5000) {
63
+
64
+ //invoca o Renesas Flash Programmer passando os parametros informados
65
+ let result = pvi.runInstructionS(`RENESAS.gravafw`, [params])
66
+
67
+ //executa callback dependendo do resultado
68
+ if (result.includes(`Operation completed.`)) {
69
+ console.log(`%cLog Program:\n\n${result}`, ' color: #00EE66')
70
+ callback(true, result)
71
+
72
+ } else if (result.includes(`Cannot find the specified tool.`)) {
73
+ console.log(`%cLog Program:\n\n${result}`, ' color: #EE0033')
74
+ callback(null, `Gravador não respondeu`)
75
+
76
+ } else if (result.includes(`Error: No project file specifed.`)) {
77
+ console.log(`%cLog Program:\n\n${result}`, ' color: #EE0033')
78
+ callback(false, `Projeto informado é inválido`)
79
+
80
+ } else {
81
+ console.log(`%cLog Program:\n\n${result}`, ' color: #EE0033')
82
+ callback(false, `Falha na gravação do firmware final`)
83
+ }
84
+ }
47
85
  ```
48
86
 
package/grav-fw-pvi.js CHANGED
@@ -1,12 +1,20 @@
1
1
  class GravaFW {
2
2
 
3
+ /**
4
+ * Realiza gravacao nos microcontroladores ST atraves do PVI, via STVP command line
5
+ * @param {string} dirFirm formato esperado: "I:\\\Documentos\\\Softwares\\\STM8\\\STM8S003F3\\\INV-173\\\173v01\\\173v01_1.50_Com.stp"
6
+ * @param {string} dirOpt formato esperado: "I:\\\Documentos\\\Softwares\\\STM8\\\STM8S003F3\\\INV-173\\\173v01\\\173v01_1.50_Com.stp"
7
+ * @param {string} modelo_uC formato esperado: "STM8S003F3"
8
+ * @param {function} callback
9
+ * @param {number} timeOut
10
+ */
3
11
  static STM8(dirFirm = null, dirOpt = null, modelo_uC = null, callback = () => { }, timeOut = 5000) {
4
12
 
5
13
  if (dirFirm != null && dirOpt != null) {
6
14
 
7
- let result = pvi.runInstructionS("ST.writefirmwarestm8_stlink", [
8
- dirFirm.replace(/[\\]/g, "\/").replace(/\.stp|\.STP/, ".HEX"),
9
- dirOpt.replace(/[\\]/g, "\/").replace(/\.stp|\.STP/, ".HEX"),
15
+ let result = pvi.runInstructionS(`ST.writefirmwarestm8_stlink`, [
16
+ dirFirm.replace(/[\\]/g, `\/`).replace(/\.stp|\.STP/, `.HEX`),
17
+ dirOpt.replace(/[\\]/g, `\/`).replace(/\.stp|\.STP/, `.HEX`),
10
18
  modelo_uC
11
19
  ])
12
20
 
@@ -25,12 +33,12 @@ class GravaFW {
25
33
  } else if (result.includes(`ERROR : Cannot communicate with the tool`)) {
26
34
 
27
35
  console.log(`%cLog Program:\n\n${result}`, ' color: #EE0033')
28
- callback(null, "Gravador não respondeu")
36
+ callback(null, `Gravador não respondeu`)
29
37
 
30
38
  } else {
31
39
 
32
40
  console.log(`%cLog Program:\n\n${result}`, ' color: #EE0033')
33
- callback(false, "Falha na gravação do firmware final")
41
+ callback(false, `Falha na gravação do firmware final`)
34
42
 
35
43
  }
36
44
  }
@@ -38,13 +46,13 @@ class GravaFW {
38
46
 
39
47
  let timeoutMonitor = setTimeout(() => {
40
48
  clearInterval(monitor)
41
- callback(false, "Tempo de gravação excedido")
49
+ callback(false, `Tempo de gravação excedido`)
42
50
  }, timeOut)
43
51
 
44
52
  } else if (dirFirm != null) {
45
53
 
46
54
  let result = pvi.runInstructionS(`ST.writeprogramstm8_stlink`, [
47
- dirFirm.replace(/[\\]/g, "\/").replace(/\.stp|\.STP/, ".HEX"),
55
+ dirFirm.replace(/[\\]/g, `\/`).replace(/\.stp|\.STP/, `.HEX`),
48
56
  modelo_uC
49
57
  ])
50
58
 
@@ -63,12 +71,12 @@ class GravaFW {
63
71
  } else if (result.includes(`ERROR : Cannot communicate with the tool`)) {
64
72
 
65
73
  console.log(`%cLog Program:\n\n${result}`, ' color: #EE0033')
66
- callback(null, "Gravador não respondeu")
74
+ callback(null, `Gravador não respondeu`)
67
75
 
68
76
  } else {
69
77
 
70
78
  console.log(`%cLog Program:\n\n${result}`, ' color: #EE0033')
71
- callback(false, "Falha na gravação do firmware")
79
+ callback(false, `Falha na gravação do firmware`)
72
80
 
73
81
  }
74
82
  }
@@ -76,13 +84,13 @@ class GravaFW {
76
84
 
77
85
  let timeoutMonitor = setTimeout(() => {
78
86
  clearInterval(monitor)
79
- callback(false, "Tempo de gravação excedido")
87
+ callback(false, `Tempo de gravação excedido`)
80
88
  }, timeOut)
81
89
 
82
90
  } else if (dirOpt != null) {
83
91
 
84
- let result = pvi.runInstructionS("ST.writeoptionstm8_stlink", [
85
- dirOpt.replace(/[\\]/g, "\/").replace(/\.stp|\.STP/, ".HEX"),
92
+ let result = pvi.runInstructionS(`ST.writeoptionstm8_stlink`, [
93
+ dirOpt.replace(/[\\]/g, `\/`).replace(/\.stp|\.STP/, `.HEX`),
86
94
  modelo_uC
87
95
  ])
88
96
 
@@ -101,12 +109,12 @@ class GravaFW {
101
109
  } else if (result.includes(`ERROR : Cannot communicate with the tool`)) {
102
110
 
103
111
  console.log(`%cLog Desprotect:\n\n${result}`, ' color: #EE0033')
104
- callback(null, "Gravador não respondeu")
112
+ callback(null, `Gravador não respondeu`)
105
113
 
106
114
  } else {
107
115
 
108
116
  console.log(`%cLog Desprotect:\n\n${result}`, ' color: #EE0033')
109
- callback(false, "Falha na gravação do option byte")
117
+ callback(false, `Falha na gravação do option byte`)
110
118
 
111
119
  }
112
120
  }
@@ -114,11 +122,64 @@ class GravaFW {
114
122
 
115
123
  let timeoutMonitor = setTimeout(() => {
116
124
  clearInterval(monitor)
117
- callback(false, "Tempo de gravação excedido")
125
+ callback(false, `Tempo de gravação excedido`)
118
126
  }, timeOut)
119
127
 
120
128
  } else {
121
- callback(false, "Nenhum diretório de firmware ou option byte informado.")
129
+ callback(false, `Nenhum diretório de firmware ou option byte informado.`)
130
+ }
131
+ }
132
+
133
+ /**
134
+ * Realiza gravacao nos microcontroladores renesas atraves do PVI, via renesas flash programmer command line
135
+ * @param {string} dirProject Formato esperado: "I:\\\Documentos\\\Softwares\\\RENESAS\\\R5F51303ADFL\\\INV-301\\\301v06\\\301v06.rpj"
136
+ * @param {function} callback
137
+ * @param {number} timeOut
138
+ */
139
+ static Renesas(dirProject = null, callback = () => { }, timeOut = 5000) {
140
+
141
+ if (dirProject != null) {
142
+
143
+ let result = pvi.runInstructionS(`RENESAS.gravafw`, [dirProject])
144
+
145
+ let monitor = setInterval(() => {
146
+
147
+ if (result != null) {
148
+
149
+ clearInterval(monitor)
150
+ clearTimeout(timeoutMonitor)
151
+
152
+ if (result.includes(`Operation completed.`)) {
153
+
154
+ console.log(`%cLog Program:\n\n${result}`, ' color: #00EE66')
155
+ callback(true, result)
156
+
157
+ } else if (result.includes(`Cannot find the specified tool.`)) {
158
+
159
+ console.log(`%cLog Program:\n\n${result}`, ' color: #EE0033')
160
+ callback(null, `Gravador não respondeu`)
161
+
162
+ } else if (result.includes(`Error: No project file specifed.`)) {
163
+
164
+ console.log(`%cLog Program:\n\n${result}`, ' color: #EE0033')
165
+ callback(false, `Projeto informado é inválido`)
166
+
167
+ } else {
168
+
169
+ console.log(`%cLog Program:\n\n${result}`, ' color: #EE0033')
170
+ callback(false, `Falha na gravação do firmware final`)
171
+
172
+ }
173
+ }
174
+ }, 100)
175
+
176
+ let timeoutMonitor = setTimeout(() => {
177
+ clearInterval(monitor)
178
+ callback(false, `Tempo de gravação excedido`)
179
+ }, timeOut)
180
+
181
+ } else {
182
+ callback(false, `Caminho do firmware não informado`)
122
183
  }
123
184
  }
124
185
  }
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
- {
2
- "name": "@libs-scripts-mep/grav-fw-pvi",
3
- "version": "1.0.0",
4
- "description": "Auxilia na gravação de microcontroladores por linha de comando através do PVI",
5
- "main": "grav-fw-pvi.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/libs-scripts-mep/grav-fw-pvi.git"
12
- },
13
- "keywords": [
14
- "gravacao",
15
- "firmware",
16
- "uc",
17
- "microcontrolador"
18
- ],
19
- "author": "Lucas Kroth",
20
- "license": "ISC",
21
- "bugs": {
22
- "url": "https://github.com/libs-scripts-mep/grav-fw-pvi/issues"
23
- },
24
- "homepage": "https://github.com/libs-scripts-mep/grav-fw-pvi#readme"
25
- }
1
+ {
2
+ "name": "@libs-scripts-mep/grav-fw-pvi",
3
+ "version": "1.1.0",
4
+ "description": "Auxilia na gravação de microcontroladores por linha de comando através do PVI",
5
+ "main": "grav-fw-pvi.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/libs-scripts-mep/grav-fw-pvi.git"
12
+ },
13
+ "keywords": [
14
+ "gravacao",
15
+ "firmware",
16
+ "uc",
17
+ "microcontrolador"
18
+ ],
19
+ "author": "Lucas Kroth",
20
+ "license": "ISC",
21
+ "bugs": {
22
+ "url": "https://github.com/libs-scripts-mep/grav-fw-pvi/issues"
23
+ },
24
+ "homepage": "https://github.com/libs-scripts-mep/grav-fw-pvi#readme"
25
+ }