RLPLite byte Array 2 dimensions?


I have a jagged array :

and because of performance issue I would like to use RLPLite C procedure to do the following :

C# version :

messageToDisplay[0] = (byte)(char)2;
messageToDisplay[1] = (byte)(char)1;

                    for (int i = 0; i < 32; i++)
                        for (int j = k; j < (192 + k); j++)
                           messageToDisplay[cptr] = message[i][j];

here is my C version :

int RLP_MemSet(void* par0, int * par1, unsigned char * par2)
	int i=0;
	int j=0;
	// the passed arguments	 /////
	unsigned char ** message = par0;
	unsigned int cptr = par1[0];
	unsigned int k = par1[1];
	unsigned char * messageToDisplay = par2;

		  messageToDisplay[0] = (char)2;
                  messageToDisplay[1] = (char)1;
                    for (i = 0; i < 32; i++)
                      for (j = k; j < (192 + k); j++)
                           messageToDisplay[cptr] = message[i][j];

return 0;

but I don’t know how to pass a 2D array to my rlplite procedure. all the Invoke method are expecting sinle array !?!

trying my code gave me the obvious following error :

GHI.OSHW.Native.RLPLite.Procedure.Invoke(byte[], int[], byte[])’ has invalid arguments

Any solution possible here ?

You can only use normal arrays but you can work this in your code like this.

byte [] array2D = new byte[ARRAY_WIDTH*100];


You will basically handle it manually. 2D arrays are nothing but a long 1D array but the compiler does the code above internally.

@ Gus,

Thanks for the tip.

In my case I want : [quote]byte [32][636]array2D[/quote] , then the formula should be :

byte [] array2D = new byte[20352]; // 32 x 636 = 20352

array2D[y*636+x]=val; // ARRAY_WIDTH = 636

is that correct ?

Yes but use constants so your code is flexible for future.

ok many thanks Gus.

By the way if I was using RLP instead of RLPLite should I had the same constraint regarding 2D array ?

Even if you are not using RLP at all. Netmf dies bit support it.

Should be does not :wink:

lol yes, does not


Sorry for using this topic - is there a way to pass a double[] array to a RLPLite function or I must use float[]?

I tried to pass the address of the array as int element inside the in[] RLP func argument, but casting a pointer to int didn’t work, for example:

// arr is double[]
fixed (double* farr = arr)
uint p = (uint)farr; // CLR_E_WRONG_TYPE exception

//uint p = (uint)(&farr[0]); // same

// it’s interesting that this below always leads to “ABORT Data” on startup
//double* pfarr = farr;
//uint p = (uint)pfarr;


I’m out of ideas :slight_smile:
I’m using Hydra and still with SDK4.1 (because of the native touch with T35 display).

Double is not supported.