-
-
Notifications
You must be signed in to change notification settings - Fork 795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test start delay option #3742
Comments
Could you re-test with |
Did a re-test for issue #3886 after |
I tested it on an Arduino Pro Micro (5V), that does the USB serial via the ATMega32U4 chip, and before updating I get
and then after upgrading (
I'm testing this on Windows 10 x64. After uploading, the board is reset and the COM port is temporarily lost and then reconnected. Seems like PIO tries to access it too early?
The german part translates to "The device does not recognize this command". |
Oh wow I just recognized another quirk of.. the Arduino core or the bootloader? The device will not send any output on the USB serial if the DTR line is not set. As in, a simple #include <Arduino.h>
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("Test");
delay(500);
} will make the device expose the USB Serial device but no output unless I use hterm to connect to and set DTR, or do When I use the "Test" button with above code, it will upload, and then fail to connect. After that if I connect with hterm and DTR line set, I will see the output.. |
This is still occurring with the latest core version per https://community.platformio.org/t/teensy-4-1-unit-testing-issue/21033. |
We plan to introduce a new feature in 5.2.0 where developers will be able to create their own result streamer/driver. We will provide examples of how to use it and include this use case where you have to need a special Serial connection. |
This can help, to temporary patch ... |
The underlying issue with the (Teensy 4 problem)[https://community.platformio.org/t/teensy-4-1-unit-testing-issue/21033] is that the test port disappears for a short while. Another way to fix the problem would be for Platform IO to wait until the specified test_port reappears before trying to connect to get the test results. |
To expand on that, this is also happening with my ESP32-S2 Kaluga1 |
this also happens with my STM32 If I DON'T specify the
However, if I DO specify
if i do the separate upload-only command, then wait, and then do the separate monitor command, then it works fine, also. so it's not a problem with the ports or anything, it simply an issue where the monitor is attempting to connect before the port is ready, and it's failing. there needs to be some timeout/retry logic in there. fwiw: i was able to work around this by adding a custom script:
|
See the solution in the original post #3742 (comment) |
- Use a single PlatformIO command to build, upload, and test. Previously, we we did this in a few steps because of a problem where the Swan's serial port wasn't ready after uploading and so the test step would fail because it couldn't find the serial port. I was able to reduce this to one step by using the approach described here: platformio/platformio-core#3742 - Fix a Bash typo in the step that cleaned up the Notehub proxy route. - I reinstalled tunnelmole using npm on the Orange Pi, and it's working again. I really don't know what was wrong here. In order for run_tmole.sh to find the tmole executable, I had to add a couple lines to the start of the script so that npm packages are on PATH. - Upgrade the note-arduino version to latest.
- Use a single PlatformIO command to build, upload, and test. Previously, we we did this in a few steps because of a problem where the Swan's serial port wasn't ready after uploading and so the test step would fail because it couldn't find the serial port. I was able to reduce this to one step by using the approach described here: platformio/platformio-core#3742 - Fix a Bash typo in the step that cleaned up the Notehub proxy route. - I reinstalled tunnelmole using npm on the Orange Pi, and it's working again. I really don't know what was wrong here. In order for run_tmole.sh to find the tmole executable, I had to add a couple lines to the start of the script so that npm packages are on PATH. - Upgrade the note-arduino version to latest.
Solution
Please add to your project a POST Extra Script with the following contents:
platformio.ini
extra_script.py
P.S: Do not forget to upgrade to the latest PlatformIO Core via
pio upgrade --dev
.Related issues:
Configuration
Operating system: Windows 10 x64
PlatformIO Version (
platformio --version
): 5.0.4a2Description of problem
Reference to topic where this popped up: https://community.platformio.org/t/unit-test-wio-terminal-could-not-open-port-while-testing/17180/
A user wants to do unit testing on a WIO terminal, which has a
SAMD21G18AATSAMD51P19A microcontroller onboard. This microcontroller implements a USB CDC serial connection. When a new firmware is uploaded, or the microcontroller is being reset, the USB connection is temporarily lost, then re-established.The problem is then when testing, PlatformIO does a Build -> Upload -> Test, where there is no delay between uploading and testing when using this specific microcontroller.
A problem was problem was observed that when using Linux, after the upload is done, the microcontroller re-enumerates twices on the USB bus, and at the moment the "Test" part of the unit tests wants to access
/dev/ttyACM0
, the Linux kernel or subsystems have not yet fully re-enumerated the device and it's currently owned by root at this point. Then accessing it fails with[Errno 13] could not open port /dev/ttyACM0: [Errno 13] Permission denied: '/dev/ttyACM0'
. A few milliseconds after it (exact timing log is here), Linux is done processing the device and now the user properly owns/dev/ttyACM0
and access to it would go through. That's at least how I read these logs.However, since PlatformIO does not have a configurable delay after uploading, or equivalently before testing,
pio test
will always run into this problem. So it would be nice to have such an option to enable these use cases where the to-be-tested MCU is the USB serial port and does some re-enumeration stuff after uploading.Steps to Reproduce
seeed_wio_terminal
pio test
Actual Results
Permission denied error on the serial device.
Expected Results
Testing goes through.
If problems with PlatformIO Build System:
The content of
platformio.ini
:Source file to reproduce issue:
Additional info
The text was updated successfully, but these errors were encountered: