| 4 | import { EventEmitter } from 'events'; |
| 5 | |
| 6 | export class BMPServerController extends EventEmitter implements GDBServerController { |
| 7 | public readonly name: string = 'BMP'; |
| 8 | public readonly portsNeeded: string[] = []; |
| 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 commands: string[] = [ |
| 31 | `target-select extended-remote ${this.args.BMPGDBSerialPort}` |
| 32 | ]; |
| 33 | |
| 34 | if (this.args.powerOverBMP === 'enable') { |
| 35 | commands.push('interpreter-exec console "monitor tpwr enable"'); |
| 36 | // sleep for 100 ms. MCU need some time to boot up after power up |
| 37 | commands.push('interpreter-exec console "shell sleep 0.1"'); |
| 38 | } |
| 39 | else if (this.args.powerOverBMP === 'disable'){ |
| 40 | commands.push('interpreter-exec console "monitor tpwr disable"'); |
| 41 | } |
| 42 | else{ |
| 43 | // keep last power state (do nothing) |
| 44 | } |
| 45 | |
| 46 | if (this.args.interface === 'jtag') { // TODO: handle ctag in when this server supports it |
| 47 | commands.push('interpreter-exec console "monitor jtag_scan"'); |
| 48 | } |
| 49 | else { |
| 50 | commands.push('interpreter-exec console "monitor swdp_scan"'); |
| 51 | } |
| 52 | |
| 53 | commands.push( |
| 54 | `interpreter-exec console "attach ${this.args.targetId}"`, |
| 55 | 'interpreter-exec console "set mem inaccessible-by-default off"' |
| 56 | ); |
| 57 | |
| 58 | return commands; |
| 59 | } |
| 60 | |
| 61 | public launchCommands(): string[] { |
| 62 | const commands = [ |
| 63 | ...genDownloadCommands(this.args, []), |
nothing calls this directly
no outgoing calls
no test coverage detected