Skip to content

Commit f0de577

Browse files
committed
First tests on function RPC
Please restructure the callback code (that right now is pure shit)
1 parent c82dbba commit f0de577

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

Diff for: cores/arduino/RPC.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include "RPC.h"
44

5+
extern int signal_rpc_available(void *data, size_t len);
6+
57
int RPC::rpmsg_recv_service_callback(struct rpmsg_endpoint *ept, void *data,
68
size_t len, uint32_t src, void *priv)
79
{
@@ -10,6 +12,9 @@ int RPC::rpmsg_recv_service_callback(struct rpmsg_endpoint *ept, void *data,
1012
if (s->code == REQUEST_REBOOT) {
1113
NVIC_SystemReset();
1214
}
15+
if (s->code == CALL_FUNCTION) {
16+
signal_rpc_available(s->data, len - sizeof(s->code));
17+
}
1318
return 0;
1419
}
1520

@@ -77,7 +82,12 @@ size_t RPC::write(uint8_t c) {
7782
}
7883

7984
int RPC::request(service_request* s) {
80-
return OPENAMP_send(&rp_endpoints[0], s, sizeof(*s) + s->length);
85+
return OPENAMP_send(&rp_endpoints[0], s, sizeof(*s));
86+
}
87+
88+
size_t RPC::write(enum endpoints_t ep, const uint8_t* buf, size_t len) {
89+
OPENAMP_send(&rp_endpoints[ep], buf, len);
90+
return len;
8191
}
8292

8393
arduino::RPC RPC1;

Diff for: cores/arduino/RPC.h

+10-3
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,23 @@ extern "C" {
1010
#define boolean boolean_t
1111
#include "openamp.h"
1212
#undef boolean
13+
#ifdef bool
1314
#define boolean bool
15+
#endif
1416
}
1517

18+
enum endpoints_t {
19+
ENDPOINT_SERVICE = 0,
20+
ENDPOINT_RAW
21+
};
22+
1623
enum service_request_code_t {
1724
REQUEST_REBOOT = 0x7F7F7F7F,
1825
CALL_FUNCTION = 0x12345678,
1926
};
2027

2128
typedef struct _service_request {
2229
enum service_request_code_t code;
23-
size_t length;
24-
size_t parameters;
2530
uint8_t* data;
2631
} service_request;
2732

@@ -45,6 +50,8 @@ class RPC : public Stream {
4550
size_t write(uint8_t c);
4651
size_t write(const uint8_t*, size_t);
4752
int request(service_request* s);
53+
size_t write(enum endpoints_t ep, const uint8_t* buf, size_t len);
54+
4855
using Print::write; // pull in write(str) and write(buf, size) from Print
4956
operator bool() {
5057
return initialized;
@@ -68,4 +75,4 @@ extern arduino::RPC RPC1;
6875

6976
#endif
7077
#endif
71-
#endif
78+
#endif

0 commit comments

Comments
 (0)