backup.c
int parse_and_filter(char raw[PACKET_SIZE], struct point_3D *acc_data){
  int offset = 36; // skip everything before the :
  char *data_off = raw + offset;

  // setup lock iter ptr
  int iter = 0;
  char data[41] = "";
  while(iter <= 40 && *data_off != '\0' && *data_off != '\n'){
    if(*data_off != ' '){
      data[iter] = *data_off;
      ++iter;
    }
    ++data_off;
  }

  // we are only interested in the first 16 hex values
  for (iter = 0; iter < 16; iter += 4){
    switch(iter){
      case 4:
        filter_in = (float)(hex_to_decimal_4bit(&data[iter]));
        iirfilt_crcf_execute(filter_ax, filter_in, &filter_out);
        if (bias_flag){
          acc_data->x_comp = creal(filter_out) - acc_bias.x_comp;
        }
        else{
          acc_data->x_comp = creal(filter_out);
        }
        break;
      case 8:
        filter_in = (float)(hex_to_decimal_4bit(&data[iter]));
        iirfilt_crcf_execute(filter_ay, filter_in, &filter_out);
        if (bias_flag)
          acc_data->y_comp = creal(filter_out) - acc_bias.y_comp;
        else
          acc_data->y_comp = creal(filter_out);
        break;
      case 12:
        filter_in = (float)(hex_to_decimal_4bit(&data[iter]));
        iirfilt_crcf_execute(filter_az, filter_in, &filter_out);
        if (bias_flag)
          acc_data->z_comp = creal(filter_out) - acc_bias.z_comp;
        else
          acc_data->z_comp = creal(filter_out);
        break;
    }
  }

  return 0;
}
////////////////////////////////////////////////////////////////////
// Process 2: Raw Data Filtering and Storage (DSP)
////////////////////////////////////////////////////////////////////
Process 2: Raw Data Filtering and Storage (DSP)
Process 2 : Raw Data Filtering and Storage ( DSP )
int parse_and_filter(char raw[PACKET_SIZE], struct point_3D *acc_data){
  int offset = 36; 
  char *data_off = raw + offset;
  int iter = 0;
  char data[41] = "";
  while(iter <= 40 && *data_off != '\0' && *data_off != '\n'){
    if(*data_off != ' '){
      data[iter] = *data_off;
      ++iter;
    }
    ++data_off;
  }
  for (iter = 0; iter < 16; iter += 4){
    switch(iter){
      case 4:
        filter_in = (float)(hex_to_decimal_4bit(&data[iter]));
        iirfilt_crcf_execute(filter_ax, filter_in, &filter_out);
        if (bias_flag){
          acc_data->x_comp = creal(filter_out) - acc_bias.x_comp;
        }
        else{
          acc_data->x_comp = creal(filter_out);
        }
        break;
      case 8:
        filter_in = (float)(hex_to_decimal_4bit(&data[iter]));
        iirfilt_crcf_execute(filter_ay, filter_in, &filter_out);
        if (bias_flag)
          acc_data->y_comp = creal(filter_out) - acc_bias.y_comp;
        else
          acc_data->y_comp = creal(filter_out);
        break;
      case 12:
        filter_in = (float)(hex_to_decimal_4bit(&data[iter]));
        iirfilt_crcf_execute(filter_az, filter_in, &filter_out);
        if (bias_flag)
          acc_data->z_comp = creal(filter_out) - acc_bias.z_comp;
        else
          acc_data->z_comp = creal(filter_out);
        break;
    }
  }
  return 0;
}
int parse_and_filter ( char raw [ PACKET_SIZE ] , struct point_3D * acc_data ) { int offset = 36 ; char * data_off = raw + offset ; int iter = 0 ; char data [ 41 ] = " " ; while ( iter <= 40 && * data_off != ' \0 ' && * data_off != ' \n ' ) { if ( * data_off != ' ' ) { data [ iter ] = * data_off ; ++ iter ; } ++ data_off ; } for ( iter = 0 ; iter < 16 ; iter += 4 ) { switch ( iter ) { case 4 : filter_in = ( float ) ( hex_to_decimal_4bit ( & data [ iter ] ) ) ; iirfilt_crcf_execute ( filter_ax , filter_in , & filter_out ) ; if ( bias_flag ) { acc_data -> x_comp = creal ( filter_out ) - acc_bias . x_comp ; } else { acc_data -> x_comp = creal ( filter_out ) ; } break ; case 8 : filter_in = ( float ) ( hex_to_decimal_4bit ( & data [ iter ] ) ) ; iirfilt_crcf_execute ( filter_ay , filter_in , & filter_out ) ; if ( bias_flag ) acc_data -> y_comp = creal ( filter_out ) - acc_bias . y_comp ; else acc_data -> y_comp = creal ( filter_out ) ; break ; case 12 : filter_in = ( float ) ( hex_to_decimal_4bit ( & data [ iter ] ) ) ; iirfilt_crcf_execute ( filter_az , filter_in , & filter_out ) ; if ( bias_flag ) acc_data -> z_comp = creal ( filter_out ) - acc_bias . z_comp ; else acc_data -> z_comp = creal ( filter_out ) ; break ; } } return 0 ; }
Process 2: Raw Data Filtering and Storage (DSP)
Process 2 : Raw Data Filtering and Storage ( DSP )
// skip everything before the : // setup lock iter ptr // we are only interested in the first 16 hex values