03-30-2012 05:31 AM
Sorry about that, when you have been staring at something for so long you forget that other people haven't.
The computer has two cores, I tried to install the drivers for the serial card on a 4 core computer with windows 7, but the drivers for the serial card doesn't work.
I'm using a SIO4 card from General Standards.http://www.generalstandards.com/view-products2.php?BD_family=sio4b. The sensor I'm reading from uses SDLC protocol and sends 400 * 28byte packages per second (11,4k bytes). The FIFO on the card is 512 bytes. The card takes care of all the low level stuff, so I just have to call the read VI often enough to get out the data.
The stacked sequence is very similar to what you will find in this demo from the vendor http://www.generalstandards.com/downloads/gsc_sio4b_bx_sync_labview_v1.2.9.zip
It's just opening a connection with the card, setting the protocol and some registers.
The two sub VI's contain dlls, so I don't know what's in them. They were made by the vendor.
The upper while loop waits up 5 seconds (or rather the VI in the loop does) for a package to be ready in the card FIFOs. If data is ready it returns with the data immediately.
I understand it's difficult to debug without knowing what's in the VI's, but from what I can understand, it must be that the FIFOs on the card are to small. I guess scrolling the mouse wheel uses a lot of CPU time. Or at least more than 44ms.
Thanks again
03-30-2012 07:52 AM
dll calls will run in the User Interface thread by default. So check to see how the dll calls are configured(right-click the node on the diagram).
If they aren't running in tht UI thread forget me.
Ben
03-30-2012 08:13 AM
Yes, the dll is run in UI thread. Should I change this to "any thread" ?
03-30-2012 08:18 AM
Only if the dll was developed to be thread-safe.
You will have to check wiht the developer of the dll to find that answer.
I believe it was rolf Kalbermatter who posted years ago, that if the dll is not thread-safe and you call it other threads, it MAY work right up until your app crashes.
Ben
03-30-2012 09:58 AM - edited 03-30-2012 10:03 AM
@q-bertsuit wrote:
Yes, the dll is run in UI thread. Should I change this to "any thread" ?
Wow, I was suspecting that this is your problem, but I was waiting for you to tell us that their "driver" is using a third party DLL. I've looked at the example program from general standards and it is absolutely deplorable.
The sad part is that they don't even know how to spell LabVIEW on their download page! This alone makes me very suspicious.
The example VI is horrible. Looking at the revision number we are on revision 431. Looks like this driver started in the last century and they probably had some random summer intern straight from high school and without much formal LabVIEW training have a stab at it, with other interns making revisions over the years.
Notable observations:
Chances are that the dll itself was written by a much better programmer (who knows???) and is is possible that it is safe to call in other threads. Don't change anything before checking with them, though. I would recommend to contact General Standards to see if the dll is safe. Point them to this discussion here! 😄
(For a similarly careless configuration example of third party drivers, the LabVIEW drivers for Phidgets are incorrectly using the UI thread configuration of the call, probably just because it is the LabVIEW default, even though the dll is claimed to be much more robust (see also)).
(On a side note, did you copy over the llb to the correct place as instructed in the readme file?
Quote: This zip archive also includes an updated LabView library, GscApiLabView.llb that includes some
fixes that were causing occassional program crashes. After installation, replace the GscApiLabView.llb
in the %PROGRAMFILES%\General Standards Corporation\GscApiLabView\SIO4B directory with the one in
this zip archive dated 2011/03/15.)
03-31-2012 05:42 AM
Being a novice LabVIEW programmer, I didn't really question the demo program at first, I just thought to my self that it would have been poor style in other programming languages. Especially point 10 on your list is a real give away that this hasn't been thought trough. From one of the emails I sent with General Standars I got a hint that this isn't really a priority for them:
"Chances are, that driver is too old to work on Windows 7. We don't have very many customers using the serial card with LabView but the ones who do seem to be working fine. If you change the code to simply log to memory rather than a file, do you still see this problem when you move the mouse, etc? Just running the sample code here (that only saves to memory), I can't duplicate the problem."
I'm under the impression that the dll's are made by a better programmer. You can find their APIs and some C code examples on their page as well, and they all seem pretty solid.
Yes, I copied the new llb, but there are still some crashes here and there. Very often when you close the program there will be a crash and often a minor change in the code will make it crash when executed.
I was offered a loaner board with much bigger FIFO's to see if it fixes the problem. I will except their offer, but it would still be nice to do everything properly. Even if it fixes the problem, there are still a lot of redundancy in the code and other problems that you have pointed out, that would need to be fixed anyway.
I'll talk to them bout the dll's tomorrow or Monday, and let you know what they say. Thank you again for taking the time to look in to all of this, much appreciated!