Lawson,
You are correct.  I added the tcflush statement a while ago while trying to
debug another problem, didn't document the change, and forgot about it,
wasting several hours of my own time, not to mention however long it took
you to see the error.  Removing the statement fixes the code so it now sends
all 35 (or whatever) bytes.
Thank you for helping.
Tom
[EMAIL PROTECTED] wrote:

> On Tue, 24 Aug 1999, Tom Glass wrote:
>
> > I have written some code based on the serial HOW-TO and everything has
> > seemed to be working.  Now I find that when I try to send over 16 bytes
> > of data, only the first 16 are sent.  The code I use to send is
> >
> > int CSerial::SendData( const char *buffer, int size )
> > {
> >
> >  if( !m_bOpened || m_fd<0 ) return( 0 );
> >
> >  int BytesWritten = write(m_fd,buffer,size);
> >
> >  tcflush(m_fd, TCOFLUSH); //flush output buffer of bytes written but
> not
> > sent
> >
> >  return( BytesWritten );
> >
> > }
> >
> > and  if I supply a char* to 35 char and supply a size of 35, the return
> > value is 35, which should indicate it was all sent.  I have an
> > independent line monitor and it clearly shows that only 16 bytes
> > actually went out.
>
> Let me guess.  You are using a 16550a uart.
> >
> > This code was working before, and actually sending the 35 bytes.
> >
> I don't think so.  Not with that tcflush.
>
> > I'm guessing maybe this has something to do with the size of output
> > buffer, but I haven't knowingly changed that from it's default (and
> > don't know how to.)  Has anyone out there encountered this problem
> > before?
>
> It has to do with the size of the fifo in the uart.
>
> Look at what you are doing.  You tell it to write 35 bytes, so it puts
> them in its buffer and commences to send them to the uart.  The uart
> takes the first 16 into the fifo and stops sending interrupts for more
> until it can finish transmiting the first one out the line, so write
> returns.  It has accepted 35 bytes to write, so it returns 35.
> You call tcflush, so the serial driver empties the output buffer,
> discarding the 19 bytes it hasn't transmitted yet.
>
> What did you expect it to do?
> >
> > Any help will be greatly apprecitated.
> >
> > Tom
> >
> >
> Lawson
>           >< Microsoft free environment
>
> This mail client runs on Wine.  Your mileage may vary.
>
> ___________________________________________________________________
> Get the Internet just the way you want it.
> Free software, free e-mail, and free Internet access for a month!
> Try Juno Web: http://dl.www.juno.com/dynoget/tagj.


-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to [EMAIL PROTECTED]

Reply via email to