Linux bash command script

Hi,

I am trying to send a command to my arduino (leonardo) and retrieve the output.
I set the parameters to
stty -F /dev/ttyACM0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts

If i echo a command, i can get the output via cat but this had to be in a different terminal :~

So, it don't work with this script
#!/bin/bash
cat /dev/ttyACM0 | head -n 1 (tried with & too)
echo "amr" > /dev/ttyACM0

also i can't get anything with tail -f (Arch Linux)
What could be wrong ?
Thanks

Ok gived up that way and used pyserial 8)

Now i can get it to work with :

#! /usr/bin/env python
import time
import serial
ser = serial.Serial('/dev/ttyACM0', 115200, timeout=3)
ser.write("amr\n".encode("utf-8"))
line = ser.readline().decode("utf-8")
print(line)
ser.close()
quit()

ser = serial.Serial('/dev/ttyACM0', 115200, timeout=3)

Open the serial port, resetting the Arduino.

ser.write("amr\n".encode("utf-8"))
line = ser.readline().decode("utf-8")
print(line)
ser.close()

Immediately send it data, while it's resetting. Read its response and close the serial port, resetting the Arduino again.

I hope the Arduino is not doing anything critical for you.

Hi nothing critical yet :slight_smile:
I use a leonardo, i don't think i had such 'resetting issue'.
Do you have another example with pyserial ?

Thanks

I use a leonardo, i don't think i had such 'resetting issue'.

Maybe not. I haven't tested that yet. I'd be surprised, though, to find out that it didn't reset.

I'am not sure either, i'am new to arduino
Seem like Leonardo don't auto-reset.
I have an instant respond with that script but i'd be glad to find other pyserial example.

Cheers