コード例 #1
0
ファイル: hs_cmdline_mmi.c プロジェクト: jprothwell/sc-fix
int app_main(void) {
    int status;

    prh_printf("\n\n\nParthus Technologies Headset Profile Headset Application\n\n");

    start_host();
	do
    {
        status = MGR_Init(0);
        if(status == BT_RETRY)
        {
            /* Delay for 100 ms */
            OS_DELAY(100);
        }
    }while(status == BT_RETRY);

    if (status!=BT_NOERROR) {
        prh_printf("Host stack initialisation error (0x%02X)\n",status);
        return 1;
    }

    status=HS_Init();
	if(status)
	{
		prh_printf(" Headset initialisation error\n");		
		return 0;
	}

    MMI_Main();

    return 0;
}
コード例 #2
0
ファイル: amservice.c プロジェクト: patelanuj28/amanda
void
client_protocol(
    char        *hostname,
    char        *auth,
    char        *service,
    FILE        *input_file)
{
    GString *strbuf = g_string_new(NULL);
    char *req, *req1;

    g_string_append_printf(strbuf, "SERVICE %s\nOPTIONS features=%s\n",
        service, our_feature_string);

    req1 = g_malloc(1024);
    while(fgets(req1, 1024, input_file) != NULL)
	g_string_append(strbuf, req1);

    g_free(req1);
    protocol_init();

    req = g_string_free(strbuf, FALSE);

    start_host(hostname, auth, req);

    protocol_run();

    fflush(stdout);

    amfree(our_feature_string);

    return;
}
コード例 #3
0
ファイル: amservice.c プロジェクト: pcmantz/amanda
void
client_protocol(
    char *hostname,
    char *auth,
    char *service,
    FILE *input_file)
{
    char *req, *req1;

    req = g_strdup_printf("SERVICE %s\nOPTIONS features=%s\n",
			  service, our_feature_string);
    req1 = malloc(1024);
    while(fgets(req1, 1024, input_file) != NULL) {
	vstrextend(&req, req1, NULL);
    }
    protocol_init();

    start_host(hostname, auth, req);

    protocol_run();

    fflush(stdout);

    amfree(our_feature_string);

    return;
}
コード例 #4
0
ファイル: event.c プロジェクト: grobe0ba/plan9front
void
ebegin(int Ehost)
{

	atexit(edie);

	einit(Emouse|Ekeyboard);

	outfd = start_host();
	if( estart(Ehost, outfd, BUFSIZ) != Ehost) {
		exits("event init error");
	}
}
コード例 #5
0
static enum dwc_otg_state do_a_host(struct dwc_otg2 *otg)
{
	int rc = 0;
	u32 otg_events, user_events, otg_mask, user_mask;
	int id = RID_UNKNOWN;
	unsigned long flags;

	/* If Battery low and connected charger is not ACA-DOCK.
	 * Then stop trying to start host mode. */
	if ((otg->usb2_phy.vbus_state == VBUS_DISABLED) &&
			(otg->charging_cap.chrg_type !=
			POWER_SUPPLY_CHARGER_TYPE_ACA_DOCK)) {
		otg_uevent_trigger(&otg->usb2_phy);
		return DWC_STATE_B_IDLE;
	}

	if (otg->charging_cap.chrg_type !=
			POWER_SUPPLY_CHARGER_TYPE_ACA_DOCK) {
		dwc_otg_enable_vbus(otg, 1);

		/* meant receive vbus valid event*/
		if (do_wait_vbus_raise(otg) == DWC_STATE_A_HOST)
			otg_err(otg, "Drive VBUS maybe fail!\n");
	}

	rc = start_host(otg);
	if (rc < 0) {
		stop_host(otg);
		otg_err(otg, "start_host failed!");
		return DWC_STATE_INVALID;
	}

stay_host:
	otg_events = 0;
	user_events = 0;

	user_mask = USER_A_BUS_DROP |
				USER_ID_B_CHANGE_EVENT;
	otg_mask = OEVT_CONN_ID_STS_CHNG_EVNT |
			OEVT_A_DEV_SESS_END_DET_EVNT;

	rc = sleep_until_event(otg,
			otg_mask, user_mask,
			&otg_events, &user_events, 0);
	if (rc < 0) {
		stop_host(otg);
		return DWC_STATE_EXIT;
	}

	/* Higher priority first */
	if (otg_events & OEVT_A_DEV_SESS_END_DET_EVNT) {
		otg_dbg(otg, "OEVT_A_DEV_SESS_END_DET_EVNT\n");

		/* ACA-Dock plug out */
		if (otg->charging_cap.chrg_type ==
				POWER_SUPPLY_CHARGER_TYPE_ACA_DOCK)
			dwc_otg_notify_charger_type(otg,
					POWER_SUPPLY_CHARGER_EVENT_DISCONNECT);
		else
			dwc_otg_enable_vbus(otg, 0);

		stop_host(otg);
		return DWC_STATE_B_IDLE;
	}

	if (user_events & USER_A_BUS_DROP) {
		/* Due to big consume by DUT, even ACA-Dock connected,
		 * the battery capability still maybe decrease. For this
		 * case, still save host mode. Because DUT haven't drive VBus.*/
		if (otg->charging_cap.chrg_type ==
				POWER_SUPPLY_CHARGER_TYPE_ACA_DOCK)
			goto stay_host;

		dwc_otg_enable_vbus(otg, 0);
		stop_host(otg);
		return DWC_STATE_B_IDLE;
	}

	if (otg_events & OEVT_CONN_ID_STS_CHNG_EVNT) {
		otg_dbg(otg, "OEVT_CONN_ID_STS_CHNG_EVNT\n");
		id = get_id(otg);

		/* Plug out ACA_DOCK/USB device */
		if (id == RID_FLOAT) {
			if (otg->charging_cap.chrg_type ==
					POWER_SUPPLY_CHARGER_TYPE_ACA_DOCK) {
				/* ACA_DOCK plug out, receive
				 * id change prior to vBus change
				 */
				dwc_otg_notify_charger_type(otg,
					POWER_SUPPLY_CHARGER_EVENT_DISCONNECT);

				stop_host(otg);
			} else {
				/* Normal USB device plug out */
				spin_lock_irqsave(&otg->lock, flags);
				otg->charging_cap.chrg_type =
					POWER_SUPPLY_CHARGER_TYPE_NONE;
				spin_unlock_irqrestore(&otg->lock, flags);

				stop_host(otg);
				dwc_otg_enable_vbus(otg, 0);
			}
		} else if (id == RID_GND || id == RID_A) {
			otg_dbg(otg, "Stay DWC_STATE_A_HOST!!\n");
			/* Prevent user fast plug in after plug out.
			 * It will cause the first ID change event lost.
			 * So need to check real ID currently.
			 */
			goto stay_host;
		} else {
			otg_err(otg, "Meet invalid charger cases!");
			spin_lock_irqsave(&otg->lock, flags);
			otg->charging_cap.chrg_type =
				POWER_SUPPLY_CHARGER_TYPE_NONE;
			spin_unlock_irqrestore(&otg->lock, flags);

			stop_host(otg);
		}
		return DWC_STATE_WAIT_VBUS_FALL;
	}

	/* Higher priority first */
	if (user_events & USER_ID_B_CHANGE_EVENT) {
		otg_dbg(otg, "USER_ID_B_CHANGE_EVENT\n");
		stop_host(otg);
		otg->user_events |= USER_ID_B_CHANGE_EVENT;
		return DWC_STATE_B_IDLE;
	}

	/* Invalid state */
	return DWC_STATE_INVALID;
}
コード例 #6
0
ファイル: bigtest.c プロジェクト: JustinTulloss/yaps
int main (int argc, char **argv)
{

    int opt;
    char *configfile = "hosts";
    JRB hosts, node, node2;
    Host *host, *join, *me;
    int nhosts;
    int i, j;
    Message *m;
    char dest[160];
    char msg[256];
    Key tmp;
    ChimeraHost ch;
    double start;

    while ((opt = getopt (argc, argv, OPTSTR)) != EOF)
	{
	    switch ((char) opt)
		{
		case 'f':
		    configfile = optarg;
		    break;
		default:
		    fprintf (stderr, "invalid option %c\n", (char) opt);
		    fprintf (stderr, "usage: %s\n", USAGE);
		    exit (1);
		}
	}

    sem = sema_create (0);
    state = (ChimeraState *) malloc (sizeof (ChimeraState));

    me = (Host *) malloc (sizeof (Host));
    me->name = "localhost";
    me->port = 11110;
    me->hnp = "localhost:11110";

    hosts = read_hosts (configfile, &nhosts);

    state->log = log_init ();
    log_direct (state->log, LOG_ERROR, stderr);
    log_direct (state->log, LOG_WARN, stderr);

    key_init ();
    state->message = message_init (state, 11110);
    message_handler (state, 21, hello, 1);
    message_handler (state, 22, fwd, 1);
    message_handler (state, 23, del, 1);
    message_handler (state, 24, NULL, 1);

    srand (time (NULL));

/* This part runs bighost in different hosts */

    announced = 0;
    jrb_traverse (node, hosts)
    {
	if (announced == 0)
	    {
		join = NULL;
	    }
	else
	    {
		i = (rand () % announced) + 1;
		jrb_traverse (node2, hosts)
		{
		    i--;
		    if (i == 0)
			break;
		}
		join = (Host *) node2->val.v;
	    }
	host = (Host *) node->val.v;

	start_host (host, join);
	dsleep (0.1);
    }