I have to interact with an existing TCP/IP server which transfers binary data structures corresponding to c-struct.
One example struct is encoded as
struct DATSETTING{ /* MCS data settings */
int32_t savedata; // bit 0: auto save after stop
// bit 1: write listfile
// bit 2: listfile only, no evaluation
int32_t autoinc; // 1 if auto increment filename
int32_t fmt; // format type (seperate spectra):
// 0 == ASCII, 1 == binary,
// 2 == CSV
int32_t mpafmt; // format used in mpa datafiles
int32_t sephead; // seperate Header
int32_t smpts;
int32_t caluse;
char filename[256];
char specfile[256];
char command[256];
};
I have been using AJAX calls through PHP to run external c-software on the server side to communicate with the TCP/IP server, process this information, and display it on a web page. However, I would like to transition to Node.js on the server side and only use JavaScript to make the entire project a little more tidy. However, I cannot figure out how to process such a data structure using JavaScript. Is there some package available to automagically convert it to JSON? Or is there some other standard technique for dealing with this?
Modifying the TCP/IP server is out of the question, as it is part of a commercial system and I do not have access to the source code for it