Dart Home | PowerTCP Telnet for .NET | Custom Development | Reply | PowerTCP Telnet for .NET Topics | Forums |
Author | Forum: PowerTCP Telnet for .NET Topic: Data Received Incomplete |
xplorer2k From: Oxnard, CA USA Posts: 33 Member Since: 03/27/09 |
posted May 4, 2009 9:02 PM Hi Everyone, I am running the following program, and I am having problems to execute the last command: telnet.Write("./activeImage " & MuxSlotNumber & " " & 0 & Chr(10)) The program stops at (regardless of any commands added after this one) : telnet.Write("./loadImage " & MuxSlotNumber & " " & 1 & " " & Trim(txtMUXfilename.Text) + Chr(10)) The attached a picture shows server’s response from above command. My problem is that I am mixing asynchronous and synchronous operations and I having problems trying to make both of them work. So my question is, how do I wait long enough (but still displaying data) to let the previous command to execute before I send the next one, without interfering with each other? Thanks, Xplorer2k Private Sub btnMUXremoteUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMUXremoteUpdate.Click Me.Text = APP_NAME & " [Connecting ...]" textDisplay.Clear() textDisplay.Focus() loopCounter = 0 strDataMessage = "Wait until text is found" MuxSlotNumber = Convert.ToInt32(Trim(txtMuxSlotNumber.Text)) - 1 Telnet1.Start(AddressOf automateSession, Nothing) End Sub Private Sub automateSession(ByVal telnet As Telnet, ByVal notUsed As Object) 'This function executes on a worker thread, providing multi-threaded, asynchronous operation Try telnet.SocketOption.ReceiveTimeout = 10000 telnet.Connect(txtANMS_Host.Text) 'Login to the server, marshal data to the UI thread telnet.Marshal(telnet.Login(txtUsername.Text, txtPassword.Text, "$"), Nothing) telnet.Write(txt_SU_Username.Text & Constants.vbCr) telnet.Marshal(telnet.Read("Password"), Nothing) telnet.Write(txt_SU_Password.Text & Constants.vbCr) telnet.Marshal(telnet.Read("#"), Nothing) telnet.Write("cd /" + Chr(10)) telnet.Marshal(telnet.Read("#"), Nothing) telnet.Write("cd /mnt/flash/home/anms/utils" + Chr(10)) telnet.Marshal(telnet.Read("#"), Nothing) telnet.SocketOption.ReceiveTimeout = 0 telnet.Write("./loadImage " & MuxSlotNumber & " " & 1 & " " & Trim(txtMUXfilename.Text) + Chr(10)) 'Receive data when it is sent by remote host Dim buffer() As Byte = New Byte(1023) {} Do While telnet.State <> ConnectionState.Closed telnet.Marshal(telnet.Read(buffer, 0, 1024), Nothing) strNumber = InStr(strData, "AAA") If Not strNumber > 0 Then strDataMessage = "text MATCH found" 'Exit Do End If Loop telnet.Write("./activeImage " & MuxSlotNumber & " " & 0 & Chr(10)) Catch ex As Exception 'Report errors to the UI thread telnet.Marshal(ex) End Try End Sub Private Sub telnet1_Data(ByVal sender As System.Object, ByVal e As Dart.Common.DataEventArgs) Handles Telnet1.Data loopCounter = loopCounter + 1 'Whenever data is received, display it textDisplay.AppendText(e.Data.ToString()) If loopCounter > 6 Then 'strData = Convert.ToString(e.Data.ToString()) strData = e.Data.ToString() ListBox1.Items.Add(strData) ListBox1.Items.Add(strNumber) End If ListBox1.Items.Add(strDataMessage) End Sub Private Sub telnet1_Error(ByVal sender As System.Object, ByVal e As System.IO.ErrorEventArgs) Handles Telnet1.Error 'Show error message MessageBox.Show(e.GetException().Message, APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning) telnet1_StateChanged(Me, Nothing) End Sub Private Sub textDisplay_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles textDisplay.KeyPress If Telnet1.State = ConnectionState.Connected Then 'Send character to remote host If e.KeyChar = Chr(13) Then 'Send a list command 'Telnet1.Write("" & Constants.vbCr) Telnet1.Write(Constants.vbCr) Else Telnet1.Write(e.KeyChar.ToString()) ''Only display character if local echo is true 'e.Handled = True End If End If End Sub |
xplorer2k From: Oxnard, CA USA Posts: 33 Member Since: 03/27/09 |
posted May 5, 2009 5:07 PM I have used wireshark to trace the data coming from the server and in the last line there are 2 rows of data instead of one: previous row: Data: ... Last row of data (2 rows, instead of one): Data: ... 8AAA20A4 64K\r\n Data: [anms@VS183-ANMS /mnt/flash/home/anms/utils]1325# Transmission Control Protocol, Src Port: 2380 (2380), Dst Port: telnet (23), Seq: 141, Ack: 578, Len: 0 Checksum: 0x4668 [incorrect, should be 0x6938 (maybe caused by "TCP checksum offload"?)] Also, there is a checksum error showed above. Please advise any other test to find solution to this problem. Thanks, xplorer2k |
xplorer2k From: Oxnard, CA USA Posts: 33 Member Since: 03/27/09 |
posted May 5, 2009 6:40 PM I figure it out! It took me a while to come out with a solution. xplorer2k |
simontrain From: Glasgow, United Kingdom Posts: 7 Member Since: 11/19/09 |
posted November 19, 2009 8:40 AM can you tell me how you solved the problem. thanks. |
xplorer2k From: Oxnard, CA USA Posts: 33 Member Since: 03/27/09 |
posted November 23, 2009 2:27 PM Hi simontrain, I used a unique "text" response from the server and the program just wait until this "text" is received and continues on with the next command: telnet.Marshal(telnet.Read(":"), null); Hope this helps. xplorer2k |
Reply | PowerTCP Telnet for .NET Topics | Forums |
This site is powered by PowerTCP WebServer for ActiveX |