How to talk to serial device via command line?

Under development: PCMCIA, wireless, etc.
Post Reply
Message
Author
Rickrandom
Posts: 195
Joined: Sat 21 Jan 2006, 05:35
Location: Bedfordshire, UK

How to talk to serial device via command line?

#1 Post by Rickrandom »

I am trying to communicate with an electronics device with a serial connection, and I have two different USB to serial adaptors. If I plug either in to my Puppy 511 machine, it shows up as ttyUSB0, so that seems promising.

I thought I would just use the command line, and I think I know how to set the baud rate (stty -F /dev/ttyUSB0 ispeed 2400) and how to log the response into a file (cat /dev/ttyUSB0 > /root/my-documents/log_file.txt) (by cribbing from http://www.futuretimes.webfreehosting.n ... meter.html).

However what I have no idea about is how to send anything out, e.g. the commands that I need to send to my electronics device, so it then replies with the data that I can log.

Any help gratefully received.

MagicZaurus
Posts: 107
Joined: Mon 05 Jan 2009, 17:35

Serial communication

#2 Post by MagicZaurus »

You can send something (ABC) to the device with the following command.

Code: Select all

echo "ABC" > /dev/ttyUSB0
More interactive would be the use of a terminal program like minicom.

Rickrandom
Posts: 195
Joined: Sat 21 Jan 2006, 05:35
Location: Bedfordshire, UK

#3 Post by Rickrandom »

Thanks.

I will look at Minicom, but thought I'd simply start with the command line.

MagicZaurus
Posts: 107
Joined: Mon 05 Jan 2009, 17:35

Serial communication

#4 Post by MagicZaurus »

You are right to try from the command line first to see if the communication with your device works fine. I only have the experience with some of these USB-To-Serial adapters under Windows and my experience is that not all of them work with all devices. The best way is still a good old COM port, but they are getting more difficult to find.

Post Reply