Find the answer to your Linux question:
Results 1 to 4 of 4
Greetings. I want to send something through the serial port, for example $ cat myfile.txt > /dev/ttyS0 or maybe $ dmesg | grep 00:00:0E > /dev/ttyS0 the point here is ...
  1. #1
    Just Joined!
    Join Date
    Jul 2010
    Posts
    2

    Streamout command to RS232

    Greetings.

    I want to send something through the serial port, for example

    $ cat myfile.txt > /dev/ttyS0

    or maybe

    $ dmesg | grep 00:00:0E > /dev/ttyS0

    the point here is send some numbers to a couple of 7 seg displays, so I will wire a RS232 chip on a protoboard, the logic after the RS232 is not an issue, but how can I assure the data is being sent right from my linux box to the RS232 chip, the one on the protoboard?

    Do I have to write a C program to read the strings and then send them to the serial port?

    For example if I wanted to send this to the displays:

    $ ifstat

    eth0 wlan0
    KB/s in KB/s out KB/s in KB/s out
    0.00 0.00 0.06 0.08
    0.00 0.00 1.56 1.60
    0.00 0.00 0.13 0.16
    0.00 0.00 1.63 1.52
    0.00 0.00 0.36 1.96

    suppose I want to send only the wlan info

    wlan0
    KB/s in KB/s out
    0.06 0.08
    1.56 1.60
    0.13 0.16
    1.63 1.52
    0.36 1.96

    but just the number array (I could use sed here)

    0.06 0.08
    1.56 1.60
    0.13 0.16
    1.63 1.52
    0.36 1.96

    So I guess the simplest way is (Supposing I can deal with the stream so it is filtered and only display the number array)

    $ ifstat > /dev/ttyS0

    But, how do I know if the RS232 will take them as the right characters??

    Thanks

  2. #2
    RDU
    RDU is offline
    Just Joined!
    Join Date
    Aug 2010
    Posts
    89
    I think to be a flexible as possible would be to have a circuit that do only displaying and put the logic on the computer (easier to update).


    But, how do I know if the RS232 will take them as the right characters??
    Thanks
    Maybe connect first a second computer with a NULL-MODEM (cross) cable and launch minicom (terminal emulator included in each distro (just install it with the package manager). Then you can look at what's on the line.

  3. #3
    Just Joined!
    Join Date
    Jul 2010
    Posts
    2
    That's a good idea... for testing...
    thanks, I'm still open to other suggestions

  4. #4
    Linux Newbie theNbomr's Avatar
    Join Date
    May 2007
    Location
    BC Canada
    Posts
    150
    Once the serial port is correctly configured in terms of bit rate, partiy, etc, the only issues that might get in the way would be console oriented behavior, such as line buffering (you want raw mode), hardware or software flow control (your application would dictate what is appropriate), and possible treatment of end-of-line handling (again, raw mode would fix this). The tools stty and setserial should handle all of these issues. Consult the respective man pages for the details. These will allow you to set up the serial port for shell-level use.

    As an aid to testing, you will probably find tools such as minicom (installed with most distros) or C-Kermit (my strong preference) useful for configuring the serial port, and allowing interactive transmission and receipt of data. If your application reads data that is normally displayed on-screen, then the data will be human-readbleASCII text. If you need to extract certain portions of the text to be sent to your device, then the usual filtering tools can almost certainly be used: bash, sed, awk, grep, Perl, cut, head, tail, etc. Again, consult the respective man pages.

    --- rod.
    Last edited by theNbomr; 08-07-2010 at 07:52 PM.
    Stuff happens. Then stays happened.

Posting Permissions

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