C/C++ Question to adapt unsigned int* getReceivedRawdata(); at BAR

candide

Member
Licensed User
i would like to add a few feature of RCSwitch on Arduino to B4R version and i have issue on this one : unsigned int* getReceivedRawdata();

on Arduino h file i have :
B4X:
 unsigned int* getReceivedRawdata();
In my wrapper, it is handled in this way :
B4X:
    ArrayUInt* B4RRCSwitch::getReceivedRawdata()
    {
        uint* raw = rcs->getReceivedRawdata(); 
        unsigned int len = 67; //raw.size(); 
        ArrayByte* arr = CreateStackMemoryObject(ArrayByte);
        arr->data = (StackMemory::buffer + StackMemory::cp);
        for (int i = 0;i < len; i++) {
            StackMemory::buffer[StackMemory::cp++] = raw[i] & 0xFF;        
            StackMemory::buffer[StackMemory::cp++] = (raw[i] >> 8) & 0xFF;  
        }
        arr->length=len;
        return arr;
in fact current version it is working, but i have to indicate in wrapper a fix value for length of array because i have only a pointer to this array and i don't know how to read length of this one.

can we have length of array when we have only a pointer to this one ?

after to add elements of this array to stack i found only a way to copy integers by byte and in 2 times, can we push an integer directly on the stack ?

thanks for your help
 

candide

Member
Licensed User
yes, length max is a constant define in h file Arduino: 67
content is corresponding at number of bits received and under 67, (2 uint by bit)

thanks for your hrlp
 
Top