09-08-2007 08:51 PM
09-10-2007 12:32 AM - edited 09-10-2007 12:32 AM
Hi amonson,
I think if you pre-allocate an array in LabVIEW, and pass the array to your DLL, then update the array in the DLL, a LabVIEW "Monitor-loop" reading the array, will see the updates even while the DLL is executing.
The reason this could work is that arrays are passed to the DLL by reference, so the DLL is updating LabVIEW's memory-space, and if LabVIEW hasn't made a copy of the array for your "Monitor-loop", it'll show you exactly the same memory your DLL is updating! Sound like a good theory? ![]()
Cheers!
Message Edited by tbd on 09-10-2007 12:33 AM
09-10-2007 01:12 AM - edited 09-10-2007 01:12 AM
Message Edited by altenbach on 09-09-2007 11:15 PM
09-10-2007 01:39 AM
Hi Altenbach,
As I understood amonson, the essential problem is how to get data out of the CIN - without waiting for it to finish executing. I think this can be done by passing the CIN a reference. I always thought the CIN was much like a DLL function - they're both compiled C functions (and can update values by reference) - am I mistaken? ![]()
Cheers.
09-10-2007 02:24 AM
btw, In this context, reference => "pointer", a memory location, this is how C passes arrays and structures, and how LabVIEW passes arrays when "array data pointer" (the default) is chosen in a DLL's CLF. I'm sure the CIN gets a pointer when an array is passed-in (so it can update LabVIEWs data), but perhaps there's a more elegant solution. ![]()
Cheers.
09-10-2007 11:47 AM
09-10-2007 01:28 PM
Hi amonson,
If I understand, you're passing a LabVIEW String to the CIN (passed by reference). I believe this means LabVIEW needs to allocate the memory for the string that your CIN will write to. What's the length of the string you're passing to the CIN, and is it long enough to accommodate any message the CIN might try to copy to it?
Cheers.
09-10-2007 03:16 PM
09-10-2007 04:22 PM - edited 09-10-2007 04:22 PM
Hi amonson,
> I would like to pass the response to labview without the need to exit the CIN.> It would also be great if I could incorporate a stop button in the vi that when pressed would cause the CIN to break the loop.
I'm sure you can do this, but I've only had experience with C and DLLs - so you'll have to have patience. ![]()
When you define the CIN, can you choose to pass a pointer-to-value for a numeric Input? If so, then to stop your CIN, pass in a numeric, by pointer, then have your CIN watch that input for a specific value. Set the value of the control in LabVIEW and the CIN should see it change.
I'd use the same technique to update a string, though I'm not sure how CINs see string-inputs, for instance, does LabVIEW send a pointer to a "String" structure with length-bytes first? To keep it simple, I'd pass the CIN an array of (32) U8, and have the CIN populate it like a char[32]. In LabVIEW, poll the array of U8 for changes and write new contents to the FP. You may need to truncate the [U8]/string at a null character. ![]()
Cheers!
P.S. If you pass in an array of 32 U8s, make sure your Response is limited to 32 characters. (it looks like sizeof(buffer) will work assuming the declaration "char buffer[32]".)
Message Edited by tbd on 09-10-2007 04:30 PM
09-11-2007 12:52 AM - edited 09-11-2007 12:52 AM
Message Edited by tbd on 09-11-2007 12:53 AM