Re: Blocking read() from a USB->Serial adapter.



Charles Sullivan wrote:

I can understand the "attempts to read" for a non-blocking read -
returning fewer characters than specified if the characters
aren't immediately available to be read.

But I had the impression that a blocking read is supposed to block
forever or until it either reads the specified number of
characters or is interrupted.

"Blocking" or "nonblocking" matters only when no data at all is
available (e.g. if some disk has to position its head first, some
network connection is slow, or a pipe has no data).

Otherwise, both return all data the driver has available for you at
the moment (but only up to count bytes).

You're saying maybe it will and maybe it won't and that's to be
expected.

Yes. I was puzzled by that too when I first used unix read() and
write(), but you'll also have to accept it ;)

Not a problem. I am just puzzled why reading from the adapter
differs from reading from an actual serial port.

As already said here, it can be many reasons. Driver issues, timing
issues ...

Regards,


Björn

--
BOFH excuse #249:

Unfortunately we have run out of bits/bytes/whatever. Don't worry,
the next supply will be coming next week.

.



Relevant Pages

  • Re: Inserting flow-control chars with an mpsafetty kernel
    ... ^Q characters cannot be inserted inserted anymore. ... TTY code, but it is not so directly involved in the handling of the ... When I implemented the ptsdriver, I thought the idea behind TIOCPKT ...
    (freebsd-current)
  • Re: xPC Serial Communication Problems
    ... We're using the serial ports that come on the CPU ... The older serial block you're using uses the kernel resident driver ... Is the receiving machine executing at the 'same' 50 ms rate? ... does it wait until there are at least 15 characters in the ...
    (comp.soft-sys.matlab)
  • Re: Bytes
    ... architecture, for the following reasons: ... to make Windows NT driver support easier. ... convert between wide characters and multibyte characters and this is ... be simply mapped to multibyte characters in C, ...
    (comp.lang.forth)
  • Re: sendStringParameterAsUnicode: How to insert unicode data correctly
    ... means the driver will send Java strings as 16-bit characters. ... will use VARCHAR indexes, but not NVARCHAR. ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: Palatable Windows IO using Ada
    ... have seen for the Win32 API simply export the ReadFile and ReadFileEx ... characters exceeding some threshold. ... used to implement a bi-directional communications driver. ...
    (comp.lang.ada)