comp.lang.ada
 help / color / mirror / Atom feed
From: "philip...@gmail.com" <philip.munts@gmail.com>
Subject: Read/write access to Unix character devices
Date: Sun, 20 Dec 2020 20:59:28 -0800 (PST)	[thread overview]
Message-ID: <6ece98b8-a82e-40e7-9a0e-37b40a175fb0n@googlegroups.com> (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

             reply	other threads:[~2020-12-21  4:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-21  4:59 philip...@gmail.com [this message]
2020-12-22  1:23 ` Read/write access to Unix character devices Randy Brukardt
2020-12-28 13:26 ` Björn Lundin
replies disabled

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