System.Device.Gpio is a brand new open-source library for .Net Core, designed to enable IoT (Internet of Things) applications to interact with hardware like sensors, displays, and input devices through its GPIO pins or other I/O controls. This library is enhanced by a collection of device bindings maintained by the community.
As demonstrated by Microsoft’s .NET project manager Richard Lunder, this new library allows developers to control the general I/O (GPIO) pins of single-board computers through a set of APIs available for controlling external devices. This was previously difficult to achieve with .NET Core, even though .NET Core could run on Raspberry Pi. Supported platforms include Raspberry Pi, BeagleBoard, HummingBoard, and ODROID, but it does not support popular Arduino boards like UNO, Mega, Nano, etc.
This new library provided via NuGet packages can run on Linux and Windows 10 IoT Core, relying on the native drivers available for these platforms. For Linux distributions based on version 4.8 and higher, System.Device.Gpio uses libgpiod, replacing the GPIO sysfs interface, which provided limited and slower GPIO access for older Linux versions. For maximum performance, albeit at the cost of portability, System.Device.Gpio on Linux also supports accessing GPIO through /dev/mem, although these custom board drivers may be deprecated in the future.
System.Device.Gpio has a companion library called Iot.Device.Bindings, which makes it easier to use many existing “dummy” sensors, displays, and input devices by providing developers with higher-level APIs instead of relying on pin-level protocols. Currently, Iot.Device.Bindings includes bindings for dozens of devices such as A/D converters, accelerometers, gas sensors, light sensors, barometers, etc. It is important to note that Iot.Device.Bindings is a community effort and is not fully supported by Microsoft.
Lunder demonstrated running an LED control application on a Raspberry Pi 3 using Visual Studio Code on a Mac, which fully supports step debugging. Parts of System.Device.Gpio are written in C++, but they are gradually being ported to C#, making it easier for .NET developers to enhance and fix it.
System.Device.Gpio is still in the experimental phase, and Microsoft is seeking positive feedback on its APIs, which may change in future versions.
Original link: https://www.infoq.cn/article/1UXmCS1yFEYY51e86mGE