コード例 #1
0
ファイル: ping_tasks.c プロジェクト: glfernando/sysbios-rpmsg
Void copyTaskFxn(UArg arg0, UArg arg1)
{
    MessageQCopy_Handle    handle;
    Char                   buffer[128];
    UInt32                 myEndpoint = 0;
    UInt32                 remoteEndpoint;
    UInt16                 dstProc;
    UInt16                 len;
    Int                    i;

    System_printf("copyTask %d: Entered...:\n", arg0);

    dstProc = MultiProc_getId("HOST");

    /* Create the messageQ for receiving (and get our endpoint for sending). */
    handle = MessageQCopy_create(arg0, &myEndpoint);

    NameMap_register("rpmsg-client-sample", arg0);

    for (i = 0; i < APP_NUM_ITERATIONS; i++) {
       /* Await a character message: */
       MessageQCopy_recv(handle, (Ptr)buffer, &len, &remoteEndpoint,
                         MessageQCopy_FOREVER);

       buffer[len] = '\0';
       System_printf("copyTask %d: Received data: %s, len:%d\n", i + 1,
                      buffer, len);

       /* Send data back to remote endpoint: */
       MessageQCopy_send(dstProc, remoteEndpoint, myEndpoint, (Ptr)buffer, len);
    }

    /* Teardown our side: */
    MessageQCopy_delete(&handle);
}
コード例 #2
0
ファイル: IpcResource.c プロジェクト: GAnthony/sysbios-rpmsg
Int IpcResource_disconnect(IpcResource_Handle handle)
{
    Int status;
    IpcResource_Req req;

    if (!handle) {
        System_printf("IpcResource_disconnect: handle is NULL\n");
    }

    req.resType = 0;
    req.reqType = IpcResource_REQ_TYPE_DISCONN;

    status = MessageQCopy_send(MultiProc_getId("HOST"), IpcResource_server,
                        handle->endPoint, &req, sizeof(req));
    if (status) {
        System_printf("IpcResource_disconnect: MessageQCopy_send "
                      "failed status %d\n", status);
        return status;
    }

    status = MessageQCopy_delete(&handle->msgq);
    if (status) {
        System_printf("IpcResource_disconnect: MessageQCopy_delete "
                      "failed status %d\n", status);
        return status;
    }

    Memory_free(NULL, handle, sizeof(*handle));

    return 0;
}
コード例 #3
0
static Void startExchange(Uint32 arg)
{
	MessageQCopy_Handle    handle;
	Char                   buffer[128];
	UInt32                 myEndpoint = 0;
	UInt32                 remoteEndpoint;
	UInt16                 len;
	UInt16				   dstProc;
	Int                    i;

	sb_printf("copyTask %d: Entered...:\n", arg);

	dstProc = MultiProc_getId("HOST");

	MessageQCopy_init(dstProc);

    /* Create the messageQ for receiving (and get our endpoint for sending). */
	handle = MessageQCopy_create(arg, &myEndpoint);

	NameMap_register("fuckit-all", arg);

	for (i = 0; i < APP_NUM_ITERATIONS; i++) {
		/* Await a character message: */
		MessageQCopy_recv(handle, (Ptr)buffer, &len, &remoteEndpoint,
							MessageQCopy_FOREVER);

		buffer[len] = '\0';

		len = 8;
		memcpy((Ptr)buffer, "response", 8);
		/* Send data back to remote endpoint: */
		MessageQCopy_send(dstProc, remoteEndpoint, myEndpoint,
							(Ptr)buffer, len);
	}

	/* Teardown our side: */
	MessageQCopy_delete(&handle);

	/* Free MessageQCopy module wide resources: */
	MessageQCopy_finalize();
}
コード例 #4
0
ファイル: IpcResource.c プロジェクト: mobiaqua/ti-rpmsg
Int IpcResource_disconnect(IpcResource_Handle handle)
{
    Int status;

    if (!handle) {
        System_printf("IpcResource_disconnect: handle is NULL\n");
        return IpcResource_E_INVALARGS;
    }

    NameMap_unregister("rpmsg-resmgr", handle->endPoint);

    status = MessageQCopy_delete(&handle->msgq);
    if (status) {
        System_printf("IpcResource_disconnect: MessageQCopy_delete "
                      "failed status %d\n", status);
        return status;
    }

    Semaphore_delete(&handle->sem);

    Memory_free(NULL, handle, sizeof(*handle));

    return IpcResource_S_SUCCESS;
}
コード例 #5
0
ファイル: IpcResource.c プロジェクト: mobiaqua/ti-rpmsg
IpcResource_Handle IpcResource_connect(UInt timeout)
{
    UInt16 dstProc;
    UInt16 len;
    IpcResource_Handle handle;
    IpcResource_Ack ack;
    Int status;

    handle = Memory_alloc(NULL, sizeof(*handle), 0, NULL);
    if (!handle) {
        System_printf("IpcResource_connect: No memory");
        return NULL;
    }

    handle->timeout = (!timeout) ? DEFAULT_TIMEOUT :
                      (timeout == IpcResource_FOREVER) ? MessageQCopy_FOREVER :
                      timeout;

    dstProc = MultiProc_getId("HOST");
    handle->sem = Semaphore_create(1, NULL, NULL);

    MessageQCopy_init(dstProc);
    handle->msgq= MessageQCopy_create(MessageQCopy_ASSIGN_ANY,
                                      &handle->endPoint);
    if (!handle->msgq) {
        System_printf("IpcResource_connect: MessageQCopy_create failed\n");
        goto err;
    }

    NameMap_register("rpmsg-resmgr", handle->endPoint);

    /* Wait for the connection ack from the host */
    status = MessageQCopy_recv(handle->msgq, &ack, &len, &handle->remote,
                               handle->timeout);
    if (status) {
        System_printf("IpcResource_connect: MessageQCopy_recv "
                      "failed status %d\n", status);
        goto err_disc;
    }

    if (len < sizeof(ack)) {
        System_printf("IpcResource_connect: Bad ack message len = %d\n", len);
        goto err_disc;
    }

    status = _IpcResource_translateError(ack.status);
    if (status) {
        System_printf("IpcResource_connect: A9 Resource Manager "
                      "failed status %d\n", status);
        goto err_disc;
    }

    return handle;

err_disc:
    NameMap_unregister("rpmsg-resmgr", handle->endPoint);
    MessageQCopy_delete(&handle->msgq);
err:
    Memory_free(NULL, handle, sizeof(*handle));
    return NULL;
}