From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: * X-Spam-Status: No, score=1.0 required=3.0 tests=BAYES_40,FREEMAIL_FROM, PDS_FROM_2_EMAILS autolearn=no autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:ac8:1c92:: with SMTP id f18mr10774762qtl.234.1608526768916; Sun, 20 Dec 2020 20:59:28 -0800 (PST) X-Received: by 2002:a37:60f:: with SMTP id 15mr15392895qkg.211.1608526768400; Sun, 20 Dec 2020 20:59:28 -0800 (PST) Path: eternal-september.org!reader02.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 20 Dec 2020 20:59:28 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=199.204.203.151; posting-account=XGCYegoAAADY19DGgU_zTfTSbVlfUJ_a NNTP-Posting-Host: 199.204.203.151 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <6ece98b8-a82e-40e7-9a0e-37b40a175fb0n@googlegroups.com> Subject: Read/write access to Unix character devices From: "philip...@gmail.com" Injection-Date: Mon, 21 Dec 2020 04:59:28 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:60906 List-Id: Lately I have been working with Unix (really Linux, FreeBSD, and OpenBSD) c= haracter devices (these happen to be USB raw HID devices, but the problem i= s 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 th= e 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 timeo= uts. 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 pa= ckages 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_Fi= le semantics (other than Direct_IO) let alone timeouts. Does anybody have = any suggestions? Phil