Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Update test message for serial monitor #141

Merged
merged 2 commits into from
Aug 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
},
Expand Down Expand Up @@ -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"),
Expand Down
3 changes: 2 additions & 1 deletion src/serialPortControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add after that line another logToOutputChannel telling them to try re-plugging the device?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm pretty sure we can add another line that prints to an OutputChannel if an error occurs. Do you think logging to the Pacifica Simulator Output Channel is more appropriate?

logToOutputChannel(this._outputChannel, CONSTANTS.ERROR.RECONNECT_DEVICE);
reject(err);
} else {
logToOutputChannel(this._outputChannel, CONSTANTS.INFO.OPENED_SERIAL_PORT(this._currentPort));
Expand Down