Find the answer to your Linux question:
Results 1 to 6 of 6
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Serial port initialization

    I've been trying to send some data over a serial port on USB

    it is correctly detected as ttyUSB0.

    The device on the other end wakes up when receives the sequence $$$ without any CR or LF or anything else, so if I do

    # screen /dev/ttyUSB0 9600

    and then I type $$$ it works!

    but if I do

    # stty -F /dev/ttyUSB0 9600 -echo
    # echo -n "\$\$\$" > /dev/ttyUSB0

    it doesn't work! and it's driving me nuts!!

    what is funny though is that the stty and echo solution works if minicom or screen is reading the serial port, so there must be some initialization I'm missing

    doing stty -F /dev/ttyUSB0 before running screen and while screen is running reveals there are NO differences on condiguration or whatsoever

    Thanks a lot for your attention!

  2. #2
    Hello and welcome!

    Does it work if you do the initial screen command first:
    screen /dev/ttyUSB0 9600
    then, jump to another terminal and attempt the echo command:
    echo -n "\$\$\$" > /dev/ttyUSB0
    if it does work, maybe try the -sane arg to stty, sometimes that has helped me jiggle a serial port to life.

  3. #3
    It does work if screen is issued first (as I explained), so it means screen correctly initializes the port and the settings are the same, if I input stty -F /dev/ttyUSB0 before screen and while screen is running it shows the same info.

    sane did not help, but thanks anyway! any more suggestions?

  4. $spacer_open
  5. #4
    Quote Originally Posted by Imanol View Post
    It does work if screen is issued first (as I explained)
    I was suggesting that you only initialize the serial device with screen, but actually send the '$$$' to the device with the echo command. Did you try that?

    Another thing to try:

    before you run the screen command, print all the serial device settings:
    stty -F /dev/ttyUSB0 -a > /tmp/stty.before
    then run the screen initialization command.

    then print settings again:
    stty -F /dev/ttyUSB0 -a > /tmp/stty.after
    then compare stty.before and stty.after - any differences?

  6. #5
    Yes, that's what I meant, I did the screen and then separately, did the echo $$$ on another console, then it works.

  7. #6
    okay, cool. did u try the before/after settings stuff?

Posting Permissions

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