This example uses C# for Raspberry Pi 3 and demonstrates remote debugging.
Fore note, all tests are performed using vs2019 (v16.4), RaspberryPi 3b v1.2 w/ Raspbian v9.
To launch your app using a clickable link on Desktop Linux.
We uploaded ours using WinSCP portable app to a new folder called TestApps
under /home/pi/Desktop
, and renamed the exe to test-pinet.exe
to keep things simple.
Next, we'll create the clicking file. Open a console window and navigate to our new folder. Now, type sudo nano TestPi.sh
and input the following content
#!/bin/bash
mono /home/pi/Desktop/TestApps/test-pinet.exe
Now give the TestPi.sh
file executable rights
sudo chmod +x TestPi.sh
Give it a try by double clicking your file via the Desktop.
The C# snip below can be found at the .NET Core IoT samples.
Requires:
- Red LED (1.8 - 2.2 Vf)
- 100K resistor
- GPIO pin 17 and GND.
int pin = 17;
GpioController controller = new GpioController();
controller.OpenPin(pin, PinMode.Output);
// Blink the LED
int lightTimeInMilliseconds = 1000;
int dimTimeInMilliseconds = 200;
while (true)
{
Console.WriteLine($"Light for {lightTimeInMilliseconds}ms");
controller.Write(pin, PinValue.High);
Thread.Sleep(lightTimeInMilliseconds);
Console.WriteLine($"Dim for {dimTimeInMilliseconds}ms");
controller.Write(pin, PinValue.Low);
Thread.Sleep(dimTimeInMilliseconds);
}
Raspberry Pi GPIO
- .NET Core IoT System.Device.Gpio - 2019-12-22
- Samples for .NET Core 2.1 and 3.0.
- Supports Raspberry Pi 2B, 3, and 4 models (ARMv7/v8).
- Raspberry Pi Zero or Arduino is not supported at this time (2019-12-27)
- Raspberry-GPIO-Manager - 2018-01-20
- RaspberryPi.Net - 2017-05-06
- http://raspberrypi-aa.github.io/session2/led_control.html
- https://www.hanselman.com/blog/InstallingTheNETCore2xSDKOnARaspberryPiAndBlinkingAnLEDWithSystemDeviceGpio.aspx
Remote Debugging:
- Connect VS to remote Linux
- VSMonoDebugger
- https://github.com/GordianDotNet/VSMonoDebugger
- Tested uploading EXE works
- Tested remote debugging and it fails out of the box.
- Mono Remote Debugger
- MonoDevelop Remote Debugger