Michael McSharry
Bob_Linux_User
spike5884
Steve Q
zwolfpack
Hello, I am using the script below to send infrared sting to a device over the ip network. The script works however if I hit the buttons a few times quickly crashes the entire application. and the following error message appears.
Please help me I don't know what to do to solve the problem
' import required modules
Imports System.Net
Imports System.Net.Sockets
Imports System.Text
Sub Main(ByVal parms as Object)
Select case parms
Case "CENAHOMEPROJETORLIGA"
Const Digit_9 = "sendir,1:7,1,37000,1,1,343,171,21,21,21,21,21,21,21,21,21,2 1,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,64,21,64,21,2 1,21,21,21,21,21,64,21,21,21,21,21,21,21,21,21,21,21,21,21,6 4,21,21,21,64,21,64,21,64,21,64,21,64,21,64,21,1743,343,85,2 1,2000"&vbCR
CALL ENVIADADOS(Digit_9)
Case "CENAHOMEPROJETORDESLIGA"
Const Digit_9 = "sendir,1:3,1,38000,1,1,347,172,21,65,21,65,21,22,21,22,21,2 1,21,21,21,22,21,65,21,65,21,21,21,65,21,22,21,65,21,22,21,6 5,21,22,21,65,21,21,21,22,21,22,21,65,21,22,21,21,21,65,21,2 2,21,65,21,65,21,65,21,21,21,65,21,65,21,21,21,1577,347,172, 21,65,21,65,21,21,21,22,21,22,21,21,21,21,21,65,21,65,21,22, 21,65,21,21,21,65,21,21,21,65,21,22,21,65,21,22,21,22,21,22, 21,65,21,22,21,21,21,65,21,21,21,65,21,65,21,65,21,21,21,65, 21,65,21,21,21,2000"&vbCR
CALL ENVIADADOS(Digit_9)
Case "CENAHOMERECEIVER"
Const Digit_9 = "sendir,1:6,1,37000,1,1,341,171,21,21,21,64,21,64,21,64,21,6 4,21,64,21,64,21,21,21,64,21,21,21,21,21,21,21,21,21,21,21,2 1,21,64,21,21,21,64,21,21,21,64,21,21,21,64,21,21,21,21,21,6 4,21,21,21,64,21,21,21,64,21,21,21,64,21,64,21,1516,341,86,2 1,2000"&vbCR
CALL ENVIADADOS(Digit_9)
Case "CENAHOMEVIVO"
Const Digit_9 = "sendir,1:6,1,36000,3,1,96,32,15,16,15,16,15,32,15,32,47,32, 15,16,15,16,15,16,15,16,15,16,15,16,15,16,31,32,31,32,31,32, 15,16,31,32,31,32,15,16,31,16,15,16,15,32,15,16,15,16,15,16, 31,16,15,32,15,16,15,2576"&vbCR
CALL ENVIADADOS(Digit_9)
Case "CENAHOMETVLIGA"
Const Digit_9 = "sendir,1:6,1,38000,1,1,172,173,20,65,20,65,20,65,20,22,20,2 2,20,22,20,22,20,22,20,65,20,65,20,65,20,22,20,22,20,22,20,2 2,20,22,20,22,20,65,20,22,20,22,20,22,20,22,20,22,20,22,20,6 5,20,22,20,65,20,65,20,65,20,65,20,65,20,65,20,1800,172,173, 20,65,20,65,20,65,20,22,20,22,20,22,20,22,20,22,20,65,20,65, 20,65,20,22,20,22,20,22,20,22,20,22,20,22,20,65,20,22,20,22, 20,22,20,22,20,22,20,22,20,65,20,22,20,65,20,65,20,65,20,65, 20,65,20,65,20,2000\r\n"&vbCR
CALL ENVIADADOS(Digit_9)
End Select
End Sub
Private Sub ENVIADADOS (Digit_9)
Const Host = "192.168.0.251"
Const HostPort = 4998
Dim tcpClient As New System.Net.Sockets.TcpClient()
tcpClient.Connect(host, hostport)
Dim networkStream As NetworkStream = tcpClient.GetStream()
Dim strResponse As String
strResponse = "No response"
If networkStream.CanWrite Then
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(Digit_9)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
Dim returndata As String = Encoding.ASCII.GetString(bytes)
strResponse = "Device responded: " & CStr(returndata)
Else
If Not networkStream.CanWrite Then
strResponse = "Error: Cannot write data to the device"
tcpClient.Close()
End If
End If
End Sub
Bob_Linux_User
spike5884
Steve Q
zwolfpack
Hello, I am using the script below to send infrared sting to a device over the ip network. The script works however if I hit the buttons a few times quickly crashes the entire application. and the following error message appears.
Please help me I don't know what to do to solve the problem
' import required modules
Imports System.Net
Imports System.Net.Sockets
Imports System.Text
Sub Main(ByVal parms as Object)
Select case parms
Case "CENAHOMEPROJETORLIGA"
Const Digit_9 = "sendir,1:7,1,37000,1,1,343,171,21,21,21,21,21,21,21,21,21,2 1,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,64,21,64,21,2 1,21,21,21,21,21,64,21,21,21,21,21,21,21,21,21,21,21,21,21,6 4,21,21,21,64,21,64,21,64,21,64,21,64,21,64,21,1743,343,85,2 1,2000"&vbCR
CALL ENVIADADOS(Digit_9)
Case "CENAHOMEPROJETORDESLIGA"
Const Digit_9 = "sendir,1:3,1,38000,1,1,347,172,21,65,21,65,21,22,21,22,21,2 1,21,21,21,22,21,65,21,65,21,21,21,65,21,22,21,65,21,22,21,6 5,21,22,21,65,21,21,21,22,21,22,21,65,21,22,21,21,21,65,21,2 2,21,65,21,65,21,65,21,21,21,65,21,65,21,21,21,1577,347,172, 21,65,21,65,21,21,21,22,21,22,21,21,21,21,21,65,21,65,21,22, 21,65,21,21,21,65,21,21,21,65,21,22,21,65,21,22,21,22,21,22, 21,65,21,22,21,21,21,65,21,21,21,65,21,65,21,65,21,21,21,65, 21,65,21,21,21,2000"&vbCR
CALL ENVIADADOS(Digit_9)
Case "CENAHOMERECEIVER"
Const Digit_9 = "sendir,1:6,1,37000,1,1,341,171,21,21,21,64,21,64,21,64,21,6 4,21,64,21,64,21,21,21,64,21,21,21,21,21,21,21,21,21,21,21,2 1,21,64,21,21,21,64,21,21,21,64,21,21,21,64,21,21,21,21,21,6 4,21,21,21,64,21,21,21,64,21,21,21,64,21,64,21,1516,341,86,2 1,2000"&vbCR
CALL ENVIADADOS(Digit_9)
Case "CENAHOMEVIVO"
Const Digit_9 = "sendir,1:6,1,36000,3,1,96,32,15,16,15,16,15,32,15,32,47,32, 15,16,15,16,15,16,15,16,15,16,15,16,15,16,31,32,31,32,31,32, 15,16,31,32,31,32,15,16,31,16,15,16,15,32,15,16,15,16,15,16, 31,16,15,32,15,16,15,2576"&vbCR
CALL ENVIADADOS(Digit_9)
Case "CENAHOMETVLIGA"
Const Digit_9 = "sendir,1:6,1,38000,1,1,172,173,20,65,20,65,20,65,20,22,20,2 2,20,22,20,22,20,22,20,65,20,65,20,65,20,22,20,22,20,22,20,2 2,20,22,20,22,20,65,20,22,20,22,20,22,20,22,20,22,20,22,20,6 5,20,22,20,65,20,65,20,65,20,65,20,65,20,65,20,1800,172,173, 20,65,20,65,20,65,20,22,20,22,20,22,20,22,20,22,20,65,20,65, 20,65,20,22,20,22,20,22,20,22,20,22,20,22,20,65,20,22,20,22, 20,22,20,22,20,22,20,22,20,65,20,22,20,65,20,65,20,65,20,65, 20,65,20,65,20,2000\r\n"&vbCR
CALL ENVIADADOS(Digit_9)
End Select
End Sub
Private Sub ENVIADADOS (Digit_9)
Const Host = "192.168.0.251"
Const HostPort = 4998
Dim tcpClient As New System.Net.Sockets.TcpClient()
tcpClient.Connect(host, hostport)
Dim networkStream As NetworkStream = tcpClient.GetStream()
Dim strResponse As String
strResponse = "No response"
If networkStream.CanWrite Then
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(Digit_9)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
Dim returndata As String = Encoding.ASCII.GetString(bytes)
strResponse = "Device responded: " & CStr(returndata)
Else
If Not networkStream.CanWrite Then
strResponse = "Error: Cannot write data to the device"
tcpClient.Close()
End If
End If
End Sub
Comment