| 4 | import { EventEmitter } from 'events'; |
| 5 | |
| 6 | export class PyOCDServerController extends EventEmitter implements GDBServerController { |
| 7 | public readonly name: string = 'PyOCD'; |
| 8 | public readonly portsNeeded: string[] = ['gdbPort', 'consolePort', 'swoPort']; |
| 9 | |
| 10 | private args: ConfigurationArguments; |
| 11 | private ports: { [name: string]: number }; |
| 12 | |
| 13 | constructor() { |
| 14 | super(); |
| 15 | } |
| 16 | |
| 17 | public setPorts(ports: { [name: string]: number }): void { |
| 18 | this.ports = ports; |
| 19 | } |
| 20 | |
| 21 | public setArguments(args: ConfigurationArguments): void { |
| 22 | this.args = args; |
| 23 | } |
| 24 | |
| 25 | public customRequest(command: string, response: DebugProtocol.Response, args: any): boolean { |
| 26 | return false; |
| 27 | } |
| 28 | |
| 29 | public initCommands(): string[] { |
| 30 | const gdbport = this.ports[createPortName(this.args.targetProcessor)]; |
| 31 | |
| 32 | return [ |
| 33 | `target-select extended-remote localhost:${gdbport}`, |
| 34 | // Following needed for SWO and accessing some peripherals. |
| 35 | // Generally not a good thing to do |
| 36 | 'interpreter-exec console "set mem inaccessible-by-default off"' |
| 37 | ]; |
| 38 | } |
| 39 | |
| 40 | public launchCommands(): string[] { |
| 41 | const commands = [ |
| 42 | ...genDownloadCommands(this.args, ['interpreter-exec console "monitor reset halt"']), |
| 43 | 'interpreter-exec console "monitor reset halt"' |
| 44 | ]; |
| 45 | return commands; |
| 46 | } |
| 47 | |
| 48 | public attachCommands(): string[] { |
| 49 | const commands = [ |
| 50 | 'interpreter-exec console "monitor halt"' |
| 51 | ]; |
| 52 | return commands; |
| 53 | } |
| 54 | |
| 55 | public restartCommands(): string[] { |
| 56 | const commands: string[] = [ |
| 57 | 'interpreter-exec console "monitor reset"' |
| 58 | ]; |
| 59 | return commands; |
| 60 | } |
| 61 | |
| 62 | public swoAndRTTCommands(): string[] { |
| 63 | const commands = []; |
nothing calls this directly
no outgoing calls
no test coverage detected