==> src/main.c <==1/* mesh-top-mock (crates/mesh-top examples/mock_meshd.rs): a mock meshd control port for trying
2 * mesh-top without a GPU: `mesh-top-mock 127.0.0.1:47700 dgx-00 0`. The data is synthetic (see
3 * @ajax/mesh-top-mock); it is a viewer fixture only. */
4#include "mesh/top_mock.h"
5
6#include <stdio.h>
7#include <stdlib.h>
8#include <unistd.h>
9
10int main(int argc, char **argv) {
11 const char *addr = argc > 1 ? argv[1] : "127.0.0.1:47700";
12 const char *host = argc > 2 ? argv[2] : "mock";
13 uint64_t sys;
14 uint32_t system = argc > 3 && mt_parse_u64(argv[3], &sys) && sys <= UINT32_MAX ? (uint32_t)sys : MESH_PEER_NONE;
15 mt_mock *m = mt_mock_start(addr, host, system);
16 if (!m) {
17 fprintf(stderr, "mesh-top-mock: cannot listen on %s\n", addr);
18 return 1;
19 }
20 /* doom's node 2 stalls, so the node grid's red state is visible. */
21 mt_mock_lock(m);
22 mt_mock_world *w = mt_mock_world_of(m);
23 snprintf(w->stalled[w->nstalled].name, sizeof w->stalled[0].name, "doom");
24 w->stalled[w->nstalled++].node = 2;
25 mt_mock_unlock(m);
26 printf("mock meshd (%s, system %u) on %s -- synthetic data, not a GPU\n", host, system, mt_mock_addr(m));
27 fflush(stdout);
28 for (;;) pause();
29}