comp.lang.ada
 help / color / mirror / Atom feed
* Read/write access to Unix character devices
@ 2020-12-21  4:59 philip...@gmail.com
  2020-12-22  1:23 ` Randy Brukardt
  2020-12-28 13:26 ` Björn Lundin
  0 siblings, 2 replies; 3+ messages in thread
From: philip...@gmail.com @ 2020-12-21  4:59 UTC (permalink / raw)


Lately I have been working with Unix (really Linux, FreeBSD, and OpenBSD) character devices (these happen to be USB raw HID devices, but the problem is more general than that).  The way these work is that each hardware device has a character device node file in /dev/, like /dev/hidraw1.  You open the file for both read and write access.  Then you can send a command to the device by writing a binary blob and get a response by subsequently reading a binary blob.  For what I am doing, it is important not to block on reads forever if there is not response forthcoming, so I need at least read timeouts.

So far, I have been binding the C library functions open(), close(), read(), write(), and poll() with pragma Import.  That works, but I have wondered if there is some way of accomplishing the same thing more portably.  The packages GNAT.Sockets and GNAT.Serial_Communicatons can be viewed as special case solutions, but I would like a general solution.

What I would really like is Ada.Sequential_IO with InOut_File and a timeout mechanism, perhaps like the select() wrapper in GNAT.Sockets.

So far I haven't found anything in the Ada. or GNAT. that supports InOut_File semantics (other than Direct_IO) let alone timeouts.  Does anybody have any suggestions?

Phil

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-28 13:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-21  4:59 Read/write access to Unix character devices philip...@gmail.com
2020-12-22  1:23 ` Randy Brukardt
2020-12-28 13:26 ` Björn Lundin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox