Exemplo n.º 1
0
static boolean _get_drv_handler(void* userdata)
{
#ifdef LINKITSTORAGE_DEBUG
    Serial.print("vm_get_removable_driver()=");
    Serial.println(vm_get_removable_driver());
#endif
    *((int*)userdata) = vm_get_removable_driver();
    return true;
}
/*****************************************************************************
 * FUNCTION
 *  vm_main
 * DESCRIPTION
 *  This function is main function which is invoked in start up 
 *  ie entry function.
 * PARAMETERS
 *  none
 * RETURNS
 *	none
*****************************************************************************/
void vm_main(void) 
{
	VMINT drv;

	/* Define logging */ 
	#ifdef MRE_LOG_ON /* if loging is on */
		VMCHAR log_file[MRE_STR_SIZE_MAX] = {0};
	    
		/* finding drive for saving log information in "sample1.log" file name */
		if ((drv = vm_get_removable_driver()) < 0)	
		{	
			/* if no removable drive then get system drive*/ 
			drv = mre_get_drv(); 
		}
		sprintf(log_file, "%c:\\mre.log", drv);
		vm_log_init(log_file, VM_DEBUG_LEVEL);			
	#endif

	//Setting the workable drive here at once (May reduce checks in the future
	// by storing it to a global variable . May change as removable media exists)
	mre_set_drv();
    
	vm_log_debug ("vm_main function starts");

	/*Initialising the layer handle*/
    layer_hdl[0] = -1;

	/*Setting Global data for Graphics*/
    mre_set_global_data();
	
	/* Set lang */ 
    vm_mul_lang_set_lang (VM_LANG_ENG);
	
	/*
		Event Mapping:
		The reason why below we have two seperate events is cause once we attach an event handler, we can not 
		change it. I could mix them both into one event handler but we already tested the API's. Now its time
		to test nuklear and make the application, its views around this.
	*/
	///*
	// For Nuklear Testing:
	vm_reg_sysevt_callback (nk_mre_handle_sys_event); //looks at implementation event handler (does thesame thing)
	vm_reg_keyboard_callback (nk_mre_handle_key_event);	//Keyboard callback
	vm_reg_pen_callback (handle_penevt);	//Pen callback - not really needed
	//initiate_nuklear_gui(); //Disabling, the method: nk_mre_handle_sys_event will call it.
	//*/
	
	/*
	//For API Testing:
    vm_mul_lang_set_lang (VM_LANG_ENG);
	vm_reg_sysevt_callback (handle_sysevt);
 	vm_reg_keyboard_callback (handle_keyevt);
	vm_reg_pen_callback (handle_penevt);
	*/ 
}
Exemplo n.º 3
0
void app_log_file(char *fmt, ...)
{
    va_list args;
    VMINT drv, hdl;
    VMUINT written;
    VMINT ret;
    vm_time_t time = {0};
    char buf[LOG_BUF_SIZE] = {0};
    VMWCHAR wpath[FILE_PATH_SIZE] = {0};
    VMCHAR path[FILE_PATH_SIZE] = {0};
  
    buf[LOG_BUF_SIZE - 2] = '\r';
    buf[LOG_BUF_SIZE - 1] = '\n';

    va_start( args, fmt );
    vm_get_time(&time);
    vm_sprintf(buf+strlen(buf), "[%02d:%02d:%02d]", time.hour, time.min, time.sec);
    vm_vsprintf(buf+strlen(buf), fmt, args);
        
    drv = vm_get_removable_driver() > 0 ? vm_get_removeable_driver() : vm_get_system_driver();
    vm_sprintf(path, "%c:\\%s", drv, BT_NAME".log");

    vm_gb2312_to_ucs2(wpath, sizeof(wpath), path); 
    hdl = vm_file_open(wpath, MODE_APPEND, 0);
    if (hdl < 0)
        hdl = vm_file_open(wpath, MODE_CREATE_ALWAYS_WRITE, 0);
    else
    {
        if (!flag_delete_log)
        {
            vm_file_close(hdl);
            vm_file_delete(wpath);
            flag_delete_log = 1;
            hdl = vm_file_open(wpath, MODE_CREATE_ALWAYS_WRITE, 0);
        }
    }
    
    vm_file_write(hdl, buf, LOG_BUF_SIZE, &written);
    vm_file_close(hdl);

    va_end( args );						
}