FEZ Raptor - Readpin()

I am trying to read pin from RLP. This is my first attempt so I am doing some basic mistake probably.
Compiling C code is without any error. RLP.H is included, G400 is defined.
My code looks like this:
RLP side:


 #define G400
 #include "RLP.h"

int Func(void** args)
{
  unsigned int* buffer = (unsigned int*)(args[0]);
  int arrayLength = *(int*)(args[1]);
  int thePin = *(int*)(args[2]);

  RLP->GPIO.EnableInputMode(thePin, RLP_GPIO_RESISTOR_PULLUP);           //Unknown error
  return RLP->GPIO.Readpin(thePin);
}

Managed side:


void ProgramStarted()
{
  byte[] elfBuffer = Resources.GetBytes(Resources.BinaryResources.G400RLP);
  var elfImage = new RuntimeLoadableProcedures.ElfImage(elfBuffer);
  var func = elfImage.FindFunction("Func");
  uint[] buffer = new uint[196000];
  var result = func.Invoke(buffer, buffer.Length, (int)G400.PB1);        //Hangs here
}

Thank you!

@ Adam - If you take out lines 10 and 11 from the native side (EnableInputMode and ReadPin), and just return thePin, do you get the expected value back in C#?

I have simplified code but Func never returns:


 #define G400
 #include "RLP.h"

int Func(void** args)
{
  RLP->GPIO.Readpin(99);           //Read LED
  return 1;
}

This code works:


 #define G400
 #include "RLP.h"

int Func(void** args)
{
  return 1;
}

Build.bat output:
rm ./.elf ./.map ./.lst
rm: cannot remove `./
.lst’: No such file or directory
make: [clean] Error 1 (ignored)
arm-none-eabi-gcc -c -g -mlittle-endian -mcpu=arm9 -Wall -I. -mapcs-frame -fno-builtin NativeCode.c -o NativeCode.o
arm-none-eabi-gcc -mcpu=arm9 -nostartfiles -Wl,–Map -Wl,./G400RLP.map -lc -lgcc -Wl,–omagic -T LinkerScript.lds -o ./G400RLP.elf NativeCode.o
rm ./*.o

@ Adam - Are you using the same managed code from your first post? I’m guessing you’re using the build files from https://www.ghielectronics.com/downloads/NETMF/RLP/RLP%20Examples.zip, have you modified any of them (except NativeCode.c)?

I have modified managed code this way:


void ProgramStarted()
{
       Thread.Sleep(10000);
       byte[] elfBuffer = Resources.GetBytes(Resources.BinaryResources.G400RLP);
       var elfImage = new RuntimeLoadableProcedures.ElfImage(elfBuffer);
       var func = elfImage.FindFunction("Func");
       var result = func.Invoke(1, 2, 3);
}

Yes I am using files from Example downloaded by link you mentioned. I have modified only NativeCode.c file. FEZ Config says that all is up to date. I am using Netmf version: 4.3. What I am doing wrong?

@ Adam - What SDK version are you using?

Solved:

-I have installed GHI Electronics NETMF SDK 2015 R1 Pre-Release 1.
-I have upgraded TinyBooter + TinyCLR on my FEZ Raptor.

Now it works. Thank you boys. :slight_smile: