Find the answer to your Linux question:
Results 1 to 3 of 3
Hi all, I have a device that communicates with the PC using the serial port. When communication is established I get a prompt from the device where I'm supposed to ...
  1. #1
    Just Joined!
    Join Date
    Mar 2010
    Posts
    2

    Talking [SOLVED] serial communication script, carriage return problem?

    Hi all,
    I have a device that communicates with the PC using the serial port. When communication is established I get a prompt from the device where I'm 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'm using bash and 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:
    deviceprompt> ANYCOMMAND\n\r
    Also, I'm using a script that defines
    stty -F /dev/ttyUSB0 19200 -cstopb cs8 -parenb -crtscts -ixon -ixoff onlcr
    all stty options are according with the device specifications and work fine, except onlcr... I was hopping that this option could help my problem with the carriage return but it didn't

    If I connect with the device using cutecom, there is no problem at all, I just select the option "CR line end" and every thing works fine.
    Any suggestions would be appreciated.
    Thanks

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Please show how you are trying to use the device. What programs (besides cutecom or minicom) are you using?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Mar 2010
    Posts
    2

    Thumbs up problem solved

    Meanwhile my problem is already solved.
    Thank you very much!
    echo -e solved it!

    In case this could be useful to someone I'm posting the script that I'm using with a VAISALA HMT330 humidity and temperature meter.

    #/bin/bash
    stty -F /dev/ttyUSB0 19200 -cstopb cs8 -parenb -crtscts -ixon -ixoff onlcr
    echo "Power-up the Vaisala HMT330 [ENTER]:"
    read
    echo -e "S\r\n" > /dev/ttyUSB0
    echo -e "DATE\r\n" > /dev/ttyUSB0
    echo "Enter new date [yyyy-mm-dd]:"
    read "data"
    echo -e "$data\r\n" > /dev/ttyUSB0
    echo -e "TIME\r\n" > /dev/ttyUSB0
    echo "Enter time [hh:mm:ss]:"
    read "time"
    echo -e "$time\r\n" > /dev/ttyUSB0
    echo "Enter file name [*.txt]:"
    read "nome"
    echo -e "R\r\n" > /dev/ttyUSB0
    while true
    do
    cat /dev/ttyUSB0 > $nome
    done

    I'm using the "Service Port Connection" and it is in RUN-mode.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...