Re: write() only sends 16 chars to serial port?



Grant Edwards wrote:
Ah, I think I see the problem. When you call write(), the
serial driver fills the tx FIFO with 16 bytes and starts it
transmitting. You then almost immediately call tcflush(),
which discards whatever is waiting to be sent in the serial
driver's tx buffer

Argh! Yup, that's it. Well spotted.

you probably want to call tcdrain()

tcdrain() waits until all output written to the object
referred to by fd has been transmitted.

Not sure I need it, but I'll probably add the tcdrain for safety. I'm
closing the port pretty soon after each access since there can be
multiple processes controlling my hardware. This doesn't seem to flush
the buffer when I do it, but I don't know if that's guaranteed
behaviour or not.

-Gus

.



Relevant Pages

  • Re: Thorny Serial Comms "UART: Overrun" error Windows CE 5.0
    ... before starting to patch the serial driver I would try to ... > errorFlags has the OVERRUN bit set. ... >> Do you know if it's the UART's FIFO buffer or the Serial Driver's ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Thorny Serial Comms "UART: Overrun" error Windows CE 5.0
    ... If it does not uses PDC or DMA, this could explain the overruns ... > I don't know if it is the serial driver or the UART. ... >> Do you know if it's the UART's FIFO buffer or the Serial Driver's ... and if you are not handshaking should solve this. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: send-receive using CSocket
    ... > desktop image & sending it from server to client " i convert it to DIB ... > strong and reliable send-receive code?? ... Is your image a constant size buffer? ... What kind of package are you transmitting across the buffer? ...
    (microsoft.public.vc.mfc)
  • Re: Performance/lockup issues with FreeBSD as a router
    ... > NICs will stop transmitting traffic. ... "no buffer space available" appears often when the buffer is used so ... because if your connections are good why the buffer should be used? ... I guess that probably your Nics, ...
    (freebsd-performance)
  • Re: send-receive using CSocket
    ... Be aware that if you send a buffer, that the receive does not receive the same information ... >> strong and reliable send-receive code?? ... Or are you also transmitting height, width, color ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)