()
| 330 | } |
| 331 | |
| 332 | private startRttMonitor() { |
| 333 | this.session.miDebugger.on('msg', (type, msg) => { |
| 334 | if (this.rttStarted) { return; } |
| 335 | msg = this.MI2Leftover + msg; |
| 336 | const lines = msg.split(/[\r]\n/); |
| 337 | if (!msg.endsWith('\n')) { |
| 338 | this.MI2Leftover = lines.pop(); |
| 339 | } else { |
| 340 | this.MI2Leftover = ''; |
| 341 | } |
| 342 | for (const line of lines) { |
| 343 | OpenOCDLog('OpenOCD Output: ' + line); |
| 344 | if (line.includes(this.rttSearchStr)) { |
| 345 | OpenOCDLog('RTT control block found. Done'); |
| 346 | this.rttStarted = true; |
| 347 | if (this.rttPollTimer) { |
| 348 | clearTimeout(this.rttPollTimer); |
| 349 | this.rttPollTimer = undefined; |
| 350 | } |
| 351 | break; |
| 352 | } else if (/rtt:.*will retry/.test(line)) { |
| 353 | OpenOCDLog('This version of OpenOCD already know how to poll. Done'); |
| 354 | this.rttAutoStartDetected = true; |
| 355 | } |
| 356 | } |
| 357 | }); |
| 358 | |
| 359 | this.session.miDebugger.on('stopped', async (info: any, reason: string) => { |
| 360 | if (reason === 'entry') { return; } // Should not happen |
| 361 | if (!this.rttStarted && this.tclSocket && !this.rttAutoStartDetected) { |
| 362 | OpenOCDLog('Debugger paused: sending command "rtt start"'); |
| 363 | const result = await this.tclCommand('rtt start'); |
| 364 | } |
| 365 | }); |
| 366 | } |
| 367 | |
| 368 | private tclSocket: net.Socket = undefined; // If null, it was opened once but then later closed due to error or the other end closed it |
| 369 | private tclSocketBuf = ''; |
no test coverage detected