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_legacy.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_legacy.cpp` 69 lines ยท 2422 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 "soundanalyzer.h" 10 #include "nd_network.h" 11 #include 12 #include 13 #include 14 #include 15 16 int g_debugLevel = 1; 17 HostValues g_Values; HostAnalyzer g_Analyzer; HostWiFi WiFi; 18 HostSystem g_hostSystem; 19 HostSystem* g_ptrSystem = &g_hostSystem; 20 std::mutex g_buffer_mutex; 21 22 void host_log(int level, const char* tag, const char* fmt, ...) 23 { 24 if (level > g_debugLevel) return; 25 char buf[512]; 26 va_list ap; va_start(ap, fmt); vsnprintf(buf, sizeof buf, fmt, ap); va_end(ap); 27 size_t n = strlen(buf); while (n && (buf[n-1] == '\n')) buf[--n] = 0; 28 printf("LOG %s %s\n", tag, buf); 29 } 30 31 namespace nd_network { 32 bool IsWiFiConnected() { return true; } 33 void SetSocketBlockingEnabled(int fd, bool blocking) 34 { 35 int fl = fcntl(fd, F_GETFL, 0); 36 fcntl(fd, F_SETFL, blocking ? (fl & ~O_NONBLOCK) : (fl | O_NONBLOCK)); 37 } 38 int GetWiFiRSSI() { return -50; } 39 } 40 41 extern "C" { 42 void uzlib_uncompress_init(struct uzlib_uncomp*, void*, unsigned) {} 43 int uzlib_zlib_parse_header(struct uzlib_uncomp*) { return -1; } // compressed path not exercised 44 int uzlib_uncompress_chksum(struct uzlib_uncomp*) { return -1; } 45 } 46 47 bool ProcessIncomingData(std::unique_ptr& p, size_t len) 48 { 49 uint32_t h = 2166136261u; 50 for (size_t i = 0; i < len; i++) { h ^= p[i]; h *= 16777619u; } 51 uint16_t cmd = p[0] | (p[1] << 8); 52 printf("PKT cmd=%u len=%zu fnv=%08x\n", cmd, len, h); 53 return true; 54 } 55 56 struct HostServer : SocketServer 57 { 58 using SocketServer::SocketServer; 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 for (;;) { s.release(); if (s.begin()) { host_log(1, "I", "Socket server listening on port %s", argv[1]); s.ProcessIncomingConnectionsLoop(); host_log(1, "W", "Socket connection closed. Retrying..."); } delay(500); } // same shape as the firmware task entry 68 return 0; 69 }