Originally posted by peterpc
View Post
Thanks!
-David
If this is your first visit, be sure to check out the FAQ. You must register before you can post.
IMPORTANT: Your first post will be checked for appropriate content. This may take a bit of time.
Array.Copy(param(3), BinaryData, UBound(BinaryData)-1)
Array.Copy(param(3), BinaryData, UBound(BinaryData)+1)
Sub Main(param() As Object) Dim ConnectionName As String = param(0) Dim FromIp As String = param(1) Dim AsciiData As String = param(2) Dim BinaryData(UBound(param(3))) As Byte Array.Copy(param(3), BinaryData, BinaryData.Length) hs.WriteLog("Pass-thru", ConnectionName) hs.WriteLog("Pass-thru", FromIp) hs.WriteLog("Pass-thru", AsciiData) hs.WriteLog("Pass-thru", "There are " & BinaryData.Length.ToString & " bytes of binary data.") For n as Int16 = 0 to UBound(BinaryData) hs.WriteLog("Pass-thru b" & n.ToString, BinaryData(n).ToString) Next End Sub
Sub Main(ByVal Param() As Object) Dim ConnectionName As String = param(0) Dim FromIp As String = param(1) Dim AsciiData As String = param(2) Dim BinaryData(UBound(param(3))) As Byte Array.Copy(param(3), BinaryData, BinaryData.Length) Dim Bytecount As Integer = UBound(BinaryData) Dim I As Integer Array.Copy(param(3), BinaryData, UBound(BinaryData) + 1) hs.WriteLog("Pass-thru 0", ConnectionName) hs.WriteLog("Pass-thru 1", FromIp) hs.WriteLog("Pass-thru 2", AsciiData) hs.WriteLog("Pass-thru", "There are " & Bytecount + 1 & " bytes of binary data.") For i = 0 To Bytecount hs.WriteLog("Pass-thru b" & I, " " & BinaryData(I)) Next 'For i = 0 To Bytecount Select Case BinaryData(0) Case "121" '32 'hs.PluginFunction("drhsIpPlugin", "", "Ext_Send_Command", New Object() {"Test Connection", "Test Command"}) hs.PluginFunction("drhsIpPlugin", "", "Ext_Send_Command", New Object() {"eth484", "0x31"}) 'hs.PluginFunction("drhsIpPlugin", "", "Ext_Send_Data", New Object() {"eth484", "0x31", "Binary"}) '0x32 = 1 hs.WriteLog("eth484", "command 0x31 send ") '“Ext_Send_Command” will send the predefined command, eg “Test Command”, to the connection “Test Connection”. '“Ext_Send_Data” will send a string, eg "Hello\sworld\r\n", parsed as either “URL-Encoded, Raw Test, Binary or C Escaped”, to the connection “Test Connection”. 'Exit For Case "33" 'Do other stuff hs.SetDeviceValueByRef(1229, 0, True) 'off hs.WriteLog("Pass-thru test", "fan uit") hs.PluginFunction("drhsIpPlugin", "", "Ext_Send_Command", New Object() {"eth484", "0x30"}) ' "0x30" 'Exit For Case "32" 'Do other stuff hs.SetDeviceValueByRef(1229, 100, True) 'on hs.WriteLog("Pass-thru test", "fan aan") 'hs.PluginFunction("drhsIpPlugin", "", "Ext_Send_Data", New Object() {"eth484", "0x30", "Binary"}) 'Exit For Case Else hs.WriteLog("eth484", "I don't know what to do with: " & BinaryData(0)) End Select 'Next End Sub
Sub Main(param() As Object) Dim ConnectionName As String = param(0) Dim FromIp As String = param(1) Dim AsciiData As String = param(2) Dim BinaryData(UBound(param(3))) As Byte Array.Copy(param(3), BinaryData, BinaryData.Length) Const Password As String = "password" If BinaryData(0) = 121 Then ' password received If Right(AsciiData, AsciiData.Length -1) = Password Then ' correct password received so send ack hs.PluginFunction("drhsIpPlugin", "", "Ext_Send_Data", New Object(){"ETH484 Host", "0X1", "Binary"}) Else hs.WriteLog("Eth484", "Incorrect password") hs.PluginFunction("drhsIpPlugin", "", "Ext_Send_Data", New Object(){"ETH484 Host", "0X2", "Binary"}) End If Else ' not password If BinaryData.Length = 3 Then ' got good data hs.WriteLog("Eth484", "Active=" & BinaryData(0).ToString & ", output=" & BinaryData(1).ToString) hs.PluginFunction("drhsIpPlugin", "", "Ext_Send_Data", New Object(){"ETH484 Host", "0X0", "Binary"}) Else hs.WriteLog("Eth484", "Unexpected data length! " & AsciiData) End If End If End Sub
Comment