mtbpatriot153
New member
- Joined
- Jun 15, 2009
- Messages
- 1
- Programming Experience
- 5-10
Hello there,
I've recently been having some trouble talking to a device I have connected remotely. Without getting into too much detail, the device has an IP address and firmware on it that automatically sends out a response when it receives a specific command.
The problem I'm having is I need to send the command three times in order to get back a response. The first time I get "??" (characters that can't display), and the second time I get nothing. When I send the command a third time, it returns exactly what I was expecting.
I don't believe the problem is with the device because HyperTerminal can connect to it (via TCP/IP) and send a command (once) and have it return appropriate data.
Here's my connect/receive code:
Any help you guys could give would be greatly appreciated!
Thank you,
Mike
I've recently been having some trouble talking to a device I have connected remotely. Without getting into too much detail, the device has an IP address and firmware on it that automatically sends out a response when it receives a specific command.
The problem I'm having is I need to send the command three times in order to get back a response. The first time I get "??" (characters that can't display), and the second time I get nothing. When I send the command a third time, it returns exactly what I was expecting.
I don't believe the problem is with the device because HyperTerminal can connect to it (via TCP/IP) and send a command (once) and have it return appropriate data.
Here's my connect/receive code:
VB.NET:
Dim serverStream As NetworkStream = clientSocket.GetStream()
Dim outStream As Byte() = System.Text.Encoding.ASCII.GetBytes("cd 3" & vbCrLf)
serverStream.Write(outStream, 0, outStream.Length)
outStream = System.Text.Encoding.ASCII.GetBytes("setswitch 1 1 1 1" & vbCrLf)
serverStream.Write(outStream, 0, outStream.Length)
serverStream.Flush()
Dim returndata As String = System.Text.Encoding.ASCII.GetString(inStream)
serverStream.Read(inStream, 0, CInt(clientSocket.ReceiveBufferSize))
msg("Data from Server : " + returndata)
Any help you guys could give would be greatly appreciated!
Thank you,
Mike