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
}
@ 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#?
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?