I do not understand what you need. RLP lets you pass float from C# down to C so where is the problem. If you have a structure then break it down into individual pieces that you pass individually or convert your structure into byte array.
something like
InstertVlaueIntoArray( MyStruct.SomeFloat, byte_array, index);
The structure resides in the C (RLP) realm. What I need to do is: fill some parts of the structure from C# -> C and read
some parts of the structur from C-> C#.
Sorry for my poor explanation I’m dutch and not really C literate.
Can you pls give little example? In the meantime I will try the InstertVlaueIntoArray function.
I just gave you an example in last post
InstertVlaueIntoArray( MyStruct.SomeFloat, byte_array, index);
I will try to explain again. What you need is code that reads or writes your data (float, int…etc.) into a byte array (serialize the data) your data can be anything, including a structure.
Thank you for the tutor etc, read it and it worked great!!! I now am getting pointers from RLP/C realm to the C# realm.
I am still having problem’s with te following:
I have a stream of INT’s in C# that I want to read in the RLP/C realm.
How to convert INT stream to byte[] array.
(I used the InsertValueArray with offsets but not sure if this the way because
of the float type in the function)
How to read/convert the byte[] array with INT stream back to seperate INT’s
I tried the byte shift trick but I have more than 4 bytes in the stream (let’s say 28 bytes) a stream of 7 INT’s.
Can you please help me again on this puzzle , forgive my noobishness or otherwise point me to some tutor.
What do you mean by “stream”. Do you mean an int array? If so then you do not need to convert that, just pass it as is. This is actually really fast as there is no need to convert anything. Look at the RLP docs and find “GeneralArray”.
I thought my gateway of transferirng data was byte array. I Already use the GeneralArray for passing a floatingpoint stream. The other (7) arguments only accept byte[] array types.
objective:
I want to pass three array’s to RLP as function arguments/parameters
example C#:
int Spa_Result = Set_Get_Spa_Structure.InvokeEx(FloatEnvArray,intDateTimeArray,FloatPostionData)
Result:
FloatPositionData is a pointer to an Array of floats inside RLP (output RLP -> C#) ** (THIS WORKS WITH ExtractValuefromarray function).
int [] intDateTimeArray = new [] {2011, 4, 40, 34, 50, -1, 5, 3}
intDateTimeArray as an Array of int’s (input C# -> RLP) **Wrong format
I tried the following:
for INT’s InsertValueIntoArray with correct offset I am somehow getting wrong/weird values from RLP.
[quote]Util.InsertValueIntoArray (SPA.year, intDateTimeArray, 0);
[/quote]
The Util we have is for float. You have to use Microsft.SPOT.Hardware.Utility one for ints.
[quote]unsigned char *intDateTimeArray = (unsigned char *)args[0];
spavalue.year = ( (intDateTimeArray[0] <<24 ) + (intDateTimeArray[1] << 16) + (intDateTimeArray[2] << + (intDateTimeArray[3] ));
[/quote]
It is little endian, so the other way around: intDateTimeArray[3] << 24 | intDateTimeArray[2] << 16…etc
But you can access it directly with no need for conversion:
unsigned int *intDateTimeArray = (unsigned int *)args[0];