Iot: Issue with GpioController.Write

Created on 22 May 2019  路  6Comments  路  Source: dotnet/iot

I have the following code:

GpioController gpioController = new GpioController(PinNumberingScheme.Logical, new RaspberryPi3Driver());
gpioController.OpenPin(0, PinMode.Output);
gpioController.OpenPin(1, PinMode.Output);

GpioCommand("write 0 1");

    private static string GpioCommand(string arguments)
    {
        Process proc = new Process
        {
            StartInfo = new ProcessStartInfo
            {
                FileName = "gpio",
                Arguments = arguments,
                UseShellExecute = false,
                RedirectStandardOutput = true,
                CreateNoWindow = true,
                WindowStyle = ProcessWindowStyle.Hidden
            }
        };

        proc.Start();
        string output = string.Empty;
        while (!proc.StandardOutput.EndOfStream)
        {
            output += proc.StandardOutput.ReadLine();
        }
        return output;
    }

This works fine and the relay on my RPi3B+ is switched off.

However if I try this instead, nothing happens:

GpioController gpioController = new GpioController(PinNumberingScheme.Logical, new RaspberryPi3Driver());
gpioController.OpenPin(0, PinMode.Output);
gpioController.OpenPin(1, PinMode.Output);

gpioController.Write(0, PinValue.High);

area-System.Device.Gpio bug needs more info

Most helpful comment

I consider this inactive and provided code appears to work. @joperezr I would close and can reopen if issue arises.

All 6 comments

May be a dumb question, but are you sure that you want to be using the Logical Numbering Scheme when calling pins 0 and 1? those are very special pins reserved for ID_SD and ID_SC so it is usually not a great idea to use them. Also, in your first example you are not changing the modes of pin 1, which I'm not sure if that has anything to do with what you are seeing.

@MarkCiliaVincenti While I didn't try your exact code, you can use the DeviceApiTest utility and it appears to work on my RPi3. Try the following and see if you get similar results

./DeviceApiTester  gpio-write-pin -d RPi3 -p 0 -v 0

I'd say go ahead and close this issue for no activity. The code in the command mentioned above is similar to what is reported and appears to work.

// Code within command.
using (GpioController controller = CreateGpioController())
{
    controller.OpenPin(Pin, PinMode.Output);
    controller.Write(Pin, Value);

    // Used to check state.
    Console.WriteLine("Press any key to exit.");
    Console.ReadKey();
}

If you please allow me more time I will test this soon. I didn't find the time just yet.

I consider this inactive and provided code appears to work. @joperezr I would close and can reopen if issue arises.

I had tried this again a couple of weeks ago and it still didn't work for me, @krwq.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Tragetaschen picture Tragetaschen  路  5Comments

ZhangGaoxing picture ZhangGaoxing  路  3Comments

pankaj-nikam picture pankaj-nikam  路  6Comments

Ellerbach picture Ellerbach  路  6Comments

Parsakarami picture Parsakarami  路  3Comments