Announcement

Collapse
No announcement yet.

IP / Serial Plugin for HS3 (by "drule") - Discussion Thread

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Originally posted by peterpc View Post
    Tested the COM port.
    Script is running now. But also at serial port I am missing the last 2 bytes.
    @ Remko, do you receive all the bytes?
    What are you sending vs what are you receiving? I'd like to attempt to recreate the problem.

    Thanks!
    -David

    Comment


      It is like in the screen shots. Text is ok but last 2 bytes read 00

      Verstuurd vanaf mijn SM-G900F met Tapatalk
      Peter

      http://ohh.pcgsm.nl

      Comment


        Originally posted by peterpc View Post
        It is like in the screen shots. Text is ok but last 2 bytes read 00

        Verstuurd vanaf mijn SM-G900F met Tapatalk
        Ah ha! I managed to reproduce the problem and then spotted the typo responsible in my sample pass-thru script.

        Line 6 says:
        Code:
        Array.Copy(param(3), BinaryData, UBound(BinaryData)-1)
        Should say:
        Code:
        Array.Copy(param(3), BinaryData, UBound(BinaryData)+1)
        Here's the whole sample script again with some improvements:
        Code:
        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
        -David

        Comment


          Hi David,

          It is working now! thanks!

          But I have an other problem.
          When I receive 0x33, the script has to reply with 0x30
          I put this in the script:
          hs.PluginFunction("drhsIpPlugin", "", "Ext_Send_Data", New Object() {"eth484", "0x30", "Binary"})
          But then I get this error:
          ERROR - SendTcp: Cannot access a disposed object. Object name: 'System.Net.Sockets.Socket'. (eth484, persistence 0)

          What am I doing wrong?
          Peter

          http://ohh.pcgsm.nl

          Comment


            Originally posted by peterpc View Post
            Hi David,

            It is working now! thanks!

            But I have an other problem.
            When I receive 0x33, the script has to reply with 0x30
            I put this in the script:
            hs.PluginFunction("drhsIpPlugin", "", "Ext_Send_Data", New Object() {"eth484", "0x30", "Binary"})
            But then I get this error:
            ERROR - SendTcp: Cannot access a disposed object. Object name: 'System.Net.Sockets.Socket'. (eth484, persistence 0)

            What am I doing wrong?
            Hi Peter,

            I'm happy to hear we got the first part working! How is your connection configured? I will make mine the same and test.

            -David

            Comment


              Hello David,

              I'm not missing any bytes anymore either, but I have discovered a different issue.

              I'm reading messages through an USB2RS485 converter. The individual messages have a length of eight bytes and I read all and can convert them properly using your pass through script. However the homeseer log shows an "Error 3", also see picture attached. It does not seem to effect conversions of the data, but I was wondering if it was harmfull, other than, filling the homeseer log.


              The interesting portion is that if I send messages quickly over the rs485 bus, the plugin reads either 16, 24 or 32 bytes instead of three individual eight byte messages and does not show the error.

              Related to the fact that the plugin can interpret multiple messages as one I was wondering if there is a minimum time required between two consecutive messages.

              As I cannot influence the sending of these messages I guess I'll have to process the data to extract individual messages. As my programming skills are rusty I'll probably bother the board members if I run into issues

              Kind regards,

              Remko.
              Attached Files

              Comment


                Originally posted by drule View Post
                Hi Peter,

                I'm happy to hear we got the first part working! How is your connection configured? I will make mine the same and test.

                -David
                Hi David,
                I am using a eth484 i/o module.
                http://www.robot-electronics.co.uk/htm/eth484tech.htm
                This module can map inputs to custom devices:

                Mapping inputs to custom devices
                Following customer requests for obtaining input states without the need for polling the ETH484, this can be achieved with the existing input mapping function.
                If you would like the inputs to be mapped to a custom device then we have a simple command structure to achieve this, the ETH484 will send the commands in blue, your device will respond with commands in yellow.
                A TCP packet with 0x79 (password entry) in the first byte, then the following bytes will be the password supplied above
                To acknowledge a password match, respond with 1, else send 2
                Digital active (0x20) or Digital inactive (0x21) followed by the output number
                Reply with a 0 for success, else send 1

                Note that the complete sequence must be followed, even if the password fails.

                This is the .vb script I have made so far:

                Code:
                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
                My goal is to have devices following the inputs of the eth484.

                This is the log I get: (y12345 means the password set in eth484 is 12345)
                Attached Files
                Peter

                http://ohh.pcgsm.nl

                Comment


                  I just ordered myself an ETH484. It looks like I can use it to monitor my generator so it will be useful. Shipping from the UK to the USA will take a few days but as soon as I receive it, I will get it set up.

                  -David

                  Comment


                    Originally posted by drule View Post
                    I just ordered myself an ETH484. It looks like I can use it to monitor my generator so it will be useful. Shipping from the UK to the USA will take a few days but as soon as I receive it, I will get it set up.

                    -David
                    Hi David,
                    That is good news!
                    Now I am sure it will work!
                    Peter

                    http://ohh.pcgsm.nl

                    Comment


                      I am testing communication between my door lock (com3) and noticed that commands from the lock are coming in by the bunch.

                      When I test it with HS2 and the door lock plugin, commands from the lock are coming in one by one command.

                      I know I had the same problem when writing a script for my solar power interface.
                      After adding SerialPort1.RTSEnable = True in the script, communication was ok.

                      How is RTS set with your plugin for a com port?
                      If not set, can I set it to True?
                      Peter

                      http://ohh.pcgsm.nl

                      Comment


                        Originally posted by peterpc View Post
                        I am testing communication between my door lock (com3) and noticed that commands from the lock are coming in by the bunch.

                        When I test it with HS2 and the door lock plugin, commands from the lock are coming in one by one command.

                        I know I had the same problem when writing a script for my solar power interface.
                        After adding SerialPort1.RTSEnable = True in the script, communication was ok.

                        How is RTS set with your plugin for a com port?
                        If not set, can I set it to True?
                        SerialPort.RTSEnable is hard coded to True in the plugin. Let me go back to the HS2 code and see if I can figure what might have changed.

                        -David

                        Comment


                          To make things clear, for HS2 I used a plugin especially made for the door lock. Not your plugin.
                          Peter

                          http://ohh.pcgsm.nl

                          Comment


                            OK, got my Eth484 and now I have it all working! I found a bug that was causing the plugin to attempt to read data from a tcp host connection after the remote client had closed the session. After the pass-thru script sent the acknowledgement byte, the Eth484 closed the connection and the plugin crashed trying to read more data from the now closed connection. I have sent cheeryfool the updated plugin to post on the main thread.

                            I also discovered that the Eth484 sends 3 bytes. not 2 when sending status. The Eth484 documentation says "The ETH484 then sends digital active (0x20) or digital inactive (0x21) followed by the output number. So it would send two bytes 0x20, 0x01." My Eth484 is sending 3 bytes: 0x20, 0x01, 0x00.

                            Here's my pass-thru script for the Eth484:
                            Code:
                            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
                            Cheers
                            -David

                            Comment


                              idiots guide to the most simple use case!

                              Hi,

                              I'm sure I;m being very dense, but am trying to implement a simple use case and failing.

                              So - all I want to do, is have an event that sends the currently playing track name to drhslpPlugin (which in turn sends the received payload to a connected tcp ip client -- and the client is receiving the output nicely).

                              I have set up an event, driven by a "Sonos Track Change" and I am selecting my connection (iRule) and I select the device: Sonos Track and the payload of Status. Instead of getting the track name, I get the value "No Track".

                              When I inspect the Sonos Track device/variable it seems there is a status of 1000, a Value of "No Track" and a String Value containing the track name that I am actually trying to access.

                              How do I get at it!

                              While I'm at it, what I really would like to do is also prepend and append a delimiter to it.

                              Darn. Almost Instant Gratification -- but not quite!

                              Comment


                                Hi,
                                I've installed a INTRONICO MFC-8800 relay card with8 inputs and 8 outputs to HS3.
                                The controlling of the outputs with the drhspi plugin works successfull, only the received string is unknown until now for me.
                                Is there a possibility for the drhsip plugin to trigger events which
                                trigger on Received string contains : instead of String Received : ?

                                http://www.growes.ca/docs/8800_lan_a...tion_guide.pdf

                                Could someone look into this application to help me how to receive
                                strings from this device ?

                                [ATTACH][ATTACH]Click image for larger version

Name:	drhsip_3_bearbeitet-1.jpg
Views:	1
Size:	362.3 KB
ID:	1180811[/ATTACH][/ATTACH]






                                Best regards, Fischi
                                Attached Files
                                Last edited by Fischi; October 23, 2015, 04:59 AM. Reason: issue

                                Comment

                                Working...
                                X