コード例 #1
0
ファイル: shell.c プロジェクト: hankGo/freertos-plus
void test_command(int n, char *argv[]) {
    int handle;
    int error;

    fio_printf(1, "\r\n");
	
    // establish the targetFile first 
    //handle = host_action(SYS_SYSTEM, "mkdir -p output");
    //handle = host_action(SYS_SYSTEM, "touch output/syslog");
    
    // open the file
    handle = host_action(SYS_OPEN, "syslog", 8);
    if(handle == -1) {
        fio_printf(0, "Open file error!\n\r");
        return;
    }

    // write something to the file
    char *buffer = "Test host_write function which can write data to output/syslog\n";
    error = host_action(SYS_WRITE, handle, (void *)buffer, strlen(buffer));
    if(error != 0) {
        fio_printf(1, "Write file error! Remain %d bytes didn't write in the file.\n\r", error);
        host_action(SYS_CLOSE, handle);
        return;
    }

    // close the file	
    host_action(SYS_CLOSE, handle);
}
コード例 #2
0
ファイル: shell.c プロジェクト: chunikuo/freertos-plus
void test_command(int n, char *argv[]) {
    int handle;
    int error;

    fio_printf(1, "\r\n");

    // create directory first
    if (host_action(SYS_SYSTEM, "mkdir -p output")) {
	fio_printf(1, "failed to create output. exiting...\r\n");
	return;
    }

    handle = host_action(SYS_OPEN, "output/syslog", 8);
    if(handle == -1) {
        fio_printf(1, "Open file error!\n\r");
        return;
    }

    char *buffer = "Test host_write function which can write data to output/syslog\n";
    error = host_action(SYS_WRITE, handle, (void *)buffer, strlen(buffer));
    if(error != 0) {
        fio_printf(1, "Write file error! Remain %d bytes didn't write in the file.\n\r", error);
        host_action(SYS_CLOSE, handle);
        return;
    }

    host_action(SYS_CLOSE, handle);
}
コード例 #3
0
ファイル: shell.c プロジェクト: CobooGuo/freertos-basic
void host_command(int n, char *argv[]){
    int i, len = 0, rnt;
    char command[128] = {0};

    if(n>1){
        for(i = 1; i < n; i++) {
            memcpy(&command[len], argv[i], strlen(argv[i]));
            len += (strlen(argv[i]) + 1);
            command[len - 1] = ' ';
        }
        command[len - 1] = '\0';
        rnt=host_action(SYS_SYSTEM, command);
        fio_printf(1, "\r\nfinish with exit code %d.\r\n", rnt);
    } 
    else {
        fio_printf(2, "\r\nUsage: host 'command'\r\n");
    }
}
コード例 #4
0
ファイル: main.c プロジェクト: CarterTsai/freertos-plus
void system_logger(void *pvParameters)
{
    signed char buf[128];
    char output[512] = {0};
    char *tag = "\nName          State   Priority  Stack  Num\n*******************************************\n";
    int handle, error;
    const portTickType xDelay = 100000 / 100;

    handle = host_action(SYS_OPEN, "output/syslog", 4);
    if(handle == -1) {
        fio_printf(1, "Open file error!\n");
        return;
    }

    while(1) {
        memcpy(output, tag, strlen(tag));
        error = host_action(SYS_WRITE, handle, (void *)output, strlen(output));
        if(error != 0) {
            fio_printf(1, "Write file error! Remain %d bytes didn't write in the file.\n\r", error);
            host_action(SYS_CLOSE, handle);
            return;
        }
        vTaskList(buf);

        memcpy(output, (char *)(buf + 2), strlen((char *)buf) - 2);

        error = host_action(SYS_WRITE, handle, (void *)buf, strlen((char *)buf));
        if(error != 0) {
            fio_printf(1, "Write file error! Remain %d bytes didn't write in the file.\n\r", error);
            host_action(SYS_CLOSE, handle);
            return;
        }

        vTaskDelay(xDelay);
    }
    
    host_action(SYS_CLOSE, handle);
}
コード例 #5
0
ファイル: kernel.c プロジェクト: chianwei123/rtenv-plus
int __rtenv_start()
{
	int i;
#ifdef TRACE	
	logfile = host_action(SYS_OPEN, "logqemu", 4);
#endif
	init_rs232();

    /* Initialize memory pool */
    memory_pool_init(&memory_pool, MEM_LIMIT, memory_space);

	/* Initialize all files */
	for (i = 0; i < FILE_LIMIT; i++)
		files[i] = NULL;

	/* Initialize ready lists */
	for (i = 0; i <= PRIORITY_LIMIT; i++)
		list_init(&ready_list[i]);

    /* Initialise event monitor */
    event_monitor_init(&event_monitor, events, ready_list);

	/* Initialize fifos */
	for (i = 0; i <= PATHSERVER_FD; i++)
		file_mknod(i, -1, files, S_IFIFO, &memory_pool, &event_monitor);

    /* Register IRQ events, see INTR_LIMIT */
	for (i = -15; i < INTR_LIMIT - 15; i++)
	    event_monitor_register(&event_monitor, INTR_EVENT(i), intr_release, 0);

    /* Register TASK blocked event -> pthread_join, atomic etc. */
	for (i = 0; i < TASK_LIMIT; i++) {
	    int pid = i;
		event_monitor_register(&event_monitor, TASK_EVENT(i), task_release, &pid);
	}

    /* Register MUTEX events */
	for (i = 0; i < MUTEX_LIMIT; i++)
	    event_monitor_register(&event_monitor, MUTEX_EVENT(i), mutex_release, 0);

	event_monitor_register(&event_monitor, TIME_EVENT, time_release, &tick_count);
    /* Initialize all task threads */
	task_create(0, pathserver, NULL);
	task_create(0, signal_server, NULL);
	task_create(0, romdev_driver, NULL);
	task_create(0, romfs_server, NULL);
	task_create(0, mount_task, NULL);

	task_create(PRIORITY_LIMIT, kernel_thread, NULL);

	current_tcb = &tasks[current_task];

	__mutex.count = 0;
	__mutex.ishead = 1;

	SysTick_Config(configCPU_CLOCK_HZ / configTICK_RATE_HZ);

	task_start();	
	
	/*	never execute here	*/
	return 0;
}
コード例 #6
0
ファイル: os.c プロジェクト: colin8930/mini-arm-os
void write(char* buf, int len)
{
	host_action(SYS_WRITE, host_handle, (void *)buf, len);
}