A little post to support building the sources on a Pi, from command line.
If you prefer to use precompiled binaries, they are available on github)
I'm developing the software on a Windows PC, with Eclipse and a cross compiler. As you can see below, it can be compiled native on the Pi too.
The 3 executables are:
- Instrument Service
- Dummy Instrument Service
- SCPI Service
For the instrument service, choose #2 if you don't have a hat, or want to experiment. Choose #1 if you have a MCC172 hat and want to automate it.
Choose #3 if you want to have SCPI compatibility. Required if you're working with the LabVIEW driver
Preparation:
get boost libraries:
sudo apt-get install libboost-all-dev
Create a directory for this project
(any directory will do)
mkdir ~/daqhats
Get the source
cd ~/daqhats
git clone https://github.com/jancumps/daqhats_scpi_service.git
Build Dummy Instrument Service.
This is the option you choose when you don't have a DAQ hat but want to evaluate the LabVIEW driver. It emulates the instrument.
Build
cd ~/daqhats
cd daqhats_scpi_service
cd daqhats_dummy_service
# compile
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o "src/main.o" "src/main.cpp"
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o "src/DaqHatInstrument.o" "src/DaqHatInstrument.cpp"
#link
g++ -o daqhats_dummy_service "src/DaqHatInstrument.o" "src/main.o" -lpthread -lboost_system -lboost_chrono
#make executable
chmod +x ./daqhats_dummy_service
Execute:
~/daqhats/daqhats_scpi_service/daqhats_dummy_service/daqhats_dummy_service 2501 2502 0
Build Real Instrument Service
This is the option you choose when you have a DAQ hat. No emulation, the real service.
Prerequisite: the supplier's software is installed as instructed on the GitHub page.
Build
cd ~/daqhats
cd daqhats_scpi_service
cd daqhats_service
#compile
g++ -std=c++2a -O0 -g3 -Wall -c -fmessage-length=0 -o "src/DaqHatInstrument.o" "src/DaqHatInstrument.cpp"
g++ -std=c++2a -O0 -g3 -Wall -c -fmessage-length=0 -o "src/main.o" "src/main.cpp"
#link
g++ -o daqhats_service "src/DaqHatInstrument.o" "src/main.o" -ldaqhats -lpthread -lboost_system -lboost_chrono
#make executable
chmod +x ./daqhats_service
Execute:
~/daqhats/daqhats_scpi_service/daqhats_service 2501 2502 0
Build SCPI Service
This is required if you want to control the instrument (or dummy) via LabVIEW or other SCPI client.
Get SCPI lib and copy files to project
cd ~/daqhats
git clone https://github.com/j123b567/scpi-parser.git
cd daqhats_scpi_servicecd daqhats_scpi_socket
cd src/scpi
cp -r ../../../../scpi-parser/libscpi/src/* .
cd ../../inc/scpi
cp -r ../../../../scpi-parser/libscpi/inc/scpi/* .
Build
cd ~/daqhats
cd daqhats_scpi_service
cd daqhats_scpi_socket
#compile
gcc -I "./inc" -O0 -g3 -Wall -c -fmessage-length=0 -o "src/scpi/utils.o" "src/scpi/utils.c"
gcc -I "./inc" -O0 -g3 -Wall -c -fmessage-length=0 -o "src/scpi-def.o" "src/scpi-def.c"
gcc -I "./inc" -O0 -g3 -Wall -c -fmessage-length=0 -o "src/scpi/parser.o" "src/scpi/parser.c"
gcc -I "./inc" -O0 -g3 -Wall -c -fmessage-length=0 -o "src/scpi/error.o" "src/scpi/error.c"
gcc -I "./inc" -O0 -g3 -Wall -c -fmessage-length=0 -o "src/scpi/minimal.o" "src/scpi/minimal.c"
gcc -I "./inc" -O0 -g3 -Wall -c -fmessage-length=0 -o "src/linux_scpi_socket.o" "src/linux_scpi_socket.c"
gcc -I "./inc" -O0 -g3 -Wall -c -fmessage-length=0 -o "src/scpi/expression.o" "src/scpi/expression.c"
gcc -I "./inc" -O0 -g3 -Wall -c -fmessage-length=0 -o "src/scpi/fifo.o" "src/scpi/fifo.c"
gcc -I "./inc" -O0 -g3 -Wall -c -fmessage-length=0 -o "src/scpi/lexer.o" "src/scpi/lexer.c"
gcc -I "./inc" -O0 -g3 -Wall -c -fmessage-length=0 -o "src/scpi/units.o" "src/scpi/units.c"
gcc -I "./inc" -O0 -g3 -Wall -c -fmessage-length=0 -o "src/scpi/ieee488.o" "src/scpi/ieee488.c"
#link
g++ -o daqhats_scpi_socket "src/linux_scpi_socket.o" "src/scpi/error.o" "src/scpi/expression.o" "src/scpi/fifo.o" "src/scpi/ieee488.o" "src/scpi/lexer.o" "src/scpi/minimal.o" "src/scpi/parser.o" "src/scpi/units.o" "src/scpi/utils.o" "src/scpi-def.o"#make executable
chmod +x ./daqhats_scpi_socket
Execute:
~/daqhats/daqhats_scpi_service/daqhats_scpi_socket/daqhats_scpi_socket 2500 2501
Link to all posts.