c - How to split up an array to specific size -


i implement algorithm in telosb motes. need is, take file , split in smaller objects , splitting object smaller object called pages, described in figure below.

after doing that, page transmitted wirelessly other mote. 1 @ time called packet.

i have array of 2000 bytes want spilt shown in figure, requirement page packet shall less 110 bytes each or less.

nx_uint16_t file[1000];      int j, a; ( j = 0;j<1000;j++)             {                  int ra = (rand() +1) % 10;                                } = sizeof(file);  printf("\n array size: %d bytes", ); 

any appreciated.

if have 3 defined sizes object, page , packet, use 3 arrays of said sizes , copy elements serially.

since have 2000 bytes, dividing 110 byte chunk means there ceil(2000/110) packets. packet may contain headers or checksums or both (prefix , suffix data).

byte array[2000]; byte packet[110]; unsigned packet_count = 0;  for(int = packet_count * 110, j = 0; j < 110; ++j, ++i)     packet[j] = array[i] ; ++packet_count ; forward(packet); 

notice i starts packet_count * 110 whereas j moves 0 109.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -