comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: GNATCOLL-Mmap example
Date: Wed, 29 Jan 2020 09:19:08 +0100
Date: 2020-01-29T09:19:08+01:00	[thread overview]
Message-ID: <r0rf5s$17fb$1@gioia.aioe.org> (raw)
In-Reply-To: 6a365294-65bb-4bd5-82d1-69d7b5aac04b@googlegroups.com

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


  reply	other threads:[~2020-01-29  8:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-25 21:52 GNATCOLL-Mmap example Bob Goddard
2020-01-28  2:10 ` Stephen Leake
2020-01-28  5:59   ` J-P. Rosen
2020-01-28  8:25 ` Dmitry A. Kazakov
2020-01-28 18:53   ` Bob Goddard
2020-01-28 20:07     ` Dmitry A. Kazakov
2020-01-28 20:17       ` Bob Goddard
2020-01-29  8:19         ` Dmitry A. Kazakov [this message]
2020-01-29 21:56           ` Bob Goddard
2020-01-30  2:45             ` Dennis Lee Bieber
2020-01-31 16:59     ` Björn Lundin
2020-01-28 19:11   ` Philip Munts
2020-01-28 20:15     ` Dmitry A. Kazakov
2020-01-28 20:18     ` Philip Munts
2020-01-28 22:06       ` Bob Goddard
replies disabled

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