static void utc_taskmanager_unicast_p(void)
{
	int ret;
	int sleep_cnt = 0;
	tm_msg_t reply_msg;
	tm_msg_t send_msg;

	cb_flag = false;

	send_msg.msg_size = strlen(TM_SAMPLE_MSG) + 1;
	send_msg.msg = malloc(send_msg.msg_size);
	TC_ASSERT_NEQ("task_manager_unicast", send_msg.msg, NULL);

	strncpy(send_msg.msg, TM_SAMPLE_MSG, send_msg.msg_size);

	ret = task_manager_unicast(tm_sample_handle, &send_msg, NULL, TM_NO_RESPONSE);
	TC_ASSERT_EQ("task_manager_unicast", ret, OK);
	while (1) {
		sleep(1);
		if (flag) {
			break;
		}
		TC_ASSERT_LEQ_CLEANUP("task_manager_unicast", sleep_cnt, 10, free(send_msg.msg));
		sleep_cnt++;
	}

	free(send_msg.msg);

	send_msg.msg_size = strlen(TM_SYNC_SEND_MSG) + 1;
	send_msg.msg = malloc(send_msg.msg_size);
	TC_ASSERT_NEQ("task_manager_unicast", send_msg.msg, NULL);

	strncpy(send_msg.msg, TM_SYNC_SEND_MSG, send_msg.msg_size);

	ret = task_manager_unicast(tm_not_builtin_handle, &send_msg, &reply_msg, TM_RESPONSE_WAIT_INF);
	TC_ASSERT_EQ_CLEANUP("task_manager_unicast", ret, OK, free(send_msg.msg));
	if (strncmp((char *)reply_msg.msg, (char *)TM_SYNC_RECV_MSG, strlen(TM_SYNC_RECV_MSG)) == 0) {
		cb_flag = true;
	} else {
		cb_flag = false;
	}

	free(send_msg.msg);
	free(reply_msg.msg);
	TC_SUCCESS_RESULT();
}
static void utc_taskmanager_unicast_n(void)
{
	int ret;
	tm_msg_t send_msg;
	send_msg.msg_size = strlen(TM_SAMPLE_MSG) + 1;
	send_msg.msg = malloc(send_msg.msg_size);
	TC_ASSERT_NEQ("task_manager_unicast", send_msg.msg, NULL);

	strncpy(send_msg.msg, TM_SAMPLE_MSG, send_msg.msg_size);
	
	ret = task_manager_unicast(tm_sample_handle, &send_msg, NULL, TM_INVALID_TIMEOUT);
	TC_ASSERT_EQ_CLEANUP("task_manager_unicast", ret, TM_INVALID_PARAM, free(send_msg.msg));

	ret = task_manager_unicast(TM_INVALID_HANDLE, &send_msg, NULL, TM_NO_RESPONSE);
	TC_ASSERT_EQ_CLEANUP("task_manager_unicast", ret, TM_INVALID_PARAM, free(send_msg.msg));

	send_msg.msg_size = 0;
	ret = task_manager_unicast(tm_sample_handle, &send_msg, NULL, TM_NO_RESPONSE);
	TC_ASSERT_EQ_CLEANUP("task_manager_unicast", ret, TM_INVALID_PARAM, free(send_msg.msg));

	free(send_msg.msg);

	TC_SUCCESS_RESULT();
}
Beispiel #3
0
int user_main(int argc, char *argv[])
#endif
{
	int handle_actionmanager = 0;
	int ret;
	app_info_list_t *action_manager_info;

	char *msg1 = (char *)malloc(sizeof(char) * 9);
	char *msg2 = (char *)malloc(sizeof(char) * 12);
	char *msg3 = (char *)malloc(sizeof(char) * 13);	
	char *msg4 = (char *)malloc(sizeof(char) * 14);
	char *msg5 = (char *)malloc(sizeof(char) * 10);
	strcpy(msg1, "alarm_on");
	strcpy(msg2, "alarm_pause");
	strcpy(msg3, "alarm_resume");
	strcpy(msg4, "alarm_restart");
	strcpy(msg5, "alarm_off");

	action_manager_info = (app_info_list_t *)task_manager_getinfo_with_name("action_manager", TM_RESPONSE_WAIT_INF);
	if (action_manager_info != NULL) {
		handle_actionmanager = action_manager_info->task.handle;
	}
	task_manager_clean_infolist(&action_manager_info);
	
	printf("\nUser App sends Alarm On message to Action Manager\n");
	ret = task_manager_unicast(handle_actionmanager, msg1, strlen(msg1) + 1, TM_RESPONSE_WAIT_INF);
	if (ret != OK) {
		printf("ERROR : SEND SIGNAL %d\n", ret);
	} else {
		printf("Alarm On message is successfully sended!\n");
	}

	sleep(3);
	printf("\nUser App sends Alarm Pause message to Action Manager\n");
	ret = task_manager_unicast(handle_actionmanager, msg2, strlen(msg2) + 1, TM_RESPONSE_WAIT_INF);
	if (ret != OK) {
		printf("ERROR : SEND SIGNAL %d\n", ret);
	} else {
		printf("Alarm Pause message is successfully sended!\n");
	}

	sleep(3);
	printf("\nUser App sends Alarm Resume message to Action Manager\n");
	ret = task_manager_unicast(handle_actionmanager, msg3, strlen(msg3) + 1, TM_RESPONSE_WAIT_INF);
	if (ret != OK) {
		printf("ERROR : SEND SIGNAL %d\n", ret);
	} else {
		printf("Alarm Resume message is successfully sended!\n");
	}

	sleep(3);
	printf("\nUser App sends Alarm Restart message to Action Manager\n");
	ret = task_manager_unicast(handle_actionmanager, msg4, strlen(msg4) + 1, TM_RESPONSE_WAIT_INF);
	if (ret != OK) {
		printf("ERROR : SEND SIGNAL %d\n", ret);
	} else {
		printf("Alarm Restart message is successfully sended!\n");
	}

	sleep(3);
	printf("\nUser App sends Alarm Off message to Action Manager\n");
	ret = task_manager_unicast(handle_actionmanager, msg5, strlen(msg5) + 1, TM_RESPONSE_WAIT_INF);
	if (ret != OK) {
		printf("ERROR : SEND SIGNAL %d\n", ret);
	} else {
		printf("Alarm Off message is successfully sended!\n");
	}

	free(msg1);
	free(msg2);
	free(msg3);
	free(msg4);
	free(msg5);

	sleep(1);
	printf("\nUser App broadcasts WIFI_ON message\n");
	ret = task_manager_broadcast(TM_BROADCAST_WIFI_ON);
	if (ret != OK) {
		printf("ERROR : SEND SIGNAL %d\n", ret);
	} else {
		printf("WIFI_ON message is successfully broadcasted!\n");
	}

	sleep(1);
	printf("\nUser App broadcasts WIFI_OFF message\n");
	ret = task_manager_broadcast(TM_BROADCAST_WIFI_OFF);
	if (ret != OK) {
		printf("ERROR : SEND SIGNAL %d\n", ret);
	} else {
		printf("WIFI_OFF message is successfully broadcasted!\n");
	}

	return 0;
}