Git Product home page Git Product logo

pisharp's People

Contributors

andycb avatar harpesichord avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pisharp's Issues

Running without sudo

This isn't an issue with PiSharp, but more of a general discussion about creating programs that don't require to be run as root to access the GPIO.

I added the pi user to the gpio group, usermod -a -G gpio pi. Logged out and back in again and I was then able to control the GPIO via the command line without the need for sudo. However when I ran a program like LibGPIODemo1 (again without sudo) it would throw exceptions complaining about not having permission to access a pins files.

After doing a bit of digging it seems that when a pin is exported it takes a little while for the directory structure for that pin to be set up under /sys/class/gpio and for the group permission on that directory to be set to gpio. If a non-sudo program tries to access one of the pins' files before the group is changed a permission exception will be raised.

A solution which worked in my case was to put a call to Thread.Sleep(200 at the end of the Export() method in LibGpio.cs. This will of course slow down the starting up of a program by 200ms for each call to Export().

Another more involved option might be to split the SetupChannel() method into two methods one to set export the pin the other to set the direction (this is actually done but the methods are private). This way an application using the library could do all the exports first, wait 200ms, then setup the direction of the pin. This would only require one delay rather than a delay after every export.

There are of course issues with using a delay like this. For instance if other programs were running and putting load on the CPU it might take longer than 200ms to set up the group. It might be possible to wait on the creation of the pins direction file and the setting of it's group to gpio before continuing.

I'm new to the Raspberry Pi so it could be I'm missing something obvious. If I am please let us know, or if there are other ways to solve the permission issue I'd be interested in hearing about them as well.

System.UnauthorizedAccessException" in mscorlib.dll

Hello!

OS: Windows 7

VB.NET always gives me an error message like written in title, when running test application and clicking the Button1:

`
Imports PiSharp.LibGpio
Imports PiSharp.LibGpio.Entities

Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    LibGpio.Gpio.SetupChannel(BroadcomPinNumber.Four, Direction.Output)
    LibGpio.Gpio.SetupChannel(BroadcomPinNumber.Eighteen, Direction.Input)
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    LibGpio.Gpio.OutputValue(BroadcomPinNumber.Four, True)
End Sub

End Class
`

It denies the access to the path written in the "LibGpio.cs" unter GetGpioPath() in line 470:

private string GetGpioPath() { if (Environment.OSVersion.Platform == PlatformID.Win32NT || Environment.OSVersion.Platform == PlatformID.Win32Windows || Environment.OSVersion.Platform == PlatformID.Win32S || Environment.OSVersion.Platform == PlatformID.WinCE) { // If we're running under Windows, use a Windows format test path return "C:\\RasPiGpioTest"; } }

Doesn't matter which path i'm filling in there (i tried different paths in my user directory or on another hard disk): the error rests. I tried to run the application as administrator and from the compiled .exe. It doesn't work.

Thank you!

File not found exception - /tmp/RasPiGpio/export

Running PiSharpGpio on Raspberry Pi and Mac results in a File Not Found exception in LibGpio.Export( BroadcomPinNumber pinNumber) when trying to open the file stream for the "export" file.

The attempt to open /tmp/RasPiGpio/export fails since the file doesn't exist (the directory does exist).

When opening a FileStream in FileMode.Truncate the file must already exist.

File not found excpeiton - /tmp/RasPiGpioTest/unexport

After put in a "fix" for not been able to find the "export" file, PiSharpGpio ran on my Mac. However, towards the end it threw a file not found exception in the LibGpio.UnExport( BraodcomPinNumber pinNumber) method.

The file /tmp/RasPiGpioTest/unexport does not exist and I can't seem to find where it should be created.

The file must exist when using FileMode.Open in the FileStream constructor.

Broadcom Pin 21/27 : Wrong number on Raspberry Pi B+

When using PiSharp, "Physical pin 13" is refered to "Broadcom Pin 21" which doesn't work on my Raspberry Pi B+

I don't know why but it seems that this Pin has two broadcom number, and in my case it was the number "27" so I had to edit your code and change line 45 of Entities/BroadcomPinNumbers.cs

I don't know much about it but maybe it's related to the model

Expose method to unexport a pin

Hi,
You might want to consider adding a method such as:

CloseChannel( BroadcomPinNumber pinNumber)

which will unexport a pin. Would be useful in cleanup code at the end of a program.

Cheers,
Paul

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.