We've been using a Raspberry Pi — initially 4, now 5 — as the hub for a data acquisition system we've built. Initially the data acquisition all happened through the command line — essentially a shell script that calls a suite of compiled C++ code — but over time we needed to simplify the DAQ and ended up designing a web-based interface to make it easier for end-users.
The issue now is to find the most efficient way of doing this. What we have at present feels a little bit jerry-rigged in order to allow client-side control of server-side executables. The current setup is:
* Apache web server installed on Pi to serve web pages
* Data acquired over USB with compiled C++ binary called from shell script
* D3 Javascript library to display live data on appropriate web page
* PHP on Pi web server to call shell scripts to begin data acquisition
* PHP triggered by XMLHttpRequest tied to button on web page
* Acquired data parsed by PapaParse from Javascript to allow live display with D3
So there's quite a lot of coding scaffolding to get the compiled binaries to acquire the data and D3 to display the acquired data live.
The question is: is there a more efficient way of doing this? The main issue we have is that the display — which should run at 25Hz — experiences a lot of slowdown and we will potentially move to a less powerful CPU in future, which will almost certainly exacerbate the problem.
I was recently told that there is a web server within Python, but it only serves static pages: not so useful when we need something that displays data that is continuously updating at 25 Hz. If I want to pursue this Python route it looks like Flask is the tool for creating web apps, but given I've no experience with it, I've no idea if it will be up to the task.
The requirements are:
* Acquisition of data using compiled C++ binaries. Shell scripts are useful to control this as it makes parsing input variables easier, but isn't essential.
* Live display of acquired data through a web browser, plus control of acquisition start/stop — ideally with a button — plus ability to set a number of input variables for the C++ code and display of error messages output by said code.
* Acquired data arrives at 25Hz and consists of 3 x 128 value arrays for 2 bar graphs (they share X data) and 3 x 1200 value arrays for 2 line graphs (that also share X data).
Very much open to suggestions!
The issue now is to find the most efficient way of doing this. What we have at present feels a little bit jerry-rigged in order to allow client-side control of server-side executables. The current setup is:
* Apache web server installed on Pi to serve web pages
* Data acquired over USB with compiled C++ binary called from shell script
* D3 Javascript library to display live data on appropriate web page
* PHP on Pi web server to call shell scripts to begin data acquisition
* PHP triggered by XMLHttpRequest tied to button on web page
* Acquired data parsed by PapaParse from Javascript to allow live display with D3
So there's quite a lot of coding scaffolding to get the compiled binaries to acquire the data and D3 to display the acquired data live.
The question is: is there a more efficient way of doing this? The main issue we have is that the display — which should run at 25Hz — experiences a lot of slowdown and we will potentially move to a less powerful CPU in future, which will almost certainly exacerbate the problem.
I was recently told that there is a web server within Python, but it only serves static pages: not so useful when we need something that displays data that is continuously updating at 25 Hz. If I want to pursue this Python route it looks like Flask is the tool for creating web apps, but given I've no experience with it, I've no idea if it will be up to the task.
The requirements are:
* Acquisition of data using compiled C++ binaries. Shell scripts are useful to control this as it makes parsing input variables easier, but isn't essential.
* Live display of acquired data through a web browser, plus control of acquisition start/stop — ideally with a button — plus ability to set a number of input variables for the C++ code and display of error messages output by said code.
* Acquired data arrives at 25Hz and consists of 3 x 128 value arrays for 2 bar graphs (they share X data) and 3 x 1200 value arrays for 2 line graphs (that also share X data).
Very much open to suggestions!
Statistics: Posted by profjolly — Wed Aug 06, 2025 5:00 pm — Replies 0 — Views 49