Serial Buffer

ceaser

Active Member
Licensed User
Hi

I have a problem:sign0148:

I have a routine to send a string to a Total Station to read the angles and distance to a prism. This then gets send back to the program where it is further processed. This works fine if there is no interruption of the beam between the Total Station and the prism. If I however turn the instrument to a different position and I instruct the program to send the Total Station a command again, but there is no prism, it gives me the results of my previous reading. I am using the command "Serial1.InputString"

I need to clear the contents in the Buffer:sign0085:

The program must keep on sending the command to the instrument, until I stop it or the instrument has picked up the prism.

I am attaching the routine that does the reading:

Sub ReadStation(R,R1)
ReadAgain:
HVD(1)=0 :HVD(2)=0 :HVD(3)=0 :f=0
If Main.DF(3)=1 Then
'Leica Total Station
suh(1)="21." :suh(2)="22." :suh(3)="31."
If Main.DF(4)>=3 Then ' tc500,tc1010,tc1610
If R="u" Then
stcm="GET/M/WI11/WI21/WI22/WI31"
Else If R="t" Then
stcm="GET//WI11/WI21/WI22"
If Main.DF(4)=3 OR Main.DF(4)=9 Then
Serial1.Output("SET/160/0" & EndLine)
End If
End If
Serial1.Output(stcm & EndLine)
Else
Serial1.Output(R & EndLine)
End If
A=Serial1.InputString
'If Main.DF(4)<>9 Then Serial1.Output("?" & EndLine)
End If
If StrLength(A)<10 Then Goto ReadAgain

'split the string up
Msgbox(A)
Do
f=f+1
A1=(StrIndexOf(A,suh(f),0))
If A1<>-1 Then
HVD(f)=SubString(A,A1+7,8)
If f=3 Then
'distance
HVD(f)=HVD(f)/1000
Else
'horizontal & vertical winkel
HVD(f)=HVD(f)/100000
End If
End If
Loop Until f=R1
End Sub

Thanks
Michael
 

ceaser

Active Member
Licensed User
Hi Agraham

I think you are right. That is information still sitting at the instrument that is being resend. I will check what I did on the old program on the Workabout. Maybe send a code through to the instrument to clear the contents there once the good data has been recorded.

Thanks:sign0188:
Michael
 
Top