From 3d6a5619b040ca14b57b55211ad43fbc8c637817 Mon Sep 17 00:00:00 2001 From: Morgan Allen Date: Sun, 5 Aug 2018 17:51:44 -0700 Subject: [PATCH 1/4] moving to testbed infrastructure --- package.json | 6 +++++- test/test.js | 33 ++++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 443c29c..124e76e 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,10 @@ "dependencies": { "async": "^2.6.1", "serialport": "^6.2.2", - "tape": "^4.9.1" + "tape": "^4.9.1", + "testbed-query-fixtures": "^1.0.0" + }, + "devDependencies": { + "homedir": "^0.6.0" } } diff --git a/test/test.js b/test/test.js index f33222c..20ceecb 100644 --- a/test/test.js +++ b/test/test.js @@ -1,16 +1,35 @@ var async = require("async"); +var homedir = require("homedir")(); var spawn = require("child_process").spawn; var SerialPort = require("serialport"); var path = require("path"); var test = require("tape"); +var testbed = require("testbed-query-fixtures"); const exec = path.join(process.env.IDF_PATH, "components", "esptool_py", "esptool", "esptool.py"); -const portString = "/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_SERIAL_ID-if00-port0"; const buildPath = path.join(__dirname, "lora32", "build"); -const TB_DEV1 = process.env.TB_DEV1 || "0000"; -const TB_DEV2 = process.env.TB_DEV2 || "0001"; +try { + var testbedConfig = require(path.join(homedir, ".testbed.json")); +} catch(e) { + console.log(e); + console.error("testbed.json fixture file not found."); + + process.exit(1); +} + +var devices = testbed({ + f: [ "esp32", "lora" ], + fixtures: testbedConfig.fixtures +}); + +if(devices.length < 2) { + throw new Error("Not enough test devices available"); +} + +const TB_DEV1 = devices[0].DEVNAME; +const TB_DEV2 = devices[1].DEVNAME; var args = [ "--chip", @@ -108,20 +127,20 @@ async.series([ async.parallel([ function(done) { - flash(portString.replace("SERIAL_ID", TB_DEV1), done); + flash(TB_DEV1, done); }, function(done) { - flash(portString.replace("SERIAL_ID", TB_DEV2), done); + flash(TB_DEV2, done); }], next); }, function(next) { async.parallel({ dev1: function(done) { - serial(portString.replace("SERIAL_ID", TB_DEV1), done); + serial(TB_DEV1, done); }, dev2: function(done) { - serial(portString.replace("SERIAL_ID", TB_DEV2), done); + serial(TB_DEV2, done); } }, next); } From 7028879878bb154ed92140d1b424f2f868276801 Mon Sep 17 00:00:00 2001 From: Morgan Allen Date: Sun, 5 Aug 2018 18:09:07 -0700 Subject: [PATCH 2/4] might help some native module issues --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f7beaa4..b8880b5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,6 +10,7 @@ all_tests: - echo $PATH - make -f test/lora32/Makefile defconfig all - npm install --unsafe-perm + - npm rebuild - npm test artifacts: paths: From 384b0ba8eea8863805efb9a00ed159a3df3023e2 Mon Sep 17 00:00:00 2001 From: Morgan Allen Date: Fri, 10 Aug 2018 10:10:27 -0700 Subject: [PATCH 3/4] move to esptool-wrapper for flashing esp devices --- package.json | 1 + test/lora32/main/main.c | 4 ++- test/test.js | 63 ++++++++++++++++++++--------------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index 124e76e..6f76c03 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ }, "dependencies": { "async": "^2.6.1", + "esptool-wrapper": "^1.0.4", "serialport": "^6.2.2", "tape": "^4.9.1", "testbed-query-fixtures": "^1.0.0" diff --git a/test/lora32/main/main.c b/test/lora32/main/main.c index 7467b83..071cedd 100644 --- a/test/lora32/main/main.c +++ b/test/lora32/main/main.c @@ -121,9 +121,11 @@ void set_mode(void *args) { } void send(void *args) { - ESP_LOGI(TAG, "sending: %s\n", (char*)args); + ESP_LOGI(TAG, "sending: %s", (char*)args); lora32_send(&lora, (uint8_t *)args, 12); + + ESP_LOGI(TAG, "done"); }; void set_spreadfactor(void *args) { diff --git a/test/test.js b/test/test.js index 20ceecb..30c9ead 100644 --- a/test/test.js +++ b/test/test.js @@ -1,4 +1,5 @@ var async = require("async"); +var esptool = require("esptool-wrapper"); var homedir = require("homedir")(); var spawn = require("child_process").spawn; var SerialPort = require("serialport"); @@ -6,8 +7,6 @@ var path = require("path"); var test = require("tape"); var testbed = require("testbed-query-fixtures"); -const exec = path.join(process.env.IDF_PATH, "components", "esptool_py", "esptool", "esptool.py"); - const buildPath = path.join(__dirname, "lora32", "build"); try { @@ -31,41 +30,39 @@ if(devices.length < 2) { const TB_DEV1 = devices[0].DEVNAME; const TB_DEV2 = devices[1].DEVNAME; -var args = [ - "--chip", - "esp32", - "--baud", - "460800", - "--before", - "default_reset", - "--after", - "hard_reset", - "write_flash", - "-z", - "--flash_mode", - "dio", - "--flash_freq", - "40m", - "--flash_size", - "detect", - "0x1000", - path.join(buildPath, "bootloader/bootloader.bin"), - "0x10000", - path.join(buildPath, "lora32.bin"), - "0x8000", - path.join(buildPath, "partitions_singleapp.bin") -]; +var testBins = { + 0x1000: path.join(buildPath, "bootloader/bootloader.bin"), + 0x8000: path.join(buildPath, "partitions_singleapp.bin"), + 0x10000: path.join(buildPath, "lora32.bin") +}; function flash(port, cb) { + var argsReset = [ + "--before", + "default_reset", + "--after", + "hard_reset" + ]; + + var argsWriteFlash = [ + "-z", + "--flash_mode", + "dio", + "--flash_freq", + "40m", + "--flash_size", + "detect" + ]; + console.log("Flashing devices at %s", port); - var cp = spawn(exec, ["--port", port].concat(args)); - - cp.on("exit", function(code) { - console.log("%s\nexited: %d", port, code); - - cb(code === 0 ? null : new Error("exited non-zero: " + code)); - }); + esptool({ + port: port, + baud: 460800, + files: testBins, + args: argsReset, + cmdArgs: argsWriteFlash + }, cb); } function toggleReset(sp) { From fce02bf039fe63fd51e067262276ec75e3367497 Mon Sep 17 00:00:00 2001 From: Morgan Allen Date: Sun, 13 Jan 2019 09:38:25 -0800 Subject: [PATCH 4/4] mistake in example code --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc0478c..d63b784 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ This is the most basic usage. Setting up the LoRa instance, setting it's receive lora32_init(&lora); - lora32_send(&lora, "Hello, LoRa", 10); + lora32_send(&lora, "Hello, LoRa", 11); ```