[SOLVED] script for serial comunnication: ok with cutecom but no answer from command line
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
script for serial comunnication: ok with cutecom but no answer from command line
Hi all,
I have been trying to communicate with a device (vaisala hmt330) by rs232. Every thing goes fine if I use cutecom. However, I am using the unit along with other instruments, and I wanted a single program that could read the data from the separate instruments and write it all to a single data file.
I tried to write a script to accomplish the job but I'm unable to send data to the device. I can read from it but I can't make it stop sending data in order to ear commands.
This script works fine for reading the data:
#/bin/bash
stty -F /dev/ttyUSB0 19200 -cstopb cs8 -parenb -crtscts -ixon -ixoff
while true
do
cat /dev/ttyUSB0
done
But I can't find the way to make the HMT330 listen to the serial port. If I do this:
echo ANYCOMMAND\r >/dev/ttyUSB0
the HMT330 just ignores the command and remains sending data.
From vaisala the info for user is:
Bauds 19200
Parity No
Data bits 8
Stop bits 1
Flow control None
Any suggestions?
Is there any way in which I can "see" what commands cutecom is sending?
Maybe I just missing some very simple issue but I can't figure out what it can be :-(
Thank you very much for your time. I will be very grateful for any help ;-)
Ergit
Humm... Yes! Perl should have been my solution but I don't know Perl and I was trying to avoid learn it, as this serial communication should be a simple thing to do. Ironically this idea was to save me time.
Good morning all,
actually I had a development today! If I connect serial cable, then run the script and only then power-up
the instrument, in this situation I get a prompt from the device.
HMT330 / 4.05
>
New problem: in this prompt I was supposed to type commands and hit ENTER.
But when I do this, the cursor just goes to the next line and the command is
not executed.
I assume this is a problem with recognition of the "end of line" or "carriage
return"... so I tried the usual shell non printing characters:
R\n
R\r
But still don't works :-(
Any suggestions would be appreciated.Thanks,
If you don't have any luck, there's a script here called mpi (functional but alpha), even without knowing perl you should be able to hack it about and make it do what you want
What commands are you using to send data to the device? Using the echo command with the -e option will enable the standard sequences. See echo man pages for more info.
echo -e "r\n" > /dev/ttyS0
I prefer using some higher level language for serial communications then a shell script.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.