-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnetbsdvaxproxy.cpp
More file actions
41 lines (33 loc) · 1.17 KB
/
netbsdvaxproxy.cpp
File metadata and controls
41 lines (33 loc) · 1.17 KB
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
#include "netbsdvaxproxy.hpp"
#include <cstring>
// Packet structure definitions - use tight packing to match network protocol
#pragma pack(push, 1)
struct netbsdvax_panel_state
{
uint32_t ps_address; /* panel switches - 32-bit address */
uint32_t ps_data; /* panel lamps - 32-bit data */
};
struct netbsdvax_panel_packet
{
panel_packet_header header;
netbsdvax_panel_state panel_state;
};
#pragma pack(pop)
NetBSDVAXProxy::NetBSDVAXProxy(unsigned short port)
: ProxyBase(port)
{
// Debug: Print structure sizes to verify pragma pack worked
log_info("Structure sizes: header=%zu bytes, panel_state=%zu bytes, total_packet=%zu bytes",
sizeof(panel_packet_header), sizeof(netbsdvax_panel_state), sizeof(netbsdvax_panel_packet));
}
std::string NetBSDVAXProxy::udp_packet_to_json(std::span<const char> data)
{
// Parse the NetBSD VAX panel state
netbsdvax_panel_state panel_state;
if (!get_panel_state(data, panel_state))
return "";
crow::json::wvalue json;
json["address"] = panel_state.ps_address; // Full 32-bit address
json["data"] = panel_state.ps_data; // Full 32-bit data
return json.dump();
}