03-31-2020 11:18 PM
Sorry - I think I must not have been clear.
The code I uploaded works for me too - and I can't manage to get the error I'm looking for when I change it.
For example, if I remove the Stop Task and place the Start before the For loop, then I get error -200557 (can't change Logging.TDMS.GroupName whilst task is running).
If I give invalid paths, I get either -201302 (file permission error) or -201309 (inaccessible, e.g. with an empty path).
In the real code, I get -201311 every time when trying to change the GroupName after the first run, but here it seems perfectly happy to change (provided the task is not running).
Since I can't reproduce the error in the simplified code, I can't check if I have the same issue (whatever that might be) in the more complicated code.
Conversely (and what I've spent more time doing), by simplifying the "real code", I've made it seemingly the same as this example code. But here I'd like to say "more or less", and clearly it isn't the same, since it always throws -201311 (needs exclusive access) when changing the group name.
If I put a disable structure around the changing of the group name, then the (real) code runs fine. But of course, then the group name doesn't change (at least in the supposedly desired way).
03-31-2020 11:22 PM - edited 03-31-2020 11:27 PM
Aha!
Putting a Control Task with "Commit" into the uploaded example before the For loop causes the error I expect.
So I suppose I have to find out how important Commit-ting the task is to the person I'm helping. And check it fixes the problem in the real code if I remove it...
Edit: So in the example code, "Commit" or "Reserve" both cause the error, "Verify" is fine. I modified the "real" code to use Verify, but now I get an error about pretrigger samples:
Error -200281
Possible reason(s):
Reading relative to the reference trigger or relative to the start of pretrigger samples position before the acquisition is complete.
Wait for the acquisition to complete before reading, or increase your read timeout. Also, make sure the hardware is set up and wired correctly, the signal for the reference trigger is correct, and that the reference trigger occurs while the device is acquiring data.
Property: RelativeTo
Corresponding Value: First Pretrigger Sample
Task Name: AnalogInputTask
Not sure why this is prevented by the Commit call, but I do think this might be something easier to fix.
03-31-2020 11:38 PM
Putting the commit in the For Loop after the Group name, no error for me.
I also couldn't get the error before the For Loop. Just Guessing here, this is @KevinPrice territory. Once the task is committed you may have problems changing it, commit should be the last thing before Run.
No error here
mcduff
03-31-2020 11:57 PM
And now the reason for one of the loops becomes clearer - it appears that this error will repeatedly appear until sufficient time has passed, and so using tunnels and a while loop allows me to call DAQmx Read or Wait (ms) based on available samples, and ignore the error in the previous message from all of the previous calls to Read.
04-01-2020 12:00 AM - edited 04-01-2020 12:02 AM
@mcduff wrote:
Putting the commit in the For Loop after the Group name, no error for me.
I also couldn't get the error before the For Loop. Just Guessing here, this is @KevinPrice territory. Once the task is committed you may have problems changing it, commit should be the last thing before Run.
No error here
mcduff
This highlights something else I didn't know (and still don't understand).
I saw in your previous post you had "Log and Read", "Off", "Log and Read", "Off".
If I set my input up that way, I also don't see the error.
Changing to some pattern with multiple "Log and Read" together produces the error.
So I guess having "Off", then calling DAQmx Read (and thus updating the behaviour as mentioned previously) and then changing is fine, whereas changing (in a Committed task) whilst the mode is "Log and Read" (even outside of Start/Stop section) is an error.
Edit: further information, setting "Unreserve" after the Stop allows me to put the Commit where you have it in the quoted screenshot without producing the error.
04-01-2020 12:05 AM
Glad you found the problem.
mcduff
04-01-2020 05:34 AM
This might help make some sense of this: DAQmx Task State Model