-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.cpp
51 lines (41 loc) · 1.24 KB
/
client.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
#include "xpipc.h"
#include "snex.h"
#include <cstdio>
int main(void) {
struct xpipc_shm shm;
if (!xpipc_shm_open("/snex-ppu", sizeof(struct snex_shared), &shm)) {
printf("%s\n", shm.last_error);
return 1;
}
struct xpipc_event ev_server_ready;
struct xpipc_event ev_client_ready;
if (!xpipc_event_open("/snex-server-ready", &ev_server_ready)) {
printf("%s\n", ev_server_ready.last_error);
return 1;
}
if (!xpipc_event_open("/snex-client-ready", &ev_client_ready)) {
printf("%s\n", ev_client_ready.last_error);
return 1;
}
struct snex_shared *snex = (struct snex_shared *) shm.mapped;
if (snex->version != 1) {
printf("error; snex version != 1; got %d\n", snex->version);
return 1;
}
for (;;) {
// wait for NMI syn:
if (!xpipc_event_wait(&ev_server_ready, 17)) {
printf("wait: %s\n", ev_server_ready.last_error);
continue;
}
printf("recv NMI syn\n");
// ack:
if (!xpipc_event_set(&ev_client_ready)) {
printf("set: %s\n", ev_client_ready.last_error);
continue;
}
printf("send NMI ack\n");
}
printf("done\n");
return 0;
}