aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2017-04-17 15:06:25 -0400
committerPaul Selkirk <paul@psgd.org>2017-04-17 15:06:25 -0400
commit22a58216681df01d20cfa0a5cfc5c49d15e6c606 (patch)
treec51681486dbb77e68f271761adc94f1d473c81f8 /tests
parentc2820e99c1e3115a7b1ba0d993eb6b665fa73c17 (diff)
Move hal_rpc_server_main() to test code.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-rpc_server.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test-rpc_server.c b/tests/test-rpc_server.c
index b0b2fd0..9736cc1 100644
--- a/tests/test-rpc_server.c
+++ b/tests/test-rpc_server.c
@@ -1,5 +1,26 @@
#include <hal.h>
+#define interrupt 0
+
+static uint8_t inbuf[HAL_RPC_MAX_PKT_SIZE], outbuf[HAL_RPC_MAX_PKT_SIZE];
+
+static void hal_rpc_server_main(void)
+{
+ size_t ilen, olen;
+ void *opaque;
+ hal_error_t ret;
+
+ while (!interrupt) {
+ ilen = sizeof(inbuf);
+ ret = hal_rpc_recvfrom(inbuf, &ilen, &opaque);
+ if (ret == HAL_OK) {
+ olen = sizeof(outbuf);
+ if (hal_rpc_server_dispatch(inbuf, ilen, outbuf, &olen) == HAL_OK)
+ hal_rpc_sendto(outbuf, olen, opaque);
+ }
+ }
+}
+
int main (int argc, char *argv[])
{
if (hal_rpc_server_init() != HAL_OK)