Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8630227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:01:03+00:00 2026-06-12T09:01:03+00:00

I was trying to log data from RS232 into a file with cat: cat

  • 0

I was trying to log data from RS232 into a file with cat:

cat /dev/ttyS0 > rs232.log

The result was that I had everything in my file except for the last line.

By printing to stdout, I was able to discover, that cat only writes the output if it gets a newline character (‘\n’). I discovered the same with:

dd bs=1 if=/dev/ttyS0 of=rs232.log

After reading How can I print text immediately without waiting for a newline in Perl? I was starting to think, if this could be a buffering problem of either the Linux-Kernel or the coreutils package.

According to TJD’s comment, I wrote my own program in C but still had the same problems:

#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* args[])
{
    char buffer;
    FILE* serial;
    serial = fopen(args[1],"r");
    while(1)
    {
        buffer = fgetc(serial);
        printf("%c",buffer);
    }
}

As of the results of my own C-Code this seems to be a Linux-Kernel related issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:01:04+00:00Added an answer on June 12, 2026 at 9:01 am

    You’re opening a TTY. When that TTY is in cooked (aka canonical) mode, it performs line processing (e.g. backspace removes the previous character from the buffer). You’ll want to put the TTY into raw mode in order to get every single byte when it arrives instead of waiting for the end of line.

    From the man page:

    Canonical and noncanonical mode

    The setting of the ICANON canon flag in c_lflag determines whether
    the terminal is operating in canonical mode (ICANON set) or
    noncanonical mode (ICANON unset). By default, ICANON set.

    In canonical mode:

    • Input is made available line by line. An input line is available
      when one
      of the line delimiters is typed (NL, EOL, EOL2; or EOF at the start of
      line). Except in the case of EOF, the line delimiter is included in the
      buffer returned by read(2).

    • Line editing is enabled (ERASE, KILL; and if the IEXTEN flag is
      set: WERASE,
      REPRINT, LNEXT). A read(2) returns at most one line of input; if the
      read(2) requested fewer bytes than are available in the current line of
      input, then only as many bytes as requested are read, and the remaining
      characters will be available for a future read(2).

    In noncanonical mode input is available immediately (without the
    user having to type a line-delimiter character), and line editing
    is disabled.

    The simplest thing to do is just to call cfmakeraw.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a log file that I'm trying to append data to the end
I am trying to read data from a .log file and process its contents.
I'm trying to load a default set of data from a csv file into
I am trying to extract some data from URLs in a LOG file and
I'm trying to log everything that happens in my application to two logs: one
In trying to solve the problem of getting data from Drupal into XML, I
I'm trying to filter certain data from an HTML file. For example, the HTML
I'm trying to put some geolocation data from Google Maps into a database. But
I'm trying to get some data from a PHP file which only gives a
I have a table I need to copy my data from (Log), into another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.