Hi,
would like to use System.Device.Gpio in Powershell Core but it's not working.
I installed latest Windows IoT on a Raspberry Pi 3b, the DotNet prerelease and Powershell Core 6. To be able to install the System.Device.Gpio assembly I created a new project in DotNet. Then I used the documented command to install the DLL finally. In C# the commands are available.
In Powershell I used
PS C:> Add-Type -AssemblyName System.Device.Gpio
to load the System.Device.Gpio assembly successfull - at least Powershell does not return an error message. However the command
PS C:> [System.Device.Gpio] | Get-Member
does not work.
This might be a stupid question, but is the assembly expected to work in Powershell?
Kind regards
Windows IoT has not been thoroughly tested yet (Raspbian has been the mostly focued OS so far)
Currently Powershell is marked as experimental on both Windows and Raspbian (see README page):
https://github.com/powershell/powershell
Please provide specific commands you are using and write down the output powershell produces (i.e. what error you are getting or write down what did you expect to happen and what happened instead).
Also you might want to try with the new package we have produced today:
https://www.nuget.org/packages/System.Device.Gpio/0.1.0-prerelease.19171.3
(assuming you were using myget before you might have hit this issue: https://github.com/dotnet/iot/issues/336 if you have used nuget then likely you got really out of date package - hard to tell without seeing error message)
@joperezr PTAL
Hello,
Thank you for your help. Today I tried again with the latest version. I used the command
dotnet add package System.Device.Gpio -Version 0.1.0-prerelease-19171.3
to install the package.
I used
find . -Name System.Device.Gpio.dll
to locate the DLL on my device. Surprisingly, I found the file in a few directories, for example:
./.nuget/packages/system.device.gpio/0.1.0-prerelease.19171.3/runtimes/linux/lib/netstandard2.0/System.Device.Gpio.dll
./.nuget/packages/system.device.gpio/0.1.0-prerelease.19171.3/runtimes/win/lib/netstandard2.0/System.Device.Gpio.dll
but the DLL is not available in the Directory …/linux-arm/
Do I need a special version for the Raspberry Pi?
Kind regards
@Kraftmuschel linux is compatible with linux-arm. linux-arm specific binaries should be visible when you publish the runtime assets (i.e. dotnet publish -r linux-arm) - that should be at minimum .so file
Hi,
I found the file System.Device.Gpio.Native.So
/home/pi/.nuget/packages/system.device.gpio/0.1.0-prerelease.19171.3/runtimes/linux-arm/native
System.Device.Gpio.Native.so
but no DLL in this tree. So I loaded the DLL from the linux subfolder
PS /home/pi/.nuget/packages/system.device.gpio/0.1.0-prerelease.19171.3/runtimes/linux/lib/netstandard2.0> Add-Type -AssemblyName ./System.Device.Gpio.dll
This command does not return any error message. However, when I try to get the members, it fails:
PS /home/pi/.nuget/packages/system.device.gpio/0.1.0-prerelease.19171.3/runtimes/linux/lib/netstandard2.0> [System.Device.Gpio] | Get-Member Unable to find type [System.Device.Gpio]. At line:1 char:1
Kind regards
note that System.Device.Gpio is a namespace not a type (that's what the error is about). Try i.e. System.Device.Gpio.GpioController instead
Thank you for getting this straigth.
[System.Device.Gpio.GpioController] | Get-Member
Works instantly. I will continue my attempts to make use of it in Powershell this weekend.
Closing as it seems like the issue here is resolved. @Kraftmuschel please reopen if that is not the case.
Most helpful comment
Thank you for getting this straigth.
[System.Device.Gpio.GpioController] | Get-Member
Works instantly. I will continue my attempts to make use of it in Powershell this weekend.