Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- long * byteA2LongA(byte * byte_slice, long * ret_array){
- /**
- * Convert the retrieved bytes into a set of 32 bit longs
- **/
- //varibale that stores the addressed long to be stored in sram
- long currentLong;
- int sizeOfB = sizeof byte_slice / sizeof(byte);
- int sizeOfL = sizeOfB / 4;
- if(sizeOfB % 4 != 0) ++sizeOfL;
- for(int i = 0; i < sizeOfB; i+=4){
- currentLong = 0;
- if(byte_slice[i]=='\0'){break;}
- if(i + 3 < sizeOfB)currentLong = (currentLong << 8) + byte_slice[i+3];
- if(i + 2 < sizeOfB) currentLong = (currentLong << 8) + byte_slice[i+2];
- if(i + 1 < sizeOfB) currentLong = (currentLong << 8) + byte_slice[i+1];
- currentLong = (currentLong << 8) + byte_slice[i+0];
- ret_array[i] = currentLong; //Serial.print("CurrentLong: ");
- }
- //pointer to the retrn array in the parent scope
- return ret_array;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement