Example #1
0
void serial_reader_f(void)
{
    int main_pid = 0;
    int bytes;
    msg_t m;
    border_packet_t *uart_buf;

    posix_open(uart0_handler_pid, 0);

    msg_receive(&m);
    main_pid = m.sender_pid;

    while(1) {
        posix_open(uart0_handler_pid, 0);
        bytes = readpacket(get_serial_in_buffer(0), BORDER_BUFFER_SIZE);

        if(bytes < 0) {
            switch(bytes) {
                case(-SIXLOWERROR_ARRAYFULL): {
                    printf("ERROR: Array was full\n");
                    break;
                }

                default: {
                    printf("ERROR: unknown\n");
                    break;
                }
            }

            continue;
        }

        uart_buf = (border_packet_t *)get_serial_in_buffer(0);

        if(uart_buf->empty == 0) {
            if(uart_buf->type == BORDER_PACKET_CONF_TYPE) {
                border_conf_header_t *conf_packet = (border_conf_header_t *)uart_buf;

                if(conf_packet->conftype == BORDER_CONF_SYN) {
                    m.content.ptr = (char *)conf_packet;
                    msg_send(&m, main_pid, 1);
                    continue;
                }
            }

            flowcontrol_deliver_from_uart(uart_buf, bytes);
        }
    }
}
Example #2
0
int main(void)
{
    shell_t shell;
    kernel_pid_t mac = basic_mac_init(mac_stack, BASIC_MAC_CONTROL_STACKSIZE,
                                      PRIORITY_MAIN - 1, CREATE_STACKTEST,
                                      "basic_mac_default", NETDEV_DEFAULT);
    sixlowpan = sixlowpan_init(mac, sixlowpan_stack, SIXLOWPAN_CONTROL_STACKSIZE,
                               PRIORITY_MAIN - 1, CREATE_STACKTEST,
                               "basic_mac_default");

    genrand_init(hwtimer_now());
    data_value = (uint8_t)(genrand_uint32() % 256);

    netapi_set_option(sixlowpan, NETAPI_CONF_SRC_LEN, &src_len, sizeof(size_t));
    netapi_get_option(sixlowpan, NETAPI_CONF_ADDRESS, &src, sizeof(uint16_t));

    (void) posix_open(uart0_handler_pid, 0);

    (void) puts("Welcome to RIOT!");

    shell_init(&shell, shell_command, UART0_BUFSIZE, uart0_readc, uart0_putc);

    shell_run(&shell);
    return 0;
}
Example #3
0
int main(void)
{
    puts("RIOT 6LoWPAN example v"APP_VERSION);

    sixlowpan_lowpan_init_interface(IF_ID);

    /* start thread for monitor mode */
    kernel_pid_t monitor_pid = thread_create(monitor_stack_buffer,
                                             sizeof(monitor_stack_buffer),
                                             PRIORITY_MAIN - 2,
                                             CREATE_STACKTEST,
                                             sixlowapp_monitor, NULL,
                                             "monitor");

    ipv6_register_packet_handler(monitor_pid);

    /* Start the UDP server thread */
    sixlowapp_udp_server_pid = thread_create(udp_server_stack_buffer,
                                             sizeof(udp_server_stack_buffer),
                                             PRIORITY_MAIN, CREATE_STACKTEST,
                                             sixlowapp_udp_server_loop, NULL,
                                             "UDP receiver");

    /* Open the UART0 for the shell */
    posix_open(uart0_handler_pid, 0);
    /* initialize the shell */
    shell_t shell;
    shell_init(&shell, shell_commands, UART0_BUFSIZE, uart0_readc, uart0_putc);
    /* start the shell loop */
    shell_run(&shell);

    return 0;
}
Example #4
0
int main(void)
{
    puts("IETF90 - BnB - CCN-RPL router");

    /*
    if (msg_init_queue(msg_buffer_shell, SHELL_MSG_BUFFER_SIZE) != 0) {
        DEBUG("msg init queue failed...abording\n");
        return -1;
    }
    */

    riot_ccn_relay_start();
    
    id = 2;

    /* fill neighbor cache */
    fill_nc();

    riot_ccn_appserver(1, NULL);
    rpl_ex_init('n');
    udp_server(1, NULL);

    posix_open(uart0_handler_pid, 0);
    net_if_set_src_address_mode(0, NET_IF_TRANS_ADDR_M_SHORT);
    shell_init(&shell, sc, UART0_BUFSIZE, uart0_readc, uart0_putc);
    shell_run(&shell);

    return 0;
}
Example #5
0
int link_open(link_transport_mdriver_t * driver, const char * path, int flags, ...){
	link_op_t op;
	link_reply_t reply;
	link_mode_t mode;
	int err;
	va_list ap;

	if ( flags & LINK_O_CREAT ){
		va_start(ap, flags);
		mode = va_arg(ap, link_mode_t);
		va_end(ap);
	} else {
		mode = 0;
	}

	if( driver == 0 ){
		return posix_open(path, convert_flags(flags) | POSIX_OPEN_FLAGS, mode);
	}

	link_debug(LINK_DEBUG_MESSAGE, "open %s 0%o 0x%X using %p", path, mode, flags, driver->dev.handle);


	op.open.cmd = LINK_CMD_OPEN;
	op.open.path_size = strlen(path) + 1;
	op.open.flags = flags;
	op.open.mode = mode;

	link_debug(LINK_DEBUG_MESSAGE, "Write open op (%p)", driver->dev.handle);
	err = link_transport_masterwrite(driver, &op, sizeof(link_open_t));
	if ( err < 0 ){
		link_error("failed to write open op with handle %p", driver->dev.handle);
		return link_handle_err(driver, err);
	}

	//Send the path on the bulk out endpoint
	link_debug(LINK_DEBUG_MESSAGE, "Write open path (%d bytes)", op.open.path_size);
	err = link_transport_masterwrite(driver, path, op.open.path_size);
	if ( err < 0 ){
		link_error("failed to write path");
		return link_handle_err(driver, err);
	}



	//read the reply to see if the file opened correctly
	err = link_transport_masterread(driver, &reply, sizeof(reply));
	if ( err < 0 ){
		link_error("failed to read the reply");
		return link_handle_err(driver, err);
	}

	if ( reply.err < 0 ){
		link_errno = reply.err_number;
		link_debug(LINK_DEBUG_WARNING, "Failed to ioctl file (%d)", link_errno);
	} else {
		link_debug(LINK_DEBUG_MESSAGE, "Opened fildes: %d", reply.err);
	}
	return reply.err;
}
Example #6
0
int fd_init(void)
{
    memset(fd_table, 0, sizeof(fd_t) * FD_MAX);

    posix_open(uart0_handler_pid, 0);
    fd_t fd = {
        .__active = 1,
        .fd = uart0_handler_pid,
        .read = (ssize_t ( *)(int, void *, size_t))posix_read,
        .write = (ssize_t ( *)(int, const void *, size_t))posix_write,
        .close = posix_close
    };
    memcpy(&fd_table[STDIN_FILENO], &fd, sizeof(fd_t));
    memcpy(&fd_table[STDOUT_FILENO], &fd, sizeof(fd_t));
    memcpy(&fd_table[STDERR_FILENO], &fd, sizeof(fd_t));
    return FD_MAX;
}

static int fd_get_next_free(void)
{
    for (int i = 0; i < FD_MAX; i++) {
        fd_t *cur = &fd_table[i];

        if (!cur->__active) {
            return i;
        }
    }

    return -1;
}

int fd_new(int internal_fd, ssize_t (*internal_read)(int, void *, size_t),
           ssize_t (*internal_write)(int, const void *, size_t),
           int (*internal_close)(int))
{
    int fd = fd_get_next_free();

    if (fd >= 0) {
        fd_t *fd_s = fd_get(fd);
        fd_s->__active = 1;
        fd_s->fd = internal_fd;
        fd_s->read = internal_read;
        fd_s->write = internal_write;
        fd_s->close = internal_close;
    }
    else {
        errno = ENFILE;
        return -1;
    }

    return fd;
}
Example #7
0
int main(void)
{
    board_uart0_init();
    posix_open(uart0_handler_pid, 0);

    shell_t shell;
    shell_init(&shell, shell_commands, SHELL_BUFSIZE, shell_readc, shell_putchar);

    puts("`struct tm` utility shell.");
    shell_run(&shell);

    return 0;
}
Example #8
0
int main(void) {
    shell_t shell;

    (void) posix_open(uart0_handler_pid, 0);

    puts("Welcome to RIOT!");

    shell_init(&shell, shell_commands, UART0_BUFSIZE, shell_readc, shell_putchar);

    shell_run(&shell);

    return 0;
}
Example #9
0
int main(void)
{
    shell_t shell;
    posix_open(uart0_handler_pid, 0);
    init_transceiver();

    puts("Welcome to RIOT!");

    shell_init(&shell, NULL, UART0_BUFSIZE, shell_readc, shell_putchar);
    shell_run(&shell);

    return 0;
}
Example #10
0
int main(void) {
    printf("6LoWPAN Transport Layers\n");
    posix_open(uart0_handler_pid, 0);

    init_tl(NULL);

    shell_t shell;
    shell_init(&shell, shell_commands, uart0_readc, uart0_putc);

    shell_run(&shell);

    return 0;
}
Example #11
0
int main(void)
{
    puts("SAFEST demo router v"SAFEST_VERSION);
    puts("station: "STATION);

    /* start shell */
    posix_open(uart0_handler_pid, 0);

    shell_t shell;
    shell_init(&shell, shell_commands, uart0_readc, uart0_putc);

    shell_run(&shell);
    return 0;
}
Example #12
0
int main(void) {
    printf("test_shell.\n");

    board_uart0_init();

    posix_open(uart0_handler_pid, 0);

    shell_t shell;
    shell_init(&shell, shell_commands, shell_readc, shell_putchar);

    shell_run(&shell);

    return 0;
}
Example #13
0
int main(void)
{
    shell_t shell;

    puts("RIOT network stack example application");

    /* start shell */
    puts("All up, running the shell now");
    posix_open(uart0_handler_pid, 0);
    shell_init(&shell, shell_commands, UART0_BUFSIZE, uart0_readc, uart0_putc);
    shell_run(&shell);

    /* should be never reached */
    return 0;
}
Example #14
0
/******************************************************************************
 Open a new GIF file for read, given by its name.
 Returns dynamically allocated GifFileType pointer which serves as the GIF
 info record.
******************************************************************************/
GifFileType *
DGifOpenFileName(const char *FileName, int *Error)
{
    int FileHandle;
    GifFileType *GifFile;

    if ((FileHandle = posix_open(FileName, O_RDONLY)) == -1) {
	if (Error != NULL)
	    *Error = D_GIF_ERR_OPEN_FAILED;
        return NULL;
    }

    GifFile = DGifOpenFileHandle(FileHandle, Error);
    return GifFile;
}
Example #15
0
int main(void)
{
    puts("Portal down Token Up");

    /* we assume the transceiver is started! */
    netsetup_set_channel(CONFIG_CHANNEL);
    netsetup_set_address(CONFIG_OWN_ADDRESS);
    printf("CHANNEL: %d\tADDRESS: %d\n", CONFIG_CHANNEL, CONFIG_OWN_ADDRESS);
    netsetup_start();

    /* start shell */
    posix_open(uart0_handler_pid, 0);
    shell_t shell;
    shell_init(&shell, shell_commands, UART0_BUFSIZE, uart0_readc, uart0_putc);
    shell_run(&shell);
}
Example #16
0
int main(void) {
    printf("6LoWPAN\n");
    vtimer_init();
    
    posix_open(uart0_handler_pid, 0);
    //struct tm now;
    //rtc_get_localtime(&now);
    
    //srand((unsigned int)now.tm_sec);
    //uint8_t random = rand() % 256;
    //printf("address: %d\n", random);

    shell_t shell;
    shell_init(&shell, shell_commands, uart0_readc, uart0_putc);

    shell_run(&shell);

    return 0;
}
Example #17
0
File: main.c Project: bumpy-b/RIOT
int main(void)
{
    shell_t shell;

    puts("Test for the low-level I2C driver");

#ifndef MODULE_NEWLIB
    /* prepare I/O for shell */
    board_uart0_init();
    (void) posix_open(uart0_handler_pid, 0);
    shell_init(&shell, shell_commands, UART0_BUFSIZE, uart0_readc, uart0_putc);
#else
    shell_init(&shell, shell_commands, UART0_BUFSIZE, getchar, putchar);
#endif

    /* define own shell commands */
    shell_run(&shell);

    return 0;
}
Example #18
0
File: main.c Project: ShaneLan/RIOT
int main(void)
{
    shell_t shell;
    (void) posix_open(uart0_handler_pid, 0);

#ifdef MODULE_LTC4150
    ltc4150_start();
#endif

#ifdef MODULE_TRANSCEIVER
    init_transceiver();
#endif

    (void) puts("Welcome to RIOT!");

    shell_init(&shell, NULL, UART0_BUFSIZE, shell_readc, shell_putchar);

    shell_run(&shell);
    return 0;
}
Example #19
0
File: main.c Project: AnonMall/RIOT
int main(void)
{
    puts("CCN!");

    if (msg_init_queue(msg_buffer_shell, SHELL_MSG_BUFFER_SIZE) != 0) {
        DEBUG("msg init queue failed...abording\n");
        return -1;
    }

    riot_ccn_relay_start();

    puts("starting shell...");
    puts("  posix open");
    posix_open(uart0_handler_pid, 0);
    puts("  shell init");
    shell_init(&shell, sc, UART0_BUFSIZE, uart0_readc, uart0_putc);
    puts("  shell run");
    shell_run(&shell);

    return 0;
}
Example #20
0
File: main.c Project: ntrtrung/RIOT
int main(void)
{
    shell_t shell;
    gnrc_netreg_entry_t dump;

    puts("KW2XRF device driver test");

    /* register the pktdump thread */
    puts("Register the packet dump thread for GNRC_NETTYPE_UNDEF packets");
    dump.pid = gnrc_pktdump_getpid();
    dump.demux_ctx = GNRC_NETREG_DEMUX_CTX_ALL;
    gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump);

    /* start the shell */
    puts("Initialization successful - starting the shell now");
    (void) posix_open(uart0_handler_pid, 0);
    shell_init(&shell, NULL, SHELL_BUFSIZE, uart0_readc, uart0_putc);
    shell_run(&shell);

    return 0;
}
Example #21
0
File: main.c Project: bumpy-b/RIOT
int main(void)
{
    shell_t shell;

    puts("GPIO peripheral driver test\n");
    puts("In this test, pins are specified by integer port and pin numbers.\n"
         "So if your platform has a pin PA01, it will be port=0 and pin=1,\n"
         "PC14 would be port=2 and pin=14 etc.\n\n"
         "NOTE: make sure the values you use exist on your platform! The\n"
         "      behavior for not existing ports/pins is not defined!");

    /* start the shell */
#ifndef MODULE_NEWLIB
    (void) posix_open(uart0_handler_pid, 0);
    shell_init(&shell, shell_commands, SHELL_BUFSIZE, uart0_readc, uart0_putc);
#else
    shell_init(&shell, shell_commands, SHELL_BUFSIZE, getchar, putchar);
#endif
    shell_run(&shell);

    return 0;
}
Example #22
0
/**
 * @brief   Maybe you are a golfer?!
 */
int main(void)
{
    shell_t shell;
    ng_netreg_entry_t dump;

    puts("RIOT sniffer application");

    /* start and register rawdump thread */
    puts("Run the rawdump thread and register it");
    dump.pid = thread_create(rawdmp_stack, sizeof(rawdmp_stack), RAWDUMP_PRIO,
                             CREATE_STACKTEST, rawdump, NULL, "rawdump");
    dump.demux_ctx = NG_NETREG_DEMUX_CTX_ALL;
    ng_netreg_register(NG_NETTYPE_UNDEF, &dump);

    /* start the shell */
    puts("All ok, starting the shell now");
    (void) posix_open(uart0_handler_pid, 0);
    shell_init(&shell, NULL, SHELL_BUFSIZE, uart0_readc, uart0_putc);
    shell_run(&shell);

    return 0;
}
Example #23
0
int main(void)
{
    shell_t shell;
    kernel_pid_t radio;

    /* initialize the radio */
    radio = comm_init();
    if (radio == KERNEL_PID_UNDEF) {
        puts("ERROR initializing the radio, aborting");
        return 1;
    }

    /* initialize the sensing module */
    sense_init(radio);

    /* run the shell */
    (void) posix_open(uart0_handler_pid, 0);
    shell_init(&shell, _commands, SHELL_BUFSIZE, _readc, _putc);
    shell_run(&shell);

    /* never reached */
    return 0;
}
Example #24
0
File: main.c Project: A-L-E-X/RIOT
int main(void)
{

    printf("test_shell.\n");

    board_uart0_init();

    posix_open(uart0_handler_pid, 0);

    /* define own shell commands */
    shell_t shell;
    shell_init(&shell, shell_commands, SHELL_BUFSIZE, shell_readc,
               shell_putchar);
    shell_run(&shell);

    /* or use only system shell commands */
    /*
    shell_t sys_shell;
    shell_init(&sys_shell, NULL, SHELL_BUFSIZE, shell_readc, shell_putchar);
    shell_run(&sys_shell);
    */

    return 0;
}
Example #25
0
void shell_runner(void) {
    shell_init(&shell, sc, UART0_BUFSIZE, uart0_readc, uart0_putc);
    posix_open(uart0_handler_pid, 0);
    shell_run(&shell);
}