@v5x/cli 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +16 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -118,7 +118,7 @@ var require_picocolors = __commonJS((exports, module) => {
118
118
  // package.json
119
119
  var package_default = {
120
120
  name: "@v5x/cli",
121
- version: "0.0.7",
121
+ version: "0.0.9",
122
122
  description: "Command line interface for v5x.",
123
123
  license: "MIT",
124
124
  type: "module",
@@ -746,13 +746,9 @@ class WebSerialPortAdapter extends EventTarget {
746
746
  this._info = info;
747
747
  }
748
748
  get readable() {
749
- if (!this._readable)
750
- throw new Error("Port not open");
751
749
  return this._readable;
752
750
  }
753
751
  get writable() {
754
- if (!this._writable)
755
- throw new Error("Port not open");
756
752
  return this._writable;
757
753
  }
758
754
  getInfo() {
@@ -2645,7 +2641,7 @@ class VexSerialConnection extends VexEventTarget {
2645
2641
  try {
2646
2642
  port = await this.serial.requestPort({ filters: this.filters });
2647
2643
  } catch (e) {
2648
- console.warn("No valid port selected.");
2644
+ throw new Error("No valid port selected.");
2649
2645
  }
2650
2646
  }
2651
2647
  if (port == null)
@@ -2758,7 +2754,9 @@ class VexSerialConnection extends VexEventTarget {
2758
2754
  clearTimeout(callbackInfo.timeout);
2759
2755
  this.callbacksQueue.splice(tryIdx - 1, 1);
2760
2756
  } catch (e) {
2761
- console.warn("Read error.", e, cache);
2757
+ if (!(e instanceof Error && e.message === "No data")) {
2758
+ console.warn("Read error.", e, cache);
2759
+ }
2762
2760
  await this.close();
2763
2761
  break;
2764
2762
  } finally {
@@ -3789,15 +3787,19 @@ async function main() {
3789
3787
  const device = new V5SerialDevice(serial);
3790
3788
  try {
3791
3789
  await device.connect();
3790
+ if (device.isConnected) {
3791
+ console.log("os:", device.brain.systemVersion.toUserString());
3792
+ console.log("name:", await device.brain.getValue("robotname"));
3793
+ console.log("team:", await device.brain.getValue("teamnumber"));
3794
+ console.log("id:", device.brain.uniqueId.toString());
3795
+ }
3792
3796
  } catch {
3793
3797
  console.warn(import_picocolors.default.yellow("v5 device not found"));
3794
- }
3795
- if (device.isConnected) {
3796
- console.log("os:", device.brain.systemVersion.toUserString());
3797
- console.log("name:", await device.brain.getValue("robotname"));
3798
- console.log("team:", await device.brain.getValue("teamnumber"));
3799
- console.log("id:", device.brain.uniqueId.toString());
3798
+ } finally {
3800
3799
  await device.disconnect();
3801
3800
  }
3802
3801
  }
3803
- main();
3802
+ main().then(() => process.exit(0), (error) => {
3803
+ console.error(error);
3804
+ process.exit(1);
3805
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v5x/cli",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Command line interface for v5x.",
5
5
  "license": "MIT",
6
6
  "type": "module",