Ejemplo n.º 1
0
// search for named .dsc file and load into network param desc memory
extern u8 files_load_desc(const char* name) {
  char path[64] = DSP_PATH;
  void * fp;
  int nparams = -1;
  // word buffer for 4-byte unpickling
  u8 nbuf[4];
  // buffer for binary blob of single descriptor
  u8 dbuf[PARAM_DESC_PICKLE_BYTES];
  // unpacked descriptor
  ParamDesc desc;
  int i;
  u8 ret = 0;

  app_pause();

  strcat(path, name);
  strip_ext(path);
  strcat(path, ".dsc");

  print_dbg("\r\n  opening .dsc file at path: ");
  print_dbg(path);

  fp = fl_fopen(path, "r");
  if(fp == NULL) {
    print_dbg("... error opening .dsc file.");
    print_dbg(path);
    ret = 1;
  } else {

    // get number of parameters
    fake_fread(nbuf, 4, fp);
    unpickle_32(nbuf, (u32*)&nparams); 

    /// loop over params
    if(nparams > 0) {
      net_clear_params();
      //    net->numParams = nparams;

      for(i=0; i<nparams; i++) {
	//  FIXME: a little gross,
	// to be interleaving network and file manipulation like this...
	///....
	// read into desc buffer
	fake_fread(dbuf, PARAM_DESC_PICKLE_BYTES, fp);
	// unpickle directly into network descriptor memory
	pdesc_unpickle( &desc, dbuf );
	// copy descriptor to network and increment count
	net_add_param(i, (const ParamDesc*)(&desc));     
 
      }
    } else {
      print_dbg("\r\n error: crazy parameter count from descriptor file.");
      ret = 1;
    }
  }
  fl_fclose(fp);
  app_resume();
  return ret;
}
Ejemplo n.º 2
0
// search for specified scene file and load it
// return 1 on success, 0 on failure
u8 files_load_scene_name(const char* name) {
  void* fp;
  u32 size = 0;
  u8 ret = 0;

  app_pause();

  fp = list_open_file_name(&sceneList, name, "r", &size);

  if( fp != NULL) {	  
    fake_fread((volatile u8*)sceneData, sizeof(sceneData_t), fp);
    fl_fclose(fp);
    scene_read_buf();

    // try and load dsp module indicated by scene descriptor
    //// DUDE! NO!!! scene does this. when did this happen!
    //// probably snuck in in some merge.
    //    ret = files_load_dsp_name(sceneData->desc.moduleName);
  } else {
    print_dbg("\r\n error: fp was null in files_load_scene_name \r\n");
    ret = 0;
  } 
  app_resume();
  return ret;
}
Ejemplo n.º 3
0
// search for specified dsp file and load it
u8 files_load_dsp_name(const char* name) {
  void* fp;
  u32 size = 0;
  u8 ret;
  //  ModuleVersion modVers;

  delay_ms(10);

  app_pause();

  fp = list_open_file_name(&dspList, name, "r", &size);

  if( fp != NULL) {	  
    print_dbg("\r\n found file, loading dsp: ");
    print_dbg(name);
    fake_fread(bfinLdrData, size, fp);

    fl_fclose(fp);
    bfinLdrSize = size;

    if(bfinLdrSize > 0) {
      print_dbg("\r\n loading bfin from buf");
      // reboot the dsp with new firmware in RAM
      bfin_load_buf();
      print_dbg("\r\n finished load");
      // write module name in global scene data

      /////////////////
      /// FIXME: filename and reported modulename should be decoupled
      /// bees should search for aleph-module-x.y.z.ldr
      /// but try aleph-module*.ldr on failure
      ////
      /// query name and version to the scene data
      //      scene_query_module();
      /// now set it to the actual filename because we are dumb
      scene_set_module_name(name);
      ///////////////////////////

      print_dbg("\r\n sceneData->moduleName : ");
      print_dbg(name);

      ret = 1;
    } else {
      print_dbg("\r\n bfin ldr size was <=0, aborting");
      ret = 0;
    }
  } else {
    print_dbg("\r\n error: fp was null in files_load_dsp_name \r\n");
    ret = 0;
  }
  app_resume();
  return ret;
}
Ejemplo n.º 4
0
// search for specified scene file and load it
// return 1 on success, 0 on failure
u8 files_load_scene_name(const char* name) {
  void* fp;
  u32 size = 0;
  u8 ret = 0;

    //// ahhhhh, i see.. 
    /// this is overwriting the descriptor in sceneData as well as the serialized blob.
    /// woud be fine, except it f***s up the comparison later.
    /// for now, let's do this ugly-ass workaround.

  char oldModuleName[MODULE_NAME_LEN];
  /// store extant module name
  strncpy(oldModuleName, sceneData->desc.moduleName, MODULE_NAME_LEN);

  app_pause();

  fp = list_open_file_name(&sceneList, name, "r", &size);

  if( fp != NULL) {	  
    print_dbg("\r\n reading binary into sceneData serialized data buffer...");
    fake_fread((volatile u8*)sceneData, sizeof(sceneData_t), fp);
    print_dbg(" done.");
    
    /// copy old name back to descriptor field... dumb dumb dumb.
    strncpy(sceneData->desc.moduleName, oldModuleName, MODULE_NAME_LEN);
    
    fl_fclose(fp);
    scene_read_buf();

    // try and load dsp module indicated by scene descriptor
    //// DUDE! NO!!! scene does this. when did this happen!
    //// probably snuck in in some merge.
    //    ret = files_load_dsp_name(sceneData->desc.moduleName);
  } else {
    print_dbg("\r\n error: fp was null in files_load_scene_name \r\n");
    ret = 0;
  } 

  app_resume();
  return ret;
}