InterOp NotSupportedException in Custom Firmware

Hi,

i compiled a custom firmware (NETMF 4.3.0) for the cerb40 (Version 1) with the help from NicolasG’s thread:
https://www.ghielectronics.com/community/forum/topic?id=10015&page=1

(my complete modified firmware as download: File-Upload.net - Datei nicht gefunden )

The firmware itself runs fine, but i’ve tried to add a native function for driving the WS2812 LEDs in the correct timing with the help from this article: Overview | Using NeoPixels with Netduino Plus 2 | Adafruit Learning System

The definition of my native function is found under: “\DeviceCode\GHI\Libraries\WS2812Native\Native\WS2812_WS2812_WS2812Native.h”



the managed c# part is found under "\DeviceCode\GHI\Libraries\WS2812Native\Managed\WS2812Native.cs"


```cs][MethodImpl(MethodImplOptions.InternalCall)

public extern static void Write(byte[] dataPtr, int count, UInt32 pin);

After flashing the firmware, i added the DLL (“DeviceCode\GHI\Libraries\WS2812Native\Managed\bin\Release\WS2812Native.dll”) to my NETMF project and tried to call my managed Write-Method, at this point i get a NotSupportedException. Here the Test-Projekt Code:

;
for (int i = 0; i < 10; i++)
{
    buff[i * 3 + 0] = 0xFF;
    buff[i * 3 + 1] = 0x00;
    buff[i * 3 + 2] = 0x00;
}

WS2812.WS2812Native.Write(buff, 10, (uint)GHI.OSHW.Hardware.FEZCerberus.Pin.PA10);

Anybody knows of this issue, or can help me? What do i wrong?

Thanks!
-Pascal

@ cyptus - Did you add the dotNetMF.proj file that VS generates for you to your TinyCLR.proj file for the Cerb firmware?

Hi John, thanks for your answer!

Yes i’ve added the following lines to the file “\Solutions\FEZCerberus_Community\TinyCLR\TinyCLR.proj” :

  <!--<ItemGroup>
    <InteropFeature Include="GHI_OSHW_Native" />
    <InteropFeature Include="GHI_OSHW_Hardware" />
    <InteropFeature Include="WS2812Native" />
  </ItemGroup>-->

  <Import Project="$(SPOCLIENT)\tools\targets\Microsoft.SPOT.System.Interop.Settings" />
  
  <ItemGroup>
    <DriverLibs Include="WS2812Native.$(LIB_EXT)" />
    <RequiredProjects Include="$(SPOCLIENT)\DeviceCode\GHI\libraries\WS2812Native\Native\dotNetMF.proj" />
  </ItemGroup>

@ cyptus - why not just use managed code to drive the WS’s?

I had problems with the timings, could not drive the LEDs correctly.

But i’ve found my fail… thanks to john, after posting my TinyCLR.proj file i’ve just seen that the lines for adding my project are commented out >:)

<!--<ItemGroup>
    <InteropFeature Include="GHI_OSHW_Native" />
    <InteropFeature Include="GHI_OSHW_Hardware" />
    <InteropFeature Include="WS2812Native" />
  </ItemGroup>-->

Now it works… Thanks anyway for the fast support!!

@ cyptus - how many are you trying to drive? I happy run 100’s of them with managed code…

But in saying that you should be about to run heaps with native code :slight_smile:

@ Justin -

140 of them ::slight_smile:
i’ve got a “ambilight” with an arduino - here a video of it: Arduino Ambilight - YouTube

but i want to drive the LEDs with the cerb40, to connect it directly over USB (not FTDI) to my PC, because of the speed (as you can see in the video, its a little bit to slow)

after a few tests with managed c# code to drive the LEDs, i could not get it 100% working, then i found the article on adafruit ( Overview | Using NeoPixels with Netduino Plus 2 | Adafruit Learning System ) - thats why i implemented the native function…

How do you drive the LEDs from managed code?

-Pascal

@ cyptus - 140…childs play for managed code ::slight_smile:

https://www.ghielectronics.com/community/codeshare/entry/649

Works a treat with full reels of 240

Mh i know this article, its exactly what i’ve tried a few times but i always got problems with my LEDs (with the arduino it works fine).

I will now try with my native function, but i will give the article above a last try after that… :think:
hope it works!

What issues do you have?
I use Cerb without issue with a 4m strip

@ Justin -
after a random time the LEDs only shows random colors, sometimes directly after starting, sometimes after a few seconds…

@ cyptus - Change the SPI clock edge from true to false and see if that sorts your issue…

@ Justin - That’s a cluttered desk that we can all be proud of! :smiley:

@ Gary - you should see todays desktop creativity :smiley:

1 Like

@ Justin - I thought it was just us. 8)