samyk / easel-driver

Easel driver for Linux, Mac, Windows, ARM, Raspberry Pi, Intel, FTDI, CH340, CH341, CP210x, FTDI clones, local, and remote access to GRBL-based CNC controllers
95 stars 24 forks source link

Fix Perl string for new version of Easel #25

Closed SpencerCornish closed 1 year ago

SpencerCornish commented 1 year ago

FYI @samyk

Easel 0.4.0 is out, and the old version of the easel driver is unsupported and thus no longer works with the website. There was a change that broke one of the perl strings, so I fixed it.

Here's a diff of the change that broke the replacer:

-        // TODO: scope for callback?
-        callback(ports);
+ // Fix for serialPort change from comName -> path
+        // Apparently the object returned from the serial
+        // port lib is also read-only
+        callback(ports.map(function(port) {
+          const clone = {};
+          for (const key of Object.getOwnPropertyNames(port)) {
+            clone[key] = port[key];
+          }
+          clone.comName = port.path;
+          return clone;
+        }));

After running the new perl code, the function looks like this:

      function(ports) {
        // Fix for serialPort change from comName -> path
        // Apparently the object returned from the serial
        // port lib is also read-only
        ports.forEach(function(part, i) {
          if (this[i].manufacturer === "1a86")
            this[i].manufacturer = "FTDI";
          if (this[i].manufacturer === "Silicon Labs")
            this[i].manufacturer = "FTDI";
          if (this[i].vendorId === "1a86")
            this[i].vendorId = "0403";
           if (this[i].vendorId === "10c4")
            this[i].vendorId = "0403";           
        }, ports);
        callback(ports.map(function(port) {
          const clone = {};
          for (const key of Object.getOwnPropertyNames(port)) {
            clone[key] = port[key];
          }
          clone.comName = port.path;
          return clone;
        }));
      },

FYI

I haven't had time to test this fix with a CNC machine yet (I will soon unless someone else can confirm), but I assume it will work. Either way, master does not currently work with 0.4.0 for the ESP/FluidNC case :(