void generic_gpio_srv_test(uint8_t service_id, uint8_t inputPin, uint8_t outputPin, char* portLabel)
{
    DRIVER_API_RC ret;
    char* outputString = balloc(55, NULL) ;
    char* border = "##################################################\n";
    cfw_client_t * gpio_client = cfw_client_init(get_test_queue(), gpio_tst_handle_msg, NULL);

    ret = tst_gpio_srv_test_single_edge(gpio_client, service_id, inputPin, outputPin);
    sprintf(outputString, "Test for %s gpio single edge", portLabel);
    CU_ASSERT(outputString , ret == DRV_RC_OK);
    if(ret == DRV_RC_OK)
    {
        cu_print("%s", border);
        cu_print("#       Test GPIO %s gpio single edge OK        #\n", portLabel);
        cu_print("%s", border);
    }

    ret = tst_gpio_srv_test_double_edge(gpio_client, service_id, inputPin, outputPin);
    sprintf(outputString, "Test for %s gpio double edge", portLabel);
    CU_ASSERT(outputString, ret == DRV_RC_OK);
    if(ret == DRV_RC_OK)
    {
        cu_print("%s", border);
        cu_print("#       Test GPIO %s gpio double edge OK         #\n", portLabel);
        cu_print("%s", border);
    }
}
Beispiel #2
0
void sensordata_init(T_QUEUE queue)
{
	/* Initialize client message handler */
	cfw_client_t *sensor_client = cfw_client_init(queue, sensor_handle_msg,
						      NULL);

	/* Open the sensor service */
	cfw_open_service_helper(sensor_client, ARC_SC_SVC_ID,
				service_connection_cb, NULL);
}
/**@brief Open connection with the Audio service.
 *
 * @details The function opens the audio service and provides message
 *          handler function pointer.
 * @param[in] queue Queue of messages.
 * @param[in] service Pointer to ui service.
 * @return   none.
 */
void ui_audio_svc_open(void *queue, service_t *service)
{
    ui_svc = service;

    ui_audio_svc = cfw_client_init(queue,
                     ui_audio_svc_handle_message,
                     UISVC_AUDIO_CLIENT);
    if (ui_audio_svc == NULL) force_panic();

    cfw_open_service_conn(ui_audio_svc, AUDIO_SVC_ID, "UI SVC Audio");
}
Beispiel #4
0
void sensing_iq_init(T_QUEUE queue)
{
	static bool sensing_initialized = false;

	if (!sensing_initialized){
		sensor_client = cfw_client_init(queue, sensor_handle_msg, NULL);

		cfw_open_service_helper(sensor_client, ARC_SC_SVC_ID,
				sensing_start_sensor_scanning, NULL);
		sensing_initialized = true;
	}
}
Beispiel #5
0
void ble_start_app(T_QUEUE queue)
{
	cfw_client_t *client;

	/* Get a client handle */
	client = cfw_client_init(queue, ble_app_msg_handler, &_ble_app_cb);
	assert(client);

	/* Open properties service -> will resume app initialization */
	cfw_open_service_helper(client, PROPERTIES_SERVICE_ID,
				on_properties_service_open, client);
}
Beispiel #6
0
bool sensor_svc_open_sensor_core_svc(void *p_queue, void (*cb)(void *),
				     void *cb_param)
{
#if defined(SENSOR_SERVICE) && (SENSOR_SERVICE == QRK_SENSOR_SERVICE)
	core_connected_cb = cb;
	core_connected_cb_data = cb_param;
#endif
	p_client = cfw_client_init(p_queue, sensor_core_svc_rsp_handle,
				   "Score_tst");
	if (!p_client)
		return false;
	cfw_register_svc_available(p_client, ARC_SC_SVC_ID, NULL);
	return true;
}
Beispiel #7
0
int main_event_handler_init(xloop_t *l)
{
	loop = l;

	cfw_handle = cfw_client_init(loop->queue, cfw_message_handler, NULL);

	cfw_open_service_helper(cfw_handle, SOC_GPIO_SERVICE_ID,
				service_opened_cb, (void *)SOC_GPIO_SERVICE_ID);

	cfw_open_service_helper(cfw_handle, SS_ADC_SERVICE_ID,
				service_opened_cb, (void *)SS_ADC_SERVICE_ID);

	xloop_post_func_periodic(loop, hello_func, NULL, NOTIF_DELAY_MS);
	pr_debug(LOG_MODULE_MAIN, "main event handler initialized");
	return 0;
}
Beispiel #8
0
int main(void) {
	queue = queue_create(10, NULL);
	cfw_service_mgr_init(queue);

	sanity_test_list();
	test_timers();

	test_service_init(queue, TEST_SERVICE_ID);

	pr_info(LOG_MODULE_MAIN, "End of init....");
	pr_info(LOG_MODULE_MAIN, "Start of real stuff...\n");

	cfw_client_t *c = cfw_client_init(queue, my_handle_message, "Client 1");
	//cfw_client_t *c2 = cfw_client_init(queue, my_handle_message, "Client 2");

	cfw_open_service_conn(c, TEST_SERVICE_ID, "Conn1");
	cfw_open_service_conn(c, TEST_SERVICE_ID, "Conn2");

	_cfw_loop(queue);
	return EXIT_SUCCESS;
}
Beispiel #9
0
void main(int argc, char** argv)
{
    int loops = 0;
    void * cfw_channel;

    if (argc > 1) {
	    baud_rate = baudrate_to_termios(strtol(argv[1], NULL, 0));
    } else {
	    baud_rate = baudrate_to_termios(0); /* forcing 115200 */
    }
    /* Set the remote CPU handlers */
    set_cpu_message_sender(CPU_ID_BLE, linux_ipc_send_message);
    set_cpu_message_sender(CPU_ID_ARC, linux_ipc_send_message);
    set_cpu_message_sender(CPU_ID_HOST, linux_ipc_send_message);
    set_cpu_free_handler(CPU_ID_BLE, linux_ipc_free);
    set_cpu_free_handler(CPU_ID_ARC, linux_ipc_free);
    set_cpu_free_handler(CPU_ID_HOST, linux_ipc_free);
    set_cpu_id(CPU_ID_QUARK);


    int uart_fd = wait_client(SOCKET_NAME, UART_PORT);

    printf("Client connected on %d\n", uart_fd);
    uart_ipc_init(uart_fd);
    fd_set fds;
    FD_ZERO(&fds);
    struct timeval tv;
    _server_cb.queue = queue_create(10, NULL);
    cfw_service_mgr_init(_server_cb.queue);

    /* We use the main task queue to support most services */
    set_service_queue(_server_cb.queue);

    _server_cb.client = (cfw_client_t *)cfw_client_init(_server_cb.queue, srv_client_handle_msg,
		    &_server_cb);
    /* get informed on new services */
    cfw_register_svc_available(_server_cb.client, BLE_CORE_SERVICE_ID, &_server_cb);

    /* some test services */
    test_service_init(_server_cb.queue, TEST_SERVICE_ID);

    /* ble service */
    ble_cfw_service_init(_server_cb.queue);

    cfw_channel = ipc_uart_channel_open(0, ipc_uart_message_cback);
    linux_ipc_set_channel(cfw_channel);

    while(1) {
        FD_SET(uart_fd, &fds);
        FD_SET(0, &fds);
        tv.tv_sec = 1;
        tv.tv_usec = 0;

        int ret = select(uart_fd + 1, &fds, NULL, NULL, &tv);
        if (ret == -1) {
            perror("select()");
        } else if (ret) {
            if (FD_ISSET(0, &fds)) {
            } else if(FD_ISSET(uart_fd, &fds)) {
                uart_ipc_handle_data(uart_fd);
            }
        } else {
            printf(".");
#ifdef CONFIG_BLE_CORE_TEST
            test_ble_service_update_battery_level(battery_level--);
            if (battery_level == 10)
        	    battery_level = 100;
#endif
        }
        cfw_process(_server_cb.queue);
    }
}
Beispiel #10
0
int press_simulation(unsigned int service_id, unsigned int input_pin,
		     unsigned int output_pin)
{
	cfw_service_conn_t *gpio_service_conn = NULL;

	cfw_client_t *gpio_client = cfw_client_init(
		get_test_queue(), pwrbtn_tst_handle_msg, NULL);

	if (!cfw_service_registered(service_id)) {
		cu_print("TST_PWRBTN: ss gpio service not registered\n");
		return DRV_RC_FAIL;
	}

	cfw_open_service_conn(gpio_client, service_id, &gpio_service_conn);
	SRV_WAIT((!gpio_service_conn), 2000);
	CU_ASSERT("TST_PWRBTN: can not open ss gpio service",
		  (gpio_service_conn));
	if (gpio_service_conn == NULL) {
		return DRV_RC_FAIL;
	}

	/* The configuration put the pin to 0 => the pin have to be set to 1
	 * before first press simulation */
	TEST_PWRBTN(configure, "TST_PWRBTN: gpio configuration failed",
		    gpio_service_conn, output_pin, 1,
		    "SS pin 2 output");
	SRV_WAIT((!tst_pwrbtn_configure), 2000);
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 1 failed (re)",
		    gpio_service_conn, output_pin, 1,
		    "set_output 1");
	/* wait state response */
	SRV_WAIT((!tst_pwrbtn_set_state), 2000);

	/* wait 3s */
	local_task_sleep_ms(3000);

	tst_step = VERY_SH_PRESS;
	cu_print("Start pattern with press_duration = 700ms\n");
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 0 failed (re)",
		    gpio_service_conn, output_pin, 0,
		    "set_output 0");
	local_task_sleep_ms(700);
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 1 failed (re)",
		    gpio_service_conn, output_pin, 1,
		    "set_output 1");

	/* wait pattern detection */
	SRV_WAIT((!tst_very_short), 2000);
	/* wait 3s */
	local_task_sleep_ms(3000);

	cu_print("Start pattern with press_duration = 2500ms\n");
	tst_step = SH_PRESS;
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 0 failed (re)",
		    gpio_service_conn, output_pin, 0,
		    "set_output 0");
	local_task_sleep_ms(2500);
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 1 failed (re)",
		    gpio_service_conn, output_pin, 1,
		    "set_output 1");

	/* wait pattern detection */
	SRV_WAIT((!tst_short), 2000);
	/* wait 3s */
	local_task_sleep_ms(3000);

	cu_print("Start pattern with press_duration = 4000ms\n");
	tst_step = SINGLE_PRESS;
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 0 failed (re)",
		    gpio_service_conn, output_pin, 0,
		    "set_output 0");
	local_task_sleep_ms(4000);
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 1 failed (re)",
		    gpio_service_conn, output_pin, 1,
		    "set_output 1");

	/* wait pattern detection */
	SRV_WAIT((!tst_single), 2000);
	/* wait 3s */
	local_task_sleep_ms(3000);

	cu_print("Start pattern with press_duration = 7000ms\n");
	tst_step = L_PRESS;
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 0 failed (re)",
		    gpio_service_conn, output_pin, 0,
		    "set_output 0");
	local_task_sleep_ms(7000);
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 1 failed (re)",
		    gpio_service_conn, output_pin, 1,
		    "set_output 1");

	/* wait pattern detection */
	SRV_WAIT((!tst_long), 2000);
	/* wait 3s */
	local_task_sleep_ms(3000);

	cu_print("Start pattern with press_duration = 12000ms\n");
	tst_step = VERY_L_PRESS;
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 0 failed (re)",
		    gpio_service_conn, output_pin, 0,
		    "set_output 0");
	local_task_sleep_ms(12000);
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 1 failed (re)",
		    gpio_service_conn, output_pin, 1,
		    "set_output 1");

	/* wait 3s */
	local_task_sleep_ms(3000);

	/* Start failed double press pattern : very_short_press + 550 ms delay max + short_press */
	cu_print("Start double pattern press failed...\n");
	tst_step = DBLE_PRESS_FAIL_1;
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 0 failed (re)",
		    gpio_service_conn, output_pin, 0,
		    "set_output 0");
	local_task_sleep_ms(700);
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 1 failed (re)",
		    gpio_service_conn, output_pin, 1,
		    "set_output 1");

	/* wait pattern detection */
	SRV_WAIT((!tst_double_fail_1), 2000);
	/* wait between the very short press */
	local_task_sleep_ms(550);

	tst_step = DBLE_PRESS_FAIL_2;
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 0 failed (re)",
		    gpio_service_conn, output_pin, 0,
		    "set_output 0");
	local_task_sleep_ms(2700);
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 1 failed (re)",
		    gpio_service_conn, output_pin, 1,
		    "set_output 1");

	/* wait pattern detection */
	SRV_WAIT((!tst_double_fail_2), 2000);
	/* wait 3s */
	local_task_sleep_ms(3000);

	cu_print("Start too short pattern with duration = 300ms\n");
	tst_step = TOO_SHORT_PRESS;
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 0 failed (re)",
		    gpio_service_conn, output_pin, 0,
		    "set_output 0");
	local_task_sleep_ms(300);
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 1 failed (re)",
		    gpio_service_conn, output_pin, 1,
		    "set_output 1");

	/* wait pattern detection */
	SRV_WAIT((!tst_double_fail_2), 2000);
	/* wait 3s */
	local_task_sleep_ms(3000);

	/* Start double press pattern : very_short_press + 350 ms delay max + very_short_press */
	cu_print("Start double pattern press...\n");
	tst_step = DBLE_PRESS;
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 0 failed (re)",
		    gpio_service_conn, output_pin, 0,
		    "set_output 0");
	local_task_sleep_ms(700);
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 1 failed (re)",
		    gpio_service_conn, output_pin, 1,
		    "set_output 1");

	/* wait between the very short press */
	local_task_sleep_ms(350);

	TEST_PWRBTN(set_state, "TST_PWRBTN: set 0 failed (re)",
		    gpio_service_conn, output_pin, 0,
		    "set_output 0");
	local_task_sleep_ms(900);
	TEST_PWRBTN(set_state, "TST_PWRBTN: set 1 failed (re)",
		    gpio_service_conn, output_pin, 1,
		    "set_output 1");

	/* wait pattern detection */
	SRV_WAIT((!tst_double), 2000);
	/* wait 2s */
	local_task_sleep_ms(2000);

	cfw_close_service_conn(gpio_service_conn, NULL);

	return DRV_RC_OK;
}