Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane-mv/blob/main/docs/external/nightdriver/666/harness/host/ndhost_modern.cpp # interplane-mv INTERPLANE: open interoperability protocol between AI models and agent runtimes. Models express intent. Runtimes retain authority. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane-mv / docs / external / nightdriver / 666 / harness / host / ndhost_modern.cpp` 69 lines ยท 2222 bytes Raw Blame History 1 // Host driver: runs the real SocketServer::Run() on Linux loopback. Written for this harness. 2 // Every line on stdout is machine-parsed by the Rust harness: 3 // LOG firmware debug output 4 // PKT cmd= len= fnv= a packet handed to ProcessIncomingData 5 #include "globals.h" 6 #include "socketserver.h" 7 #include "values.h" 8 #include "systemcontainer.h" 9 #include "nd_network.h" 10 #include 11 #include 12 #include 13 #include 14 15 int g_debugLevel = 1; 16 HostValues g_Values; 17 HostSystem g_hostSystem; 18 HostSystem* g_ptrSystem = &g_hostSystem; 19 std::mutex g_buffer_mutex; 20 21 void host_log(int level, const char* tag, const char* fmt, ...) 22 { 23 if (level > g_debugLevel) return; 24 char buf[512]; 25 va_list ap; va_start(ap, fmt); vsnprintf(buf, sizeof buf, fmt, ap); va_end(ap); 26 size_t n = strlen(buf); while (n && (buf[n-1] == '\n')) buf[--n] = 0; 27 printf("LOG %s %s\n", tag, buf); 28 } 29 30 namespace nd_network { 31 bool IsWiFiConnected() { return true; } 32 void SetSocketBlockingEnabled(int fd, bool blocking) 33 { 34 int fl = fcntl(fd, F_GETFL, 0); 35 fcntl(fd, F_SETFL, blocking ? (fl & ~O_NONBLOCK) : (fl | O_NONBLOCK)); 36 } 37 int GetWiFiRSSI() { return -50; } 38 } 39 40 extern "C" { 41 void uzlib_uncompress_init(struct uzlib_uncomp*, void*, unsigned) {} 42 int uzlib_zlib_parse_header(struct uzlib_uncomp*) { return -1; } // compressed path not exercised 43 int uzlib_uncompress_chksum(struct uzlib_uncomp*) { return -1; } 44 } 45 46 bool ProcessIncomingData(allocated_unique_ptr& p, size_t len) 47 { 48 uint32_t h = 2166136261u; 49 for (size_t i = 0; i < len; i++) { h ^= p[i]; h *= 16777619u; } 50 uint16_t cmd = p[0] | (p[1] << 8); 51 printf("PKT cmd=%u len=%zu fnv=%08x\n", cmd, len, h); 52 return true; 53 } 54 55 struct HostServer : SocketServer 56 { 57 using SocketServer::SocketServer; 58 using SocketServer::Run; 59 }; 60 61 int main(int argc, char** argv) 62 { 63 if (argc < 2) { fprintf(stderr, "usage: ndhost [debug-level]\n"); return 2; } 64 if (argc > 2) g_debugLevel = atoi(argv[2]); 65 setvbuf(stdout, nullptr, _IOLBF, 0); 66 HostServer s(atoi(argv[1]), NUM_LEDS); 67 s.Run(); // the real accept/read/dispatch loop; runs until the harness kills this process 68 return 0; 69 }