question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Opening an output pin with libpgiod driver changes the pin value

See original GitHub issue

Describe the bug

I want to read the value from an output pin, but by just opening an output pin it gets set to high. So reading it always returns high of course.

But using gpioget to read the pin value returns it as low, if that was what it was.

Steps to reproduce

Create GPIO controller Open pin (for one that is low) It is set to high, without an explicit write

var led1 = 19;

using var gpio = new GpioController(PinNumberingScheme.Logical, new LibGpiodDriver(2));

gpio.OpenPin(led1, PinMode.Output);
// gpio.Write(led1, PinValue.High);
gpio.ClosePin(led1);

Expected behavior

I expected to be able to open the pin without its state being affected, so I could read the state afterwards.

Actual behavior

Opening the pin changes state.

Versions used

Debian 10 (arm64) System.Device.Gpio package: 1.3.0 .NET Core: 3.1

Dockerfile

FROM mcr.microsoft.com/dotnet/sdk:3.1 as build

WORKDIR /src
COPY GpioApp.csproj ./
RUN dotnet restore GpioApp.csproj

COPY Program.cs ./
RUN dotnet build GpioApp.csproj -c Release -o /app

FROM mcr.microsoft.com/dotnet/runtime:3.1-alpine-arm64v8 as final

RUN apk update && apk add libgpiod-dev

WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "GpioApp.dll"]

docker run --privileged --rm dotnet-gpio:3.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:30 (22 by maintainers)

github_iconTop GitHub Comments

1reaction
krwqcommented, Jul 16, 2021

@raffaeler we now have a new nightly package you can try out. The nightly should work now (minus flaky tests which can be retried)

1reaction
krwqcommented, Jul 13, 2021

@raffaeler theoretically: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json (note dotnet6 not dotnet5)

has the latest but seems to me the last package is from June 4 which seems something is wrong with the publishing even though I’m seeing successful builds in the pipeline. I will ask our engineering team if they know what’s wrong

Read more comments on GitHub >

github_iconTop Results From Across the Web

LibGpiodDriver Class (System.Device.Gpio.Drivers)
This driver uses the Libgpiod library to get user-level access to the gpio ports ... The driver attempts to open the pin without...
Read more >
Get value of a gpio output using libgpiod in Linux
Setting the pin to '1' works. But then checking the current value of that same pin using gpioget, the value changes to '0'...
Read more >
Confusion with libgpiod and the gpiod user tools?
The gpioget returns the state of the output line - the -a option prevents the line being requested as an input, instead opening...
Read more >
Single Pin GPIO (General Purpose Input Output)
The timing of driving changes between the two states can be arbitary up to the resolution of the microcontroller that controls the GPIO....
Read more >
GPIO (Linux) | Toradex Developer Center
On i.MX based modules one cannot read back the value which has been set to an output unless one did set the SION...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found