Error: (25, ‘Inappropriate ioctl for device’)

It seems the combination “platformio device monitor” in background + stdout redirection is not supported on Linux (tested on Ubuntu 20.04).
The following code works well on windows:

$PLATFORMIO run --verbose --target upload --environment $conf > $uploadout 2> $uploaderr
stop_watch "launching" 3
#ISSUE at next line on Linux
$PLATFORMIO device monitor > $outfile& 2> $temp_folder/serial_err.txt
PID=$!
wait_eof_marker
kill -9 $PID 

On linux, I get “Error: (25, ‘Inappropriate ioctl for device’)”

Note that this run in a bash script, no IDE involved.
easy way to reproduce:

git clone git@github.com:sebastien-riou/Lightweight-Cryptography-Benchmarking.git
cd Lightweight-Cryptography-Benchmarking/src/lwc-benchmarking
git merge origin/nucleo_f411re
export PYTHON=python3;export PLATFORMIO=platformio
./build.sh --target f411re --submission "comet" --primary --aead --experiment "kat" --impl "ref" --overwrite

Seems like a clear bug, so it belongs in Issues · platformio/platformio-core · GitHub.

However, it could also be a miniterm.py issue, as that is the underlying serial program for PlatformIO.

As a workaround I can only recommend to run pio device monitor once. That will show you how miniterm.py is invoked (mostly… if you haven’t set any special monitor_flags or monitor_filters, but those can also be replicated). E.g., --- Miniterm on /dev/ttyACM0 9600,8,N,1 --- can be replicated with miniterm.py /dev/ttyACM0 9600.

1 Like

Thanks for the tip.
I did another kind of workaround. It’s kind of ugly but it allows to let pio manage the connection details. the workaround is to put the script that was suppose to read the output in the background and let pio run in foreground. see Lightweight-Cryptography-Benchmarking/build.sh at 265eb7cc3cca480f712b77302bb326636c7d1cb6 · sebastien-riou/Lightweight-Cryptography-Benchmarking · GitHub

I hope it can be fixed in the long run.

1 Like