01-29-2014 03:13 PM
So as the title says, I have a VI which is writing to a tdms file, and I want to send the file by gmail once the program has completed it's run. I downloaded gmail.vi and am integrating it into my existing code. Both my original code and the gmail VI work fine on their own, but when I try to have the combined VI send the data file by email, I get the error message that I've attached.
Basically, it seems like the .tdms data file is in use by the measurement code, and I need to know how to free it up so that the gmail code can attach and send it.
I've attached the main code as well as my modified gmail VI, so hopefully someone can take a look at tell me what I'm missing.
Any help is much appreciate!
01-29-2014 03:40 PM - edited 01-29-2014 03:41 PM
While I can't view all of your code because it is missing several SubVIs, I have a good idea of what you are trying to do. I believe the culprit is the "Write to measurement file" express VI. Near as I can tell the original reference to the TDMS file is being held open inside the express VI. Here's a good general rule for using Express VI's: when you see them, RUN THE OTHER WAY! I say because there is almost always a significant amount of code in there that is unnecessary, In this case, you simply need the Open TDMS file, Write to TDMS, Close file functions; you do not need all of the extra code that is in the express VI's.
<edit> P.S. I hope the username/password in Email alert.vi is a placeholder otherwise you just gave every idiot with access to LabVIEW your username and password to the account. 🙂
01-29-2014 03:43 PM
Thanks for the response Charles. I keep hearing that same message about expressVIs, but I find they're pretty helpful for a beginner like me...
Is there anyway to add a close TDMS or something outside of the expressVI? I'll look into converting it away from an expressVI at some point, but for now I just want to see if I can get it to go as is.
01-29-2014 03:45 PM
The easiest way is to right-click the express VI and choose "Open Front Panel". You'll get a nag message that you are about to lose the "express" functionality etc. Ignore this message and move on. You now have a VI that you can open, edit and save. Aside from that because the handle is hidden from you, you have no way to close the reference.
01-30-2014 09:10 AM
Thanks Charles, the converting away from an expressVI worked. I went into the resulting code and found a lock file constant which I switch from true to false, which let me attach and send the measurement file.
Any idea if there's any side-effects to doing that though?
01-30-2014 11:06 AM
In response to changing the lock file constant Boolean, it may not allow the VI to function properly, or have unseen effects that may cause problems elsewhere. Changing low-level code like that is risky unless you can find out exactly what the change will do.
Going back to your original error, it seems that the TDMS file you are trying to send is being used by another program (perhaps it isn't closed out by your VI yet) and you could try adding a wait function to ensure the file is finished writing and closed out before you try to call it up to send it through gmail.
01-30-2014 12:47 PM
Steve, I removed the ExpressVI abomination from your code and replaced it with native TDMS code. I'm not familiar with the ExpressVI used so I'm not sure that the output will be 100% correct but this should illustrate how easy it is to use the native TDMS.