Beispiel #1
0
Datei: main.c Projekt: wuwx/simba
int test_log_mask(struct harness_t *harness_p)
{
    char command[64];

    BTASSERT(thrd_get_log_mask() == 0x0f);
    BTASSERT(thrd_set_log_mask(thrd_self(), 0x00) == 0x0f);
    BTASSERT(thrd_get_log_mask() == 0x00);

    strcpy(command, "/kernel/thrd/set_log_mask main 0xff");
    BTASSERT(fs_call(command, NULL, sys_get_stdout(), NULL) == 0);
    BTASSERT(thrd_get_log_mask() == 0xff);

    /* Invalid arguments. */
    strcpy(command, "/kernel/thrd/set_log_mask");
    BTASSERT(fs_call(command, NULL, sys_get_stdout(), NULL) == -EINVAL);
    BTASSERT(thrd_get_log_mask() == 0xff);

    strcpy(command, "/kernel/thrd/set_log_mask foo bar");
    BTASSERT(fs_call(command, NULL, sys_get_stdout(), NULL) == -ESRCH);
    BTASSERT(thrd_get_log_mask() == 0xff);

    strcpy(command, "/kernel/thrd/set_log_mask main foo");
    BTASSERT(fs_call(command, NULL, sys_get_stdout(), NULL) == -EINVAL);
    BTASSERT(thrd_get_log_mask() == 0xff);

    return (0);
}
Beispiel #2
0
int test_fs(struct harness_t *harness_p)
{
    char command[64];
    struct command_t *command_p;
    struct command_t commands[] = {
        { "/debug/log/list", 0 },
        { "/debug/log/print foo", 0 },
        { "/debug/log/set_log_mask log 0xff", 0 },
        
        { "/debug/log/list d", -EINVAL },
        { "/debug/log/print d d", -EINVAL },
        { "/debug/log/set_log_mask invalid_object 0xff", -EINVAL },
        { "/debug/log/set_log_mask missing_mask", -EINVAL },
        { "/debug/log/set_log_mask bad_mask ds", -EINVAL },
        { NULL, 0 }
    };

    command_p = &commands[0];

    while (command_p->command_p != NULL) {
        strcpy(command, command_p->command_p);
        BTASSERT(fs_call(command,
                         NULL,
                         sys_get_stdout(),
                         NULL) == command_p->res);

        command_p++;
    }

    return (0);
}
Beispiel #3
0
int test_get_temp(struct harness_t *harness_p)
{
    struct owi_driver_t owi;
    struct ds18b20_driver_t ds;
    struct owi_device_t devices[4];
    char buf[24];
    int number_of_sensors;

    BTASSERT(owi_init(&owi, &pin_d7_dev, devices, membersof(devices)) == 0);
    BTASSERT(ds18b20_init(&ds, &owi) == 0);

    time_busy_wait_us(50000);

    number_of_sensors = owi_search(&owi);

    std_printf(FSTR("number_of_sensors = %d\r\n"), number_of_sensors);

    BTASSERT(number_of_sensors == 2);

    strcpy(buf, "drivers/ds18b20/list");
    BTASSERT(fs_call(buf, NULL, sys_get_stdout(), NULL) == 0);

    time_busy_wait_us(50000);

    return (0);
}
Beispiel #4
0
Datei: main.c Projekt: wuwx/simba
int main()
{
    sys_start();

    uart_soft_init(&uart,
                   &pin_d4_dev,
                   &pin_d3_dev,
                   &exti_d3_dev,
                   9600,
                   qinbuf,
                   sizeof(qinbuf));

    fs_command_init(&cmd_at,
                    CSTR("/at"),
                    cmd_at_cb,
                    NULL);
    fs_command_register(&cmd_at);

    std_printf(FSTR("Welcome to HC-0X configuration tool!\r\n"
                    "\r\n"
                    "SETUP: Connect pin34 to VCC so the device enters AT mode.\r\n"
                    "\r\n"
                    "Type 'at' to start communicating with the device.\r\n"));

    shell_init(&shell,
               sys_get_stdin(),
               sys_get_stdout(),
               NULL,
               NULL,
               NULL,
               NULL);
    shell_main(&shell);

    return (0);
}
Beispiel #5
0
static int test_print(struct harness_t *harness_p)
{
    /* Print various information about the file system. */
    BTASSERT(fat16_print(&fs, sys_get_stdout()) == 0);

    return (0);
}
Beispiel #6
0
Datei: main.c Projekt: wuwx/simba
int test_monitor_thread(struct harness_t *harness_p)
{
    char command[64];

    /* Missing print value. */
    strcpy(command, "/kernel/thrd/monitor/set_print");
    BTASSERT(fs_call(command, NULL, sys_get_stdout(), NULL) == -EINVAL);

    /* Bad print integer value. */
    strcpy(command, "/kernel/thrd/monitor/set_print 2");
    BTASSERT(fs_call(command, NULL, sys_get_stdout(), NULL) == -EINVAL);

    /* Bad print value. */
    strcpy(command, "/kernel/thrd/monitor/set_print foo");
    BTASSERT(fs_call(command, NULL, sys_get_stdout(), NULL) == -EINVAL);

    /* Start printing. */
    strcpy(command, "/kernel/thrd/monitor/set_print 1");
    BTASSERT(fs_call(command, NULL, sys_get_stdout(), NULL) == 0);

    /* Wait a while for monitor thread output.*/
    thrd_sleep_ms(30);

    strcpy(command, "/kernel/thrd/monitor/set_period_ms 10");
    BTASSERT(fs_call(command, NULL, chan_null(), NULL) == 0);

    /* Wait a while for monitor thread output.*/
    thrd_sleep_ms(30);

    /* Stop printing. */
    strcpy(command, "/kernel/thrd/monitor/set_print 0");
    BTASSERT(fs_call(command, NULL, sys_get_stdout(), NULL) == 0);

    /* Missing period. */
    strcpy(command, "/kernel/thrd/monitor/set_period_ms");
    BTASSERT(fs_call(command, NULL, chan_null(), NULL) == -EINVAL);

    /* Bad period. */
    strcpy(command, "/kernel/thrd/monitor/set_period_ms bar");
    BTASSERT(fs_call(command, NULL, chan_null(), NULL) == -EINVAL);

    return (0);
}
Beispiel #7
0
int main()
{
    sys_start();

    /* Configure and start the the WiFi module as a Station and
       SoftAP. */
    esp_wifi_set_op_mode(esp_wifi_op_mode_station_softap_t);

    if (esp_wifi_softap_init("Simba", NULL) != 0) {
        std_printf(FSTR("Failed to configure the Soft AP.\r\n"));
    }

    if (esp_wifi_station_init("Qvist2", "maxierik", NULL) != 0) {
        std_printf(FSTR("Failed to configure the Station.\r\n"));
    }

    while (1) {
        esp_wifi_print(sys_get_stdout());
        thrd_sleep(2);
    }

    return (0);
}
Beispiel #8
0
Datei: main.c Projekt: wuwx/simba
int test_handler(struct harness_t *harness_p)
{
    struct log_object_t foo;
    struct log_handler_t handler;

    /* Initialize the log objects. */
    BTASSERT(log_object_init(&foo,
                             "foo",
                             LOG_UPTO(INFO)) == 0);
    BTASSERT(log_handler_init(&handler, sys_get_stdout()) == 0);

    /* This should be printed once for the default handler. */
    BTASSERT(log_object_print(&foo,
                              LOG_INFO,
                              FSTR("one handler\r\n")) == 1);

    /* Add our handler. */
    BTASSERT(log_add_handler(&handler) == 0);

    /* This should be printed twice, one for the default handler and
       once for our handler. */
    BTASSERT(log_object_print(&foo,
                              LOG_INFO,
                              FSTR("two handlers\r\n")) == 2);

    /* Remove our handler. */
    BTASSERT(log_remove_handler(&handler) == 0);
    BTASSERT(log_remove_handler(&handler) == 1);

    /* This should be printed once for the default handler. */
    BTASSERT(log_object_print(&foo,
                              LOG_INFO,
                              FSTR("one handler again\r\n")) == 1);

    return (0);
}