LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-13-2015, 09:25 AM   #1
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
termio buffer size


I'm trying to send serial data to a device I'm building through a USB to TTL chip. When I had a PL2303HX in the input, things worked fine. I've changed to an MCP2221 and now there seems to be some sort of termio buffer limit of 16 chars. Anything above that and I lose data. I thought that I had the program on the linux side setup to just send raw unbuffered data to the device, but clearly that's not happening. I've been working on this problem for three days straight and I'm stumped. Any help would truly be appreciated.

Here is the termio setup I'm using:

Code:
   memset(&tioPLL,0,sizeof(tioPLL));   /* start with clean tioPLL */
   tioPLL.c_cflag |= (CS8 | CLOCAL | CREAD);  /* 8N1 */
   tioPLL.c_cflag &= ~CSTOPB;  /* 1 stop bit */

   tioPLL.c_iflag &= ~(IXON | IXOFF | IXANY); /*disable software flow control*/
   tioPLL.c_iflag &= ~(INPCK | PARMRK);    /* no parity check*/
   tioPLL.c_iflag |= IGNPAR;     /* ignore parity errors*/

   tioPLL.c_oflag &= ~OPOST;     /* enable raw output */

   tioPLL.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);  /* enable raw input */
   tioPLL.c_cc[VTIME] = 1;

   cfsetospeed(&tioPLL,B57600);     // 9600 baud
   cfsetispeed(&tioPLL,B57600);     // 9600 baud
   tcsetattr(ttyPLL,TCSANOW,&tioPLL);
Here is an idea of how I'm passing data to the device:
Code:
      /* if there's input from STDIN */
      if(FD_ISSET(STDIN_FILENO, &readfs))
      {
         /* if new data is available on the console,
          * send it to the serial port */
         if(read(STDIN_FILENO,&kbdByte,1)>0)
         {
            if(kbdByte != 'q')
            {
               write(STDOUT_FILENO,&kbdByte,1);

               write(ttyPLL,&kbdByte,1);
               if(kbdByte == '\r')
                  write(ttyPLL, "\r\n", 2);
            }
         }
      }
I've just made sure that the PIC using the PL2303HX with the same version of the PIC program (and the same user program on linux) works fine for more than 16 chars of input.
 
Old 10-13-2015, 05:00 PM   #2
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Original Poster
Rep: Reputation: 141Reputation: 141
If it's any help, I've managed to confirm that it has nothing to do with /dev/ttyACM*. I did this by running "gtkterm -p /dev/ttyACM0 -s 57600" and making some trial commands. One thing I don't understand is that I had to use CTL-Enter on gtkterm to send a command through. If that gives anyone any ideas, please give me a hand.
 
Old 10-13-2015, 10:51 PM   #3
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Original Poster
Rep: Reputation: 141Reputation: 141
Apparently something has changed with directing the stdout of a program to a file in going from Squeeze to Jessie. After cutting the program back to just the IO and skipping the redirect, I was getting what I expected. When I redirected stdout on that, I had the same problem. Going back to the original program I see the same thing. Here's what I mean

This works properly:
./testit2 /dev/GPSDO 192.168.1.80

This breaks it, and is the normal way I run the program to get logging.
./testit2 /dev/GPSDO 192.168.1.80 > /home/bob/GPSDOe.logs/junk.log


I'm going to close this problem, though I don't really understand why this happened. I guess I'll have to open a non-blocking output to a log file instead of redirecting stdio.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Buffer Size lieuquocdat Linux - Software 1 11-15-2007 07:07 AM
buffer cache size gsr_kashyap Red Hat 6 09-18-2006 01:15 AM
calculating buffer size cynthia_thomas Programming 1 01-19-2006 10:49 PM
Data buffer size MarcReing Programming 7 10-21-2004 12:51 PM
CD write buffer size rch Linux - General 1 09-26-2003 05:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration