LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a DLL

In this VI, the DLL doesn't have the 'size of the array' as separate parameter.
What are the 'problems' using this VI in a while loop?
0 Kudos
Message 1 of 9
(4,159 Views)
That depends very much on what that function is expecting. If you can supply some more information, we could be a little more specific. However, going with some basic assumptions...

The signature, according to the DLL node, is

long Read_Next_Data_RTx(long arg1, unsigned short int arg2, unsigned short int arg3, unsigned short int *arg4, long *arg5);

and arg3 has the "Num Data Words" wired to it, so I assume we are telling the function how large the array is. However, you also then initialize the size of the array to 5 times that.

Since the function isn't taking a double pointer for an argument, it doesn't seem to be allocating memory - at least for the array proper...

So, it seems like you are preallocating the read buffer in LabVIEW and passing that memory to the C routine. If it is expecting 16-bit integers of size arg3, you are giving it an array 5 times that size. If it is expecting some other sort of data structure, it would depend what that was...

I have no idea what the overwrite flag is telling us.

If what I said is correct, there aren't any problems doing this in a loop. You could be more efficient with the memory (such as not allocating it each loop) and such, but it would work.

However, this is a lot of guess work on my part. Any chance of getting more information on the function.
Message 2 of 9
(4,143 Views)
Thank you for the answer.
I don't have the function, I have to use this VI and I have this problem:
I'm reading for example messages( each message has 8 words), first word has the label FF, the rest label 8.
When I'm reading a new message the FIRST word with label FF is from the last message and the words with the label 8 are from the new message; only the third message is correct, the new word with the label FF and the new words with the label 8 are from the new message.
0 Kudos
Message 3 of 9
(4,142 Views)
Do you have any documentation for this method, especially the parameter information? I am not sure what is going on but that would be helpful.

Also, when you are doing this multiple times (you mention 3 messages), are you just rerunning the VI or are you running a modified VI from the one you posted?
Message 4 of 9
(4,125 Views)
Input parameters: handle, channel=0, num_data_words=number of 32-bit words to read
Output parameters: msgptr=data returned; overwritten: old data overwritten by new data.

Here is not the size of the array!

The msgptr is an array of 16-bit words, and from 5 X 16-bit words I'll have 1 num_data_word(32-bit); that's why they did x5.
I'm using this VI only.
0 Kudos
Message 5 of 9
(4,117 Views)
I'm sorry, but I'm a bit confused by your reply.

1. overwritten - I am assuming it means that data was lost from the internal buffer? I hope that it is an internal buffer and they are not doing something with the buffer you are sending in. Is there any more documentation (PDF, link, something)?

2. "Here is not the size of the array!" What? I don't know what you're saying.

3. Okay, so the array is actually an array of 32-bit values. I am not sure why you are passing a U16 array, but okay. Since it would only take x2 to get the 32-bits, I don't understand the "from 5 X 16-bit words I'll have 1 num_data_word(32-bit); that's why they did x5." Where is the 5 coming from?

4. Is there any C based test program that you can try? Any C based example you can email me? The DLL node looks fine based on what you have said so far so I am wondering if we are dealing with a configuration or device error.
Message 6 of 9
(4,107 Views)
I don't have the C code of the function or something similar with what I'm doing.
Everything is in a while loop, I'm reading messages with 3 to 9 words; are a lot of messages.
I read them in a text file, each message with a time stamp; from text file I transfered them with Active X in an Excel file and from there I trasfered them in an Access database.

If I put a delay in the while loop the program is running better but I have overwritten problem.
0 Kudos
Message 7 of 9
(4,084 Views)
I hate to be single-minded about this, but we are jumping around a bit.

The VI you posted does not have a while loop and you only talked about reading the example message which always had 8 words (I assume are 32-bits). You are calling a driver of some sort that has a C interface. Before moving forward to anything regarding ActiveX, Excel, Text files, etc. I would like to stay on the one VI you posted and see about getting that working.

I am also making an assumption that when you talked about the three read messages, you were running the posted VI three times. If that is incorrect, please let me know. I want to stay with that one VI until we have it working.

Is this a custom piece of hardware or did you purchase it? If you purchased it, can you tell me what it is? There must be a manual somewhere for this thing.
Message 8 of 9
(4,071 Views)
Brian,

I sent to you an e-mail with more information.
0 Kudos
Message 9 of 9
(4,061 Views)