Hello all,
I’m currently trying to use the unity test framework for my Raspberry Pi Pico W. I’m also running VSCode as superuser on an Arch Linux machine. While running pio test -vvv, I get some TimeoutErrors after the upload completes.
Building, uploading and monitoring works individually yet running the test doesn’t.
During the test i get this:
The device was rebooted to start the application.
Testing...
If you don't see any output for the first 10 secs, please reset board (press reset button)
[Errno 2] could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'
Alternatively if i comment test_port = /dev/ttyACM0 in the ini file, I get:
The device was rebooted to start the application.
Testing...
If you don't see any output for the first 10 secs, please reset board (press reset button)
TimeoutError: Could not automatically find serial port for the `Pico W` board based on the declared HWIDs=['2E8A:00C0', '2E8A:F00A']
TimeoutError: Could not automatically find serial port based on the known UART bridges
Below are the important files. Thank you for any suggestions!
platformio.ini
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:rpipicow]
platform = https://github.com/maxgerhardt/platform-raspberrypi
framework = arduino
board = rpipicow
board_build.core = earlephilhower
upload_protocol = picotool
upload_port = /dev/ttyACM0
monitor_speed = 115200
monitor_port = /dev/ttyACM0
check_tool = cppcheck
test_speed = 115200
test_port= /dev/ttyACM0
lib_deps =
ESP8266WiFi
build_flags = -I include/
src/manager.cpp:
#include "manager.h"
// settings to make the manager pico an access point
const char* ssid = "Manager";
const char* password = "123456789";
// for statics addressing our lovely network
IPAddress local_IP(192,168,0,2);
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,255,0);
// Turns raspberry pi into an access point for other devices to connect to via WiFi
void initAP(String ssid, String password) {
Serial.print("Attempting to create AP: ");
Serial.println(WiFi.softAP(ssid, password, 1, false, 4) ? "Created" : "Failed");
Serial.print("Attempting to configure AP: ");
WiFi.softAPConfig(local_IP, gateway, subnet);
Serial.println((WiFi.SSID() == ssid) ? "Configured" : "Failed");
Serial.print("Local static IP: ");
Serial.println(WiFi.softAPIP());
}
void setup() {
// Allows us to see messages on our computers via serial monitor e.g. pio device monitor
Serial.begin(115200);
// 5 sec delay so that an external serial monitor can connect for debugging purposes
delay(5000);
initAP(ssid, password);
}
void loop() {
}
include/manager.h
#ifndef MANAGER_H
#define MANAGER_H
#include <Arduino.h>
#include <ESP8266WiFi.h>
void initAP();
#endif
test/testinitAP.cpp
#include <Arduino.h>
#include <unity.h>
#include <ESP8266WiFi.h>
#include "manager.h"
// settings to make the manager pico an access point
const char* ssid = "Manager";
const char* password = "123456789";
// for statics addressing our lovely network
IPAddress local_IP(192,168,0,2);
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,255,0);
/*
void test_ap_activated(void) {
initAP(ssid, password);
TEST_ASSERT_EQUAL_STRING(ssid, WiFi.softAPSSID().c_str());
WiFi.softAPdisconnect();
}
void test_ap_local_ip(void) {
initAP(ssid, password);
IPAddress expected_ip(192, 168, 0, 1);
TEST_ASSERT_EQUAL(expected_ip, WiFi.softAPIP());
WiFi.softAPdisconnect();
}
*/
void test_stuff(void) {
WiFi.softAP(ssid, password);
TEST_ASSERT_EQUAL_STRING(ssid, WiFi.softAPSSID().c_str());
WiFi.softAPdisconnect();
}
void setup(void) {
}
void tearDown(void) {
}
int main(void) {
delay(10000);
UNITY_BEGIN();
RUN_TEST(test_stuff);
//RUN_TEST(test_ap_activated);
//RUN_TEST(test_ap_local_ip);
return UNITY_END();
}