@libs-scripts-mep/grav-fw-pvi 1.2.0 → 1.3.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 (2) hide show
  1. package/grav-fw-pvi.js +26 -31
  2. package/package.json +1 -1
package/grav-fw-pvi.js CHANGED
@@ -139,45 +139,40 @@ class GravaFW {
139
139
  static Renesas(dirProject = null, callback = () => { }, timeOut = 5000) {
140
140
 
141
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')
142
+ const eventObserverId = pvi.FWLink.globalDaqMessagesObservers.add((msg, [renesasOutLog]) => {
143
+ console.log(`%cLog Program: ${renesasOutLog}`, ' color: #B0E0E6')
144
+
145
+ if (renesasOutLog != undefined) {
146
+ if (renesasOutLog.includes(`Operation completed.`)) {
147
+ pvi.FWLink.globalDaqMessagesObservers.remove(eventObserverId)
148
+ clearTimeout(timeoutGravacao)
149
+ callback(true, `Gravação bem-sucedida: ${dirProject}`)
150
+ } else if (renesasOutLog.includes(`Cannot find the specified tool.`)) {
151
+ pvi.FWLink.globalDaqMessagesObservers.remove(eventObserverId)
152
+ clearTimeout(timeoutGravacao)
160
153
  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')
154
+ } else if (renesasOutLog.includes(`Error: No project file specifed.`)) {
155
+ pvi.FWLink.globalDaqMessagesObservers.remove(eventObserverId)
156
+ clearTimeout(timeoutGravacao)
165
157
  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
-
158
+ } else if (renesasOutLog.includes(`The device is not responding.`)) {
159
+ pvi.FWLink.globalDaqMessagesObservers.remove(eventObserverId)
160
+ clearTimeout(timeoutGravacao)
161
+ callback(false, `Sem resposta do microcontrolador`)
162
+ } else if (renesasOutLog.includes(`A framing error occurred while receiving data`)) {
163
+ pvi.FWLink.globalDaqMessagesObservers.remove(eventObserverId)
164
+ clearTimeout(timeoutGravacao)
165
+ callback(false, `Falha ao receber dados do microcontrolador`)
172
166
  }
173
167
  }
174
- }, 100)
168
+ }, "sniffer.exec")
175
169
 
176
- let timeoutMonitor = setTimeout(() => {
177
- clearInterval(monitor)
170
+ let timeoutGravacao = setTimeout(() => {
171
+ pvi.FWLink.globalDaqMessagesObservers.remove(eventObserverId)
178
172
  callback(false, `Tempo de gravação excedido`)
179
173
  }, timeOut)
180
174
 
175
+ pvi.runInstructionS("EXEC", [`${pvi.runInstructionS("GETRESOURCESPATH", [])}/Renesas/RFPV3.Console.exe`, dirProject, "true", "true"])
181
176
  } else {
182
177
  callback(false, `Caminho do firmware não informado`)
183
178
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libs-scripts-mep/grav-fw-pvi",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
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": {