LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView FPGA C API FIFO Read Crashing

Solved!
Go to solution

I am trying to read a FIFO that I have configured as Target to Host - DMA.   When I run the following code on the same thread that calls NiFpga_Initialize() and NiFpga_Open() the following code works; if I call it from a worker thread (I guarantee that the session hasn't been closed or NiFpga_Finalize() called) it crashes the program.

 

uint64_t buffer[4096];
size_t toRead;
NiFpga_ReadFifoU64(session, NiFpga_FirmwareSettings_TargetToHostFifoU64_MY_FIFO, buffer, 4096, NiFpga_InfiniteTimeout, &toRead));

Why would this crash in a worker thread but work correctly in the main thread?

 

0 Kudos
Message 1 of 3
(2,430 Views)

Going through my code this morning, I have two worker threads.  One reads from the FIFO.  The other waits on an IRQ and then reads a uint8 when the IRQ is triggered.  The crash only happens if both worker threads are running.

0 Kudos
Message 2 of 3
(2,383 Views)
Solution
Accepted by topic author Graz

I just noticed that both threads were being assigned to the same std::thread object.  This caused the crash.  The crash had nothing to do with the LabVIEW C API.

0 Kudos
Message 3 of 3
(2,379 Views)