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 ?

Kingofkech
  • 1,028
Patrick
  • 29
  • 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? – Anthony Geoghegan Sep 27 '17 at 09: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)? – Chris Davies Sep 27 '17 at 18:28

1 Answers1

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
Kingofkech
  • 1,028
Patrick
  • 29