10-08-2019 04:03 AM
Hi ,
I've a python script which writes a file periodically (every 2 seconds) . When I run this python script from command prompt or using IDLE, the file is updated periodically and I can read the file.
But when I run the same python script using system exec VI in LabVIEW context. It doesn't update the file periodically and updates the file when it got terminated. So because of this I can't plot my data in run-time.
Let me know if there is any other way of doing this.
Solved! Go to Solution.
10-08-2019 04:15 AM - edited 10-08-2019 04:16 AM
Set 'Wait Until Completion' input to False.
An alternative would be to create a BAT file of your command, then call the BAT file using system exec.vi
10-08-2019 06:18 AM
10-09-2019 04:27 AM
Problem solved as I was not using "f.flush()" and "os.fsync(f.fileno())". After adding this I was able to resolve the issue I was facing. It was not a issue with System Exec. Now I can read the file and plot the data as I need. Thanks for pointing out "Wait untill Completion". I need to set it to false because I want to let the script run and don't want to wait for its completion.
def write_csv(*args):
my_str= str(args[1]) + "," + ",".join(args[2]) + "\n"
#print (my_str)
file_handle = args[0]
file_handle.write(my_str)
file_handle.flush()
os.fsync(file_handle.fileno())