rpi-ws281x / rpi-ws281x-csharp

C# / .NET library wrapper for the rpi-ws281x library
BSD 2-Clause "Simplified" License
28 stars 17 forks source link

Licensing #1

Closed DanielSSilva closed 6 years ago

DanielSSilva commented 6 years ago

Hello there! Really glad that I've found this project :) As I've mentioned in the other issue (on the organization) I want to develop a module for PowerShell. I don't know if you are familiar with it, but PowerShell uses .Net Framework. This means that I can possibly use your module for the development. Although, there are 2 issues:

Urmel11 commented 6 years ago

Hi Daniel, nice to hear that you want to use this library to develop a PowerShell wrapper. Of course you are allowed to use it ;) I added the "BSD 2-Clause "Simplified" License" so that you are officially allowed to do so. This is the license of the original project (https://github.com/jgarff/rpi_ws281x).

The C# solution consists of 2 projects:

  1. rpi_ws281x This project is the actual wrapper which you should use. It targets already .NET Standard 2.0. is this sufficient for you? Can you use .NET Standard libraries?

  2. TestApp This is just a console application which uses the rpi_ws281x library to demonstrate its usage. The project targets .NET Framework 4.6.1. In my opinion this project does not need to be migrated.

Fabi

DanielSSilva commented 6 years ago

Hello again. Thank you for your answer. Yesterday I was messing around with your repo and was able to compile it for core. Although when I ran it i had an exception on the ws281x_t ctor (if i recall correctly). It was this exception https://stackoverflow.com/questions/15544818/non-blittable-error-on-a-blittable-type?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa Have you had any similar error? I don't know if dotnet and mono handle things differently

DanielSSilva commented 6 years ago

Oh and it would be a really good help if you/we could make this a nuget package in order to be easier to manage dependencies.

Urmel11 commented 6 years ago

Hi, sorry for my delayed respone. I did not got such exceptions. Do you use the version of the native library which is linked in this repo? Can you provide more exception details? Which runtime do you use for execution (mono or .Net Core)?

DanielSSilva commented 6 years ago

Hi, no problem. I'm using the native library yes. I'm using the .Net Core runtime. the exception full exception states the following

Unhandled Exception: System.ArgumentException: Object contains non-primitive or non-blittable data.
   at System.Runtime.InteropServices.GCHandle.InternalAlloc(Object value, GCHandleType type)
   at System.Runtime.InteropServices.GCHandle.Alloc(Object value, GCHandleType type)
   at rpi_ws281x.WS281x..ctor(Settings settings) in /home/daniel/Documents/RPI/rpi-ws281x-csharp/src/rpi_ws281x/WS281x.cs:line 28
   at TestAppCore.ColorWipe.Execute(AbortRequest request) in /home/daniel/Documents/RPI/rpi-ws281x-csharp/src/TestAppCore/ColorWipe.cs:line 27
   at TestAppCore.Program.Main(String[] args) in /home/daniel/Documents/RPI/rpi-ws281x-csharp/src/TestAppCore/Program.cs:line 38

This leads to the line where you pin the object into memory

_ws2811Handle = GCHandle.Alloc(_ws2811, GCHandleType.Pinned);

and it complains about this struct

[MarshalAs(UnmanagedType.ByValArray, SizeConst = PInvoke.RPI_PWM_CHANNELS)]
    public ws2811_channel_t[] channel;
Urmel11 commented 6 years ago

Since my current raspberry does not support armv7 instructions, I am not able to install .NET Core to reproduce the exception. I have just ordered a new model which will be delivered the next days. Because the licensing issue is done, I want to the track the exception in the new issue #2.