Skip to content

Instantly share code, notes, and snippets.

@rwaldron
Last active April 4, 2017 06:46
Show Gist options
  • Select an option

  • Save rwaldron/4e4afee850adcebeb7eea61e2f74550a to your computer and use it in GitHub Desktop.

Select an option

Save rwaldron/4e4afee850adcebeb7eea61e2f74550a to your computer and use it in GitHub Desktop.
Tessel 2: wifi measuring and power demonstration with replacement components Raw
  • Subject Tessels

    • ava: T2 as presently shipping
    • dolores: T2 testing new components
  • Tests

    • Wifi Strength

      • Wifi measuring @ 3m from router (10 measurements)

        Board Source Avg dBm Avg Quality
        ava USB to MBP -41 69/70
        ava USB to 5V 2400mAh battery (fully charged) -43 67/70
        ava USB to 5V 1000mAh wall wart -39 70/70
        dolores USB to MBP -37 70/70
        dolores USB to 5V 2400mAh battery (fully charged) -41 69/70
        dolores USB to 5V 1000mAh wall wart -41 69/70
      • Wifi measuring @ 5m from router (10 measurements)

        Board Source Avg dBm Avg Quality
        ava USB to MBP -41 69/70
        ava USB to 5V 2400mAh battery (fully charged) -42 69/70
        ava USB to 5V 1000mAh wall wart -42 70/70
        dolores USB to MBP -40 70/70
        dolores USB to 5V 2400mAh battery (fully charged) -42 70/70
        dolores USB to 5V 1000mAh wall wart -43 70/70
      • Wifi measuring @ 5m horizontal, 3.1m vertical, with steel staircase between router and Tessel (10 measurements)

        Board Source Avg dBm Avg Quality
        ava USB to 5V 2400mAh battery (fully charged) -59 49/70
        dolores USB to 5V 2400mAh battery (fully charged) -56 55/70
      • Measurment program:

        "use strict";
        
        let cp = require("child_process");
        let iterations = -1;
        let results = [];
        
        const MAX_MEASUREMENTS = 10;
        const COMMAND = "iwinfo wlan0 scan";
        const NETWORK = "Bocoup";
        
        function capturedBm(result) {
          let cells = result.split("\nCell");
          return cells.reduce((captured, cell) => {
            if (captured) {
              return captured;
            }
        
            let isMeasuredNetwork = cell.includes(`ESSID: "${NETWORK}"`);
            let rsignal = /Signal: (.*) dBm/;
        
            if (isMeasuredNetwork) {
              let parsed = rsignal.exec(cell);
        
              if (parsed.length === 2) {
                captured = Number(parsed[1]);
              }
            }
            return captured;
          }, null);
        }
        
        function run() {
          if (++iterations === MAX_MEASUREMENTS) {
            console.log(`Average of ${MAX_MEASUREMENTS} measurements: `);
            console.log(results.reduce((a, b) => a + b) / results.length);
          } else {
            cp.exec(COMMAND, (error, result) => {
              results.push(capturedBm(result));
              console.log(".");
              run();
            });
          }
        }
        
        run();
    • Download

      • Download https://builds.tessel.io/t2/firmware/40b2b46a62a34b5a26170c75f7e717cea673d1eb.tar.gz (3 measurements)

        • Length: 15457068 (15M) [application/x-gzip]

          Board Avg Seconds
          ava 19.60
          dolores 20.86
      • Measurment program:

        "use strict";
        
        const got = require("got");
        const REMOTE_TGZ_URL = "https://builds.tessel.io/t2/firmware/40b2b46a62a34b5a26170c75f7e717cea673d1eb.tar.gz";
        const MAX_MEASUREMENTS = 3;
        
        let iterations = -1;
        let results = [];
        
        function run() {
          if (++iterations === MAX_MEASUREMENTS) {
            console.log(`Average of ${MAX_MEASUREMENTS} measurements: `);
            console.log(results.reduce((a, b) => a + b) / results.length);
          } else {
            const start = Date.now();
            got.stream(REMOTE_TGZ_URL).on("data", _ => {}).on("end", () => {
              const time = Date.now() - start;
              const result = time / 1000;
              results.push(result);
              console.log(result);
              run();
            });
          }
        }
        
        run();
    • USB Port Power

      • Can switch port power on and off

        Board Port Outcome
        ava 0 Yes
        ava 1 Yes
        dolores 0 Yes
        dolores 1 Yes
      • Test program:

        "use strict";
        
        let port = process.argv[2];
        let ppps = require("ppps");
        
        ppps.findHubs(0x1a40, 0x0101, (error, hubs) => {
          console.log("Port: ", port);
          console.log("Powering off");
          hubs[0].port(port).control(0);
        
          setTimeout(_ => {
            console.log("Powering On");
            hubs[0].port(port).control(1);
          }, 3000);
        });

        Run as:

        t2 run ppps.js [0]
        t2 run ppps.js [1]      
        
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment