09-14-2010 03:57 AM
Successfully installed NI-DAQmxBase 3.3 on Red Hat EL4
I am trying to write a standard linux daemon program talking with USB-6501 card. If I run this program as simple background process, it works well.
If I daemonize the process in the standard way (fork() and terminate parent), it does not work. The process aborts the first time it attempts to talk with the card.
My hypothesis is that the problem is related to lack of multithread support in NI-DAQmxBase, what do you think ?
Following is the piece of code that daemonize/not_daemonize the process
if ( DAEMONIZE == 1 ) {if(getppid()==1) return; /* already a daemon */i=fork();if (i<0) exit(1); /* fork error */if (i>0) exit(0); /* parent exits *//* child (daemon) continues */setsid(); /* obtain a new process group */}
Many thanks,
Pino
09-14-2010 10:47 AM
Unfortunately NI Core driver component that DAQ depends on does not work with fork() due to the way the driver works. We do support multi-threading, but fork() creates another process container without notifying the driver and our driver gets confused. If you want to do fork(), call it before loading NI driver stack.
09-14-2010 01:59 PM
Some correction actually. With using DAQmx Base for USB devices it just uses the user-mode USB interface and does not actually go down and hit the NI Core driver component. So I don't know why you are hitting the issue to help you out, but is at least not exactly what Irwan is pointing out.
Hopefully somebody who has tried this with VISA could say better...
09-15-2010 02:35 AM
First of all, many thanks for your replies. I was able to see them only opening the RSS link and I do not know why, but this is another issue related to this forum tool.
Back to my question.
If you want to do fork(), call it before loading NI driver stack
Do you mean initialize NI device after the fork() ? I tried it but it did not work. It is possibile that I made some other mistake, I will check better.
Hopefully somebody who has tried this with VISA could say better
As you probably have understood, this is my first use of NI device. Could you please help me to find my bearings ? ... What is VISA ?
Best regards,
Pino
09-15-2010 08:36 AM
picolu wrote:
As you probably have understood, this is my first use of NI device. Could you please help me to find my bearings ? ... What is VISA ?
Hi Pino,
There's a good overview of what VISA is here: http://cnx.org/content/m12288/latest/
And a tutorial here: https://www.ni.com/support/visa/vintro.pdf
09-15-2010 09:09 AM
Thanks,
Pino
09-15-2010 09:11 AM
And as a further clarification for relevance to this discussion. I mentioned VISA because that is what DAQmx Base uses for the operations you are doing. Really, it could be in DAQmx Base or VISA causing this problem.
09-15-2010 03:27 PM
Looks like I was wrong and you're not actually using NI Core Driver.. But for what it's worth, what I meant by:
If you want to do fork(), call it before loading NI driver stack
is to call fork() even before the process loads any of NI driver shared library. Potentially this means that you need to bundle your app in another shared lib, that's called by a wrapper executable that does fork() before loading your main shared lib and execute whatever you need to do.
06-30-2011 05:39 AM
Hello,
Sorry for disturbing this thread but it's very interresting for my own problem, when i bundle my working code into a shared library, DAQmxBaseReadAnalogF64 never update samplesNread, so you dont know how many sample be readed !!! Here is a sample to reproduce the probleme over 4th OS : https://decibel.ni.com/content/message/24454
I need help.
Thanks in advance
Rom1nux