-
Notifications
You must be signed in to change notification settings - Fork 215
/
erpc_rpmsg_linux_transport.cpp
69 lines (56 loc) · 1.49 KB
/
erpc_rpmsg_linux_transport.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* Copyright 2017 NXP
* Copyright 2021 ACRIOS Systems s.r.o.
* All rights reserved.
*
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "erpc_rpmsg_linux_transport.hpp"
#include <unistd.h>
using namespace erpc;
////////////////////////////////////////////////////////////////////////////////
// Code
////////////////////////////////////////////////////////////////////////////////
RPMsgLinuxTransport::RPMsgLinuxTransport(RPMsgEndpoint *endPoint, int16_t remote) :
Transport(), m_endPoint(endPoint), m_remote(remote)
{
}
RPMsgLinuxTransport::~RPMsgLinuxTransport(void) {}
erpc_status_t RPMsgLinuxTransport::init(void)
{
erpc_assert(m_endPoint != NULL);
return (m_endPoint->init()) ? kErpcStatus_Fail : kErpcStatus_Success;
}
erpc_status_t RPMsgLinuxTransport::send(MessageBuffer *message)
{
int retval;
retval = m_endPoint->send(message->get(), m_remote, message->getUsed());
return (retval > 0) ? kErpcStatus_Success : kErpcStatus_Fail;
}
erpc_status_t RPMsgLinuxTransport::receive(MessageBuffer *message)
{
int32_t ret;
erpc_status_t err;
while (true)
{
ret = m_endPoint->receive(message->get(), message->getLength());
if (ret == 0)
{
usleep(1); // 1us sleep
}
else
{
if (ret > 0)
{
err = kErpcStatus_Success;
}
else
{
err = kErpcStatus_Fail;
}
break;
}
}
return ret;
}