This example demonstrates how you can use the FPGA Interface Python API to perform host-to-target and target-to-host communication with a compiled LabVIEW FPGA bitfile (.LVBITX). The idea for this example, as well as the LabVIEW project and bitfile are pulled directly from the existing FPGA Interface C API Example by ColdenR.
This example runs from the command line of the NI Linux Real-Time OS (this example specifically uses the CompactRIO-9068), and showcases the following:
Opening and closing FPGA Interface sessions
Reading to and writing from indicators and controls
Setting up, reading to, and writing from DMA FIFOs
Using IRQs for FPGA/Host synchronization
Integration with basic Python data logging techniques
2a. Connect via SSH OR the serial console and log in as an administrator (same link as above)
2b. Run these commands to install the FPGA Interface Python API:
3. Leaving your SSH or serial console open, transfer the example Python script (‘main.py’) and bitfile (‘MyBitfile.lvbitx’) to the Real-Time target (**note: if your target is not a cRIO-9068, you will have to recompile the FPGA VI for your specific target).
3a. Set up either WebDAV (recommended; default installation) or FTP.
3b. Move the files to any location on the Real-Time target (ensuring that they’re both in the same directory). On the example RIO, I placed these in the /home/lvuser directory:
4. In your SSH or serial session, navigate to the directory that you placed the files in and run the Python script: