From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.fn3LatRFkm9/xzEj7F2/NQ.user.gioia.aioe.org!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: GNATCOLL-Mmap example Date: Wed, 29 Jan 2020 09:19:08 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <6a365294-65bb-4bd5-82d1-69d7b5aac04b@googlegroups.com> NNTP-Posting-Host: fn3LatRFkm9/xzEj7F2/NQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:57981 Date: 2020-01-29T09:19:08+01:00 List-Id: On 2020-01-28 21:17, Bob Goddard wrote: > On Tuesday, 28 January 2020 20:07:56 UTC, Dmitry A. Kazakov wrote: >> On 2020-01-28 19:53, Bob Goddard wrote: >>> On Tuesday, 28 January 2020 08:25:25 UTC, Dmitry A. Kazakov wrote: >>>> On 2020-01-25 22:52, Bob Goddard wrote: >>>> >>>>> I need to map the RPi's GPIO memory addresses so that I can do what I need to do. >>>> >>>> See files under: >>>> >>>> /sys/class/gpio >>>> >>>> You can use standard Ada I/O to read and set GPIO pins. E.g. >>>> >>>> /sys/class/gpio/gpio/XXX/value >>> >>> This was the way I started, but could not get it to read anything. It just blocks trying to read a single character. My c code works fine using the wiringPi libs. >> >> If I correctly remember you should rewind the file after each reading. > > It did not get that far. It blocks right at the start. What about this use GNAT.OS_Lib; FD : File_Descriptor; Buffer : aliased char; begin FD := Open_Read ("/sys/class/gpio/gpio/XXX/value", Binary); Lseek (FD, 0, Seek_Set); if 1 = Read (FD, Buffer'Address, 1) then if Buffer = '1' then ... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de