diff --git a/src/constants.ts b/src/constants.ts index 2dff4dabc..1e7176339 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -89,6 +89,10 @@ export const CONSTANTS = { "error.noPythonPath", "We found that you don't have Python 3 installed on your computer, please install the latest version, add it to your PATH and try again." ), + RECONNECT_DEVICE: localize( + "error.reconnectDevice", + "Please disconnect your Circuit Playground Express and try again." + ), STDERR: (data: string) => { return localize("error.stderr", `\n[ERROR] ${data} \n`); }, @@ -204,6 +208,10 @@ export const CONSTANTS = { SERIAL_MONITOR_NAME: localize( "misc.serialMonitorName", "Pacifica Serial Monitor" + ), + SERIAL_MONITOR_TEST_IF_OPEN: localize( + "misc.testIfPortOpen", + "Test if serial port is open" ) }, NAME: localize("name", "Pacifica Simulator"), diff --git a/src/serialPortControl.ts b/src/serialPortControl.ts index b34bf9350..0b3eb3912 100644 --- a/src/serialPortControl.ts +++ b/src/serialPortControl.ts @@ -73,9 +73,10 @@ export class SerialPortControl { this._currentSerialPort = new SerialPortControl.serialport(this._currentPort, { baudRate: this._currentBaudRate }); this._outputChannel.show(); this._currentSerialPort.on("open", () => { - this._currentSerialPort.write("msft", "Both NL & CR", (err: any) => { + this._currentSerialPort.write(CONSTANTS.MISC.SERIAL_MONITOR_TEST_IF_OPEN, "Both NL & CR", (err: any) => { if (err && !(err.message.indexOf(CONSTANTS.ERROR.COMPORT_UNKNOWN_ERROR) >= 0)) { logToOutputChannel(this._outputChannel, CONSTANTS.ERROR.FAILED_TO_OPEN_SERIAL_PORT(this._currentPort)); + logToOutputChannel(this._outputChannel, CONSTANTS.ERROR.RECONNECT_DEVICE); reject(err); } else { logToOutputChannel(this._outputChannel, CONSTANTS.INFO.OPENED_SERIAL_PORT(this._currentPort));