Exemple #1
0
int main( void )
{
  FILE* fp;

  // Initialize platform first
  if( platform_init() != PLATFORM_OK )
  {
    // This should never happen
    while( 1 );
  }

  // Initialize device manager
  dm_init();

  // Register the ROM filesystem
  dm_register( romfs_init() );

  // Register the MMC filesystem
  dm_register( mmcfs_init() );

  // Register the remote filesystem
  dm_register( remotefs_init() );

  // Autorun: if "autorun.lua" is found in the file system, run it first
  if( ( fp = fopen( FS_AUTORUN, "r" ) ) != NULL )
  {
    fclose( fp );
    char* lua_argv[] = { "lua", FS_AUTORUN, NULL };
    lua_main( 2, lua_argv );
  }
  
#ifdef ELUA_BOOT_RPC
  boot_rpc();
#else
  
  // Run the shell
  if( shell_init() == 0 )
  {
    printf( "Unable to initialize the eLua shell!\n" );
    // Start Lua directly
    char* lua_argv[] = { "lua", NULL };
    lua_main( 1, lua_argv );
  }
  else
    shell_start();
#endif // #ifdef ELUA_BOOT_RPC

#ifdef ELUA_SIMULATOR
  hostif_exit(0);
  return 0;
#else
  while( 1 );
#endif
}
Exemple #2
0
int main( void )
{
    FILE* fp;

    // Initialize platform first
    if( platform_init() != PLATFORM_OK )
    {
        // This should never happen
        while( 1 );
    }

    // Initialize device manager
    dm_init();

    // Register the ROM filesystem
    dm_register( romfs_init() );

#ifdef BUILD_XMODEM
    // Initialize XMODEM
    xmodem_init( xmodem_send, xmodem_recv );
#endif

#ifdef BUILD_TERM
    // Initialize terminal
    term_init( TERM_LINES, TERM_COLS, term_out, term_in, term_translate );
#endif

    // Autorun: if "autorun.lua" is found in the ROM file system, run it first
    if( ( fp = fopen( "/rom/autorun.lua", "r" ) ) != NULL )
    {
        fclose( fp );
        char* lua_argv[] = { "lua", "/rom/autorun.lua", NULL };
        lua_main( 2, lua_argv );
    }

    // Run the shell
    if( shell_init() == 0 )
    {
        printf( "Unable to initialize the eLua shell!\n" );
        // Start Lua directly
        char* lua_argv[] = { "lua", NULL };
        lua_main( 1, lua_argv );
    }
    else
        shell_start();

    while( 1 );
}
Exemple #3
0
void finsh_lua(struct para *parameters)
{
    rt_err_t (*rx_indicate)(rt_device_t dev, rt_size_t size);

    rt_sem_init(&(dev4lua.sem), "luasem", 0, 0);

    /* save old rx_indicate */
    rx_indicate = dev4lua.device->rx_indicate;

    /* set new rx_indicate */
    rt_device_set_rx_indicate(dev4lua.device, lua_rx_ind);

    {
	    int argc = parameters->argc;
	    char **argv = parameters->argv;
	    /*
	    rt_kprintf("argc =%d, argv[1] =%d\n", argc, argv[1]);
	    while(1);
	    */
	    /* run lua interpreter */
	    lua_main(argc, argv);
    }
    if (parameters->argc > 1)
	    rt_free(parameters->argv[1]);
    rt_free(parameters);

    /* recover old rx_indicate */
    rt_device_set_rx_indicate(dev4lua.device, rx_indicate);
}
void task_lua(os_event_t *e){
    char* lua_argv[] = { (char *)"lua", (char *)"-i", NULL };
    NODE_DBG("Task task_lua started.\n");
    switch(e->sig){
        case SIG_LUA:
            NODE_DBG("SIG_LUA received.\n");
            lua_main( 2, lua_argv );
            break;
        default:
            break;
    }
}
Exemple #5
0
static void b_lua(int argc, char **argv) {

    /* verificacao da memoria utilizada pelo lua */
    //lua -e "print(collectgarbage'count')"

    usb_print(NOVA_LINHA);
    if (lua_main(argc, argv) != EXIT_SUCCESS) {
        usb_print("\r\nerro: lua falhou gravemente");
    } else {
        usb_print("\r\nsucesso na execucao");
    }
}
Exemple #6
0
static void lua_main_thread(void *data)
{
  //lua setup  
  char *argv[] = {"lua", NULL};
  lua_main(1, argv);
  
//if error happened  
  lua_printf("lua exited,will reboot\r\n");
  free(lua_rx_data);
  lua_rx_data = NULL;
  mico_rtos_delete_thread(NULL);
  MicoSystemReboot();
}
Exemple #7
0
int start( lua_State *L ) {
    LUA::Set(L);
    LJUCEApplication *mc = Luna<LJUCEApplication>::check(L, 2);
    mainClass = mc;

    int rc = lua_main();
    
    #if ! JUCE_ANDROID
    lua_shutdown(L);
    #endif

    DBG("END of START\n");
    lua_pushnumber(L, rc);
    return 1;
}
Exemple #8
0
static void tlua(void *pvParameters){
    char *argumentos[] = {"lua", "-i"};

    bash_suicidio();

    vTaskDelay(1000/portTICK_RATE_MS);

    while(1){
        lua_main(2, argumentos);

        bash_cria();

        vTaskDelay(1000/portTICK_RATE_MS);
        tlua_suicidio();
    }
}
Exemple #9
0
void task_lua(os_event_t *e){
    char* lua_argv[] = { (char *)"lua", (char *)"-i", NULL };
    NODE_DBG("Task task_lua started.\n");
    switch(e->sig){
        case SIG_LUA:
            NODE_DBG("SIG_LUA received.\n");
            lua_main( 2, lua_argv );
            break;
        case SIG_UARTINPUT:
            lua_handle_input (false);
            break;
        case LUA_PROCESS_LINE_SIG:
            lua_handle_input (true);
            break;
        default:
            break;
    }
}
Exemple #10
0
// 'lua' handler
static void shell_lua( char* args )
{
  int nargs = 0;
  char* lua_argv[ SHELL_MAX_LUA_ARGS + 2 ];
  char *p, *prev, *temp;
  
  lua_argv[ 0 ] = "lua";
  // Process "args" if needed
  if( *args )
  {
    prev = args;
    p = strchr( args, ' ' );
    while( p )
    {
      if( nargs == SHELL_MAX_LUA_ARGS )
      {
        printf( "Too many arguments to 'lua' (maxim %d)\n", SHELL_MAX_LUA_ARGS );
        return;
      }
      *p = 0;
      lua_argv[ nargs + 1 ] = temp = prev;
      nargs ++;
      prev = p + 1;
      p = strchr( p + 1, ' ' );
      // If the argument is quoted, remove the quotes and transform the 'alternate chars' back to space
      if( *temp == '\'' || *temp == '"' )
      {
        temp ++;
        lua_argv[ nargs ] = temp;
        while( *temp )
        {
          if( *temp == SHELL_ALT_SPACE )
            *temp = ' ';
          temp ++;
        }
        *( temp - 1 ) = '\0';
      }
    }
  }
  lua_argv[ nargs + 1 ] = NULL;
  printf( "Press CTRL+Z to exit Lua\n" );
  lua_main( nargs + 1, lua_argv );  
  clearerr( stdin );
}
Exemple #11
0
int main( void )
{
    // Initialize platform first
    if( platform_init() != PLATFORM_OK )
    {
        // This should never happen
        while( 1 );
    }

    // Initialize the TLSF allocator
    // (if TLSF is not used, the next function does nothing)
    tlsf_elua_init();

    // Initialize device manager
    dm_init();

    // Register the ROM filesystem
    dm_register( romfs_init() );

    // Initialize XMODEM
    xmodem_init( xmodem_send, xmodem_recv );

    // Initialize terminal
    term_init( TERMINAL_LINES, TERMINAL_COLS, term_out, term_in, term_translate );

    printf( ".text ends at %p\n", etext );

    // Run the shell
    if( shell_init( XMODEM_MAX_FILE_SIZE ) == 0 )
    {
        printf( "Unable to initialize the eLua shell!\n" );
        // Start Lua directly
        char* lua_argv[] = { "lua", NULL };
        lua_main( 1, lua_argv );
    }
    else
        shell_start();

    while( 1 );
}
Exemple #12
0
int main( void )
{
  // Initialize platform first
  if( platform_init() != PLATFORM_OK )
  {
    // This should never happen
    while( 1 );
  }
    
  // Initialize device manager
  dm_init();
  
  // Register the ROM filesystem
  dm_register( romfs_init() );  
  
  // Initialize XMODEM
  xmodem_init( xmodem_send, xmodem_recv );    
  
  // Initialize terminal
  term_init( TERMINAL_LINES, TERMINAL_COLS, term_out, term_in, term_translate );
  
  printf( ".text ends at %p, first free RAM is at %p, last free ram is at %p\r\n", etext, platform_get_first_free_ram(), platform_get_last_free_ram() );
  
  // Run the shell
  if( shell_init( XMODEM_MAX_FILE_SIZE ) == 0 )
  {
    printf( "Unable to initialize the eLua shell!\n" );
    // Start Lua directly
    char* lua_argv[] = { "lua", NULL };
    lua_main( 1, lua_argv );
  }
  else
    shell_start();

  while( 1 );
}
Exemple #13
0
static int
lua_cmd(int argc, char **argv)
{
    lua_main(argc, argv);
    return 0;
}
// +================== New task interface ==================+
static void start_lua(task_param_t param, uint8 priority) {
  char* lua_argv[] = { (char *)"lua", (char *)"-i", NULL };
  NODE_DBG("Task task_lua started.\n");
  lua_main( 2, lua_argv );
}
Exemple #15
0
// 'lua' handler
static void shell_lua( int argc, char **argv )
{
  printf( "Press " SHELL_EOF_STRING " to exit Lua\n" );
  lua_main( argc, argv );
  clearerr( stdin );
}
Exemple #16
0
int main(int argc, char ** argv) {
	std::vector<std::string> arg_list;
	llvm::llvm_shutdown_obj Y;   // Call llvm_shutdown() on exit.
	std::string tmp;
	char **lua_argv;
	int lua_argc=0;
	int new_argc=0;
	int pos;
	int ret;

	// check for '--' and '-' options to cut-off parsing at that point.
	for(new_argc=0; new_argc < argc; new_argc++) {
		if(argv[new_argc][0] == '-') {
			if(argv[new_argc][1] == '\0') {
				break;
			} else if(argv[new_argc][1] == '-' && argv[new_argc][2] == '\0') {
				break;
			}
		}
	}

	llvm::cl::SetVersionPrinter(print_version);
	llvm::cl::ParseCommandLineOptions(new_argc, argv, 0, true);
	// Show version?
	if(ShowVersion) {
		print_version();
		return 0;
	}
	// recreate arg list.
	arg_list.push_back(argv[0]);
	for(std::vector<std::string>::iterator I=Executes.begin(); I != Executes.end(); I++) {
		pos = Executes.getPosition(I - Executes.begin());
		// keep same format -e'statement' or -e 'statement'
		if(argv[pos][0] == '-' && argv[pos][1] == 'e') {
			tmp = "-e";
			tmp.append(*I);
			arg_list.push_back(tmp);
		} else {
			arg_list.push_back("-e");
			arg_list.push_back(*I);
		}
	}
	for(std::vector<std::string>::iterator I=Libraries.begin(); I != Libraries.end(); I++) {
		pos = Libraries.getPosition(I - Libraries.begin());
		// keep same format -llibrary or -l library
		if(argv[pos][0] == '-' && argv[pos][1] == 'l') {
			tmp = "-l";
			tmp.append(*I);
			arg_list.push_back(tmp);
		} else {
			arg_list.push_back("-l");
			arg_list.push_back(*I);
		}
	}
	if(!MemLimit.empty()) {
		arg_list.push_back("-m");
		arg_list.push_back(MemLimit);
	}
	if(Interactive) {
		arg_list.push_back("-i");
	}
	if(!InputFile.empty()) {
		arg_list.push_back(InputFile);
	}
	// append options from cut-off point.
	for(;new_argc < argc; new_argc++) {
		arg_list.push_back(argv[new_argc]);
	}
	arg_list.insert(arg_list.end(),InputArgv.begin(), InputArgv.end());
	/* construct lua_argc, lua_argv. */
	new_argc = arg_list.size() + 1;
	lua_argv = (char **)calloc(new_argc, sizeof(char *));
	for(std::vector<std::string>::iterator I=arg_list.begin(); I != arg_list.end(); I++) {
		if(lua_argc == new_argc) break;
		lua_argv[lua_argc] = (char *)(*I).c_str();
		lua_argc++;
	}
	lua_argv[lua_argc] = NULL;

	// initialize the Lua to LLVM compiler.
	ret = llvm_compiler_main(1);
	// Run the main "interpreter loop" now.
	ret = lua_main(lua_argc, lua_argv);
	return ret;
}
Exemple #17
0
int main( void )
{
  int i;
  FILE* fp;

  // Initialize platform first
  if( platform_init() != PLATFORM_OK )
  {
    // This should never happen
    while( 1 );
  }

  // Initialize device manager
  dm_init();

  // Register the ROM filesystem
  romfs_init();

  // Register the MMC filesystem
  mmcfs_init();

  // Register the Semihosting filesystem
  semifs_init();

  // Register the remote filesystem
  remotefs_init();

  // Register NIFFS
  nffs_init();

  // Search for autorun files in the defined order and execute the 1st if found
  for( i = 0; i < sizeof( boot_order ) / sizeof( *boot_order ); i++ )
  {
    if( ( fp = fopen( boot_order[ i ], "r" ) ) != NULL )
    {
      fclose( fp );
      char* lua_argv[] = { (char *)"lua", (char *)boot_order[i], NULL };
      lua_main( 2, lua_argv );
      break; // autoruns only the first found
    }
  }

#ifdef ELUA_BOOT_RPC
  boot_rpc();
#else
  
  // Run the shell
  if( shell_init() == 0 )
  {
    // Start Lua directly
    char* lua_argv[] = { (char *)"lua", NULL };
    lua_main( 1, lua_argv );
  }
  else
    shell_start();
#endif // #ifdef ELUA_BOOT_RPC

#ifdef ELUA_SIMULATOR
  hostif_exit(0);
  return 0;
#else
  while( 1 );
#endif
}