I’m working with some RLP code and I’m having problems with something that should be simple.
Below is my RLP code:
#include "RLP.h"
#include "LPC17xx.h"
int RlpTest(void **args) {
return 12;
}
int UpdateLinearInterpolation(void** args) {
int length = *(int*) (args[0]); //length of the array
int position = *(int*) (args[1]); //position of the interpolation between 0-256;
return length;
}
This is my managed code:
/// <summary>
/// Initializes the RLP procedures.
/// </summary>
static void InitializeRLP()
{
Debug.Print("->Initialize RLP\r\n");
var elfData = Resources.GetBytes(Resources.BinaryResources.BalanceBoard);
RLP.LoadELF(elfData);
RLP.InitializeBSSRegion(elfData);
RLP.Procedure test = RLP.GetProcedure(elfData, "RlpTest");
rlpUpdateLinearInterpolation = RLP.GetProcedure(elfData, "UpdateLinearInterpolation");
elfData = null; //we don't need this anymore.
int result = test.Invoke(); //run the test
int length = rlpUpdateLinearInterpolation.Invoke(16, 0); //, array,array,array});
Debug.Print("Test = " + result);
Debug.Print("Length = " + length);
}
When I run this, my output is as follows:
[quote]->Initialize RLP
Test = 12
Length = 536875525[/quote]
I don’t understand why my length variable isn’t correct. The “RlpTest” function is working correctly, and the second function will output the correct value, if I return a constant. So I must be doing something wrong with passing int the argument. Any suggestions about what I’m doing wrong? I would expect Length to equal 16. Thanks!