LOCAL int check_param_file(void)
{
#if 0
	fs_rsp_msg_type rsp_msg;

	if (camsensor_id == (camsensor_sensor_model_type)0)  // '0' means main camera.
		fs_nametest(CAMSENSOR_MAIN_PARAM_FILE, FS_TEST_FILE, NULL, &rsp_msg);
	else
		fs_nametest(CAMSENSOR_SUB_PARAM_FILE, FS_TEST_FILE, NULL, &rsp_msg);
#endif
	return TRUE;
}
Beispiel #2
0
uint32 camsensor_reg_file_read
(
    const char *filename,
    uint32 register_set_size,
    camsensor_parser_register_t *register_set
)
{
  //int i;
  fs_rsp_msg_type        rsp_msg;     
  fs_handle_type         fhandle = 0;

  unsigned char *param_file;
  unsigned char *temp_ptr;
  uint32 file_size;
  uint32 register_index = 0;

  //u_int16_t param_version;

  u_int16_t reg_address;
  u_int16_t reg_val;


  fs_nametest(filename, FS_TEST_FILE, NULL, &rsp_msg);

  if ( !rsp_msg.nametest.name_found )
  {
    MSG_FATAL(" File Not Found! ",0,0,0);
    return 0;
  } 
  else 
  {  //when SensorParamTable exists
    fs_open(filename, FS_OA_READONLY, NULL, NULL, &rsp_msg);

    MSG_FATAL(" File Open O.K ! ",0,0,0);

    if (rsp_msg.open.handle == FS_NULL_HANDLE)
    {
      MSG_ERROR ("File was not opened!!!",0,0,0);
      fs_close(fhandle,NULL,&rsp_msg);
      return 0;
    }
    fhandle = rsp_msg.open.handle;

    fs_file_size(filename, NULL, &rsp_msg);
    if (rsp_msg.file_size.status != FS_OKAY_S)
    {
      MSG_ERROR ("File size read fail!!!",0,0,0);
      rsp_msg.file_size.size = MAX_SENSORPARAM_SIZE;
      fs_close(fhandle,NULL,&rsp_msg);
      ERR_FATAL("ERR!",0,0,0);
      return 0;
    }
    file_size = rsp_msg.file_size.size;

    param_file = (unsigned char *)malloc(file_size+2);

    if(param_file==NULL)
    {
      fs_close(fhandle,NULL,&rsp_msg);
      ERR_FATAL("ERR!",0,0,0);
      return 0;
    }

    *(param_file+file_size)= NULL;
    *(param_file+file_size+1)=NULL;

    fs_read ( fhandle, (void *)param_file, file_size, NULL, &rsp_msg );
  
    if ( rsp_msg.read.status != FS_OKAY_S )
    {
      MSG_ERROR ("File read file header fail!!!",0,0,0);
      free((void *)param_file);
      fs_close(fhandle,NULL,&rsp_msg);
      return 0;
    }
    else
    {
      fs_close(fhandle, NULL, &rsp_msg);
      if ( rsp_msg.close.status != FS_OKAY_S )
      {
        MSG_ERROR ("File closing fail!!!",0,0,0);
      }

      temp_ptr = param_file;

      while (temp_ptr)
      {  
//20070622_c@m_이창원_chg [ 
//        if ((temp_ptr=find_next_address(temp_ptr, &reg_address)))
        if ((temp_ptr=find_next_address(temp_ptr, &reg_address)) != NULL)
        {
//20070622_c@m_이창원_chg [ 
//          if ((temp_ptr=find_next_val(temp_ptr, &reg_val)))
          if ((temp_ptr=find_next_val(temp_ptr, &reg_val)) != NULL)
          {
              register_set[register_index].address = reg_address;
              register_set[register_index].value = reg_val;
              register_index++;
              if (register_index >= register_set_size)
              {
                ERR_FATAL("ERR!",0,0,0);
                return 0;
              }
          }
        }
      }
    }

    free((void *)param_file);
  }

  return register_index;
}