VDT2 Data Reading Differences between Terminal Port and Command Port
Tue, 07/24/2012 - 07:14 am
I am reading data from a Keyence laser displacement sensor using VDT2 and I am having trouble reading the data output stream and I am getting different results when using the the terminal port and the command port. I had the system running on an XP based system a while back without issue and the current one is a Windows 7 machine. The XP based machine is no longer available. The basic code was just carried over from the XP machine.
For the Keyence sensor, the basic commands are:
VDTWrite2 "DS,01"+"\r\n" //reset buffer 01
VDTWrite2 "AQ"+"\r\n" // clear accumulation another reset of buffer
VDTWrite2 "AS"+"\r\n" //start data collection
VDTWrite2 "AP"+"\r\n" // pause data collection
VDTWrite2 "AO,01"+"\r\n" //request data from buffer 01
VDTRead2/n=1000000/O=3/Q /T="\r\n" input //read data
I can do all this from the terminal window by entering the text string commands.
Here is the problem:
In the terminal window when I issue the "AO,01" command I get the full data stream including the carriage return and line feed.
Within my function I do not get the full stream of data and it times out and gets chopped. I print the input string and can see the truncated values. The string is about 1700 characters long. I never get the carriage return and line feed within the function. I always get it when in terminal mode. Also note that I have a very long time out time and within terminal window I never come close to needing that amount of time.
When I change the time out time from 0.5,1, 2, 3, 4 or 5 sec
0.5 sec I get ~500 characters received and no terminators
1 sec I get ~1000 characters received and no terminators
3-5 sec I get ~1700 characters and no terminators
Any hints on what is going on and how to fix it?