Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

[beginner] "Write to Measurement File" problem

Hi

 

Yes, I'm using a serial cable for connecting two computers.

 

I did set a loop count in my code. While reading the data from another computer, sometimes I recieve an incorrect buffer of data and this cause writing to the file to start form the beginning. and when I check the loop count, at that instance it resets the while loop (i=0).

 

For solving this if I remove the part of my code where I empty the string for the first time it'll work fine, since when the while loop resets my string doesn't. But in this case is there any other way for empty-ing string?

 

Thanks for your time

0 Kudos
Message 11 of 14
(1,587 Views)

Hello Neo_Ev,

 

This is a little hard to understand without seeing the code you are working with. What string are you talking about? Do you initilize an empty string that you were then filling with the loop count? Or are you just feeding the loop iteration in as the information to send? 

 

Also are you still having issues or is it working now; as in, do you need to empty the string?

Jonathan L.
Technical Support Section Manager
National Instruments
0 Kudos
Message 12 of 14
(1,574 Views)

I save all the data I need into a string, then write the string to a text file. At every instance I append the string of instance (i) to the string of instance of (i-1). When I initialize the code I want to have an empty string. So I use the loop count of while loop to do this. (if loop count is zero then I empty the string).

 

But if while I'm reading the data, I get an incorrect data buffer, the while loop will reset and the loop count will go to zero. So it will empty my string and all the data I had saved (appended to the string) will be lost.

 

I want to empty the string only when I  initialize the code and not when the while loop resets. How should I do it?

 

Thanks

0 Kudos
Message 13 of 14
(1,567 Views)

Hello Neo_Ev,

 

If you want to initalize the string just once then move it outside the while loop and feed it in. It will feed an empty string into the while loop that can then be appended to on each iteration of the loop. 

Jonathan L.
Technical Support Section Manager
National Instruments
Message 14 of 14
(1,557 Views)