1

I have a web application running on an Raspberry Pi Server (Debian).

The application send a simple echo over the commandline to a serialport.

I think the serialport is configured correctly.

The Echo:

echo "G0030af13403b1610097ee8" > /dev/ttyUSB0

When i send the command nothing happend.

But when i open a cat session in a other terminal everything works fine !

cat /dev/ttyUSB0

I think the serialport does not open with the echo alone ...

Is there a way to open the port and send the echo in one commandline ?

2
  • 2
    I suspect that /dev/ttyUSB0 is a regular file rather than a character special file (device node). Can you edit the question to include the output of stat /dev/ttyUSB0? Commented Sep 27, 2017 at 9:42
  • 1
    What do you mean by "nothing happened"? Did the echo command hang? Did it return immediately? Did it return after a short while? Was there an error message? What did you expect to happen (but didn't)? Commented Sep 27, 2017 at 18:28

1 Answer 1

1

Thanks to all i have found a solution ...

I have to run cat in background.

cat /dev/ttyusb0 &

then echo to it .

echo "G0030af13403b1610097ee8" > /dev/ttyUSB0

and kill the cat process.

I have solved it in a litte shell script:

cat /dev/ttyUSB0 &
bgPid=$!
echo "G0030af13403b1610097ee8" > /dev/ttyUSB0
kill $bgPid
1
  • 1
    Please use the correct button to answer your question.
    – Kingofkech
    Commented Sep 27, 2017 at 9:56

Not the answer you're looking for? Browse other questions tagged .