JTrotta/RaspberrySharp

[request] is there any documentation available ?

Graveen opened this issue · 6 comments

Hi,
I'm testing all frameworks for mono related to Pi.
Looking for one supporting GPIO, I2C and callbacks.
Working with Pi3 and Pi 0W.

Except yours, i can't find a lot. Either they are not compatible with 0W (i think about Unosquare), or a simple wrapper on WiringPI (which would be my last choice).

Can you tell me:

  • are the pin numbers BCM or WPI based ? edit: BCM based
  • how can i declare a callback on input state change ? edit: with event StatusChanged on GpioConnection
  • what are the differences between GPIOConnection / GPIOConnectionDriver / FileConnection ? i'm not really aware how/when to use them

More generally, do you have any documentation (even in beta) i could browse ?
Thank you !

Hello @Graveen ,

  1. Pins are BCM only. You just need to read RP datasheets, and use GPIO numbers

  2. PinStatusChanged event.

  3. You can connect to linux OS using 3 different drivers. If you use Raspbian, just use default one. GPIOConnection is the main class to be used to connect to the GPIOs.

Will do a wiki, (sooner or later)

@JTrotta
Thank you !
I can give a hand as much as possible, very good job.

Is there any "getting started" docs? I just spent 3 days trying to get any blink program to work on buster. What I get now, is I can build a blink program on my windows desktop, but when I try to send it to the RPi, it is x86. I have two installs (one buster, with the works installed onto it), and the other stretch, that I am just trying to get re-installed.
So, for buster, hello world works, and even Blink prints out a string, then as soon as it tries to do anything with hardware, I get: RaspberrySharp.IO.Interop.MemoryMapFailedException was thrown.
For stretch, I was getting an error related to x86, but I now get the same error.
I have also been trying to build from the command-line on the RPI using mono, but I don't know how to include the RaspberrySharp library (I assume there must be an apt-get package for it). mcs -pkg:raspberrysharp Program.cs
I have also been trying to build locally using MonoDevelop as well, with no joy.
Is there a forum? I mean this seems like it has really great potential, but I feel like I just wasted 3 days trying to do something that is not achievable. I just want to use C#, and make some IO work. So far it seems nothing works for the BCM2835 processor.

Hi @ghcaveman
I'm not the maintainer but can tell you that the MemoryMapFailedException can be resolved by running it with sudo. sudo mono testapp.exe

I use Visual Studio Community 2017 for my Pi C# development and have no problems running the resulting exe's on the Pi. Ensure all the DLLs in the bin/debug directory that are alongside the exe file go with it. Set your build platform to "Any CPU" instead of "x86", though I'm not sure if that's required. I target .NET Framework 4.7.1 but am certain I've targeted earlier versions just fine, too. Output Type for me is always Console Application. And of course, run it with sudo mono name.exe on the Pi.

Have you checked the Blink example in this repository? https://github.com/JTrotta/RaspberrySharp/tree/master/Samples/Gpio/Blink

@ghcaveman ,
@tylerforsythe is right. First whenever you have to access memory map in Linux you always need sudo. To compile you need "Any CPU". Tryout examples they simply works.
For Wiki, I need some more time.

Thank you.