Re: Trapping for error and displaying receive buff - WeOnlyDo Discussion board

Re: Trapping for error and displaying receive buff (General questions)

by Eric, Friday, December 07, 2007, 20:29 (5956 days ago) @ woddrazen

Same issue happens. Can You please explain what is happening here:

[code]
Telnet1.Connect()

On Error GoTo ErrorHandler
Telnet1.WaitFor( p5104 - Select: )
Telnet1.DataReady = 0
Telnet1.Execute( T & vbLf, p5104 - Select: )
[/code]

Lines:
1 - Connect to host
2 - On Error call special Handler
3 - Receive the output from the host and wait for string p5104 - Select:
4 - Turn off receive buffer for next command
5 - Send T to host and receive output to buffer and wait for string p5104 - Select:

[size=2]Prompt Method[/size]
[code]
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
.
.
.
Telnet1.Prompt = p5104 - Select:

ExecCount = 0
Telnet1.Connect()
End Sub

Private Sub Telnet1_PromptReceived() Handles Telnet1.PromptReceived
Select Case ExecCount
Case 0
AddToList(Telnet1.Prompt)
Telnet1.Prompt = p5104 - Select:
Telnet1.Send( T & vbLf)
Case 1
AddToList(Telnet1.Prompt)
Telnet1.Prompt = (c)Eagle Con&Dev
Telnet1.Send( e51 & vbLf)
Case 2
.
.
.
End Select

ExecCount = ExecCount + 1
End Sub
[/code]

Here the prompt is defined before the Connect method. This way the output buffer is scaned for the string p5104 - Select: . When the string is found it raises the Telnet1.PromptReceived Event which is then handled by the case statement above.

Is there a difference of when the buffer is received and lost with the WaitFor and Execute method? What I mean is that the only time a Timeout event can be raised if it does not find the string in the received buffer. This is turned off for WiatFor and Execute so where is the buffer to read the data stream?


Complete thread: