Announcement

Collapse
No announcement yet.

IP and Serial Plugin

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

    IP and Serial Plugin

    I've had some very good responses so far, including a couple of feature suggestions. Please keep them coming!

    -David

    Link to plugin: http://forums.homeseer.com/showthread.php?t=155438
    Last edited by drule; August 24, 2012, 08:33 AM. Reason: Adding link to plugin.

    #2
    Triggering Events on Binary Strings

    David,

    Firsly, fantastic plug-in. I am in the process of setting up communication to a Philips Dynalite system using an RS485-RS232 gateway. This enables me to send Hex bytes to the Dynalite system to control lighting, fans, blinds etc.

    I was hoping that I could also trigger events using Hex (Binary) strings to enable me to track the status of all these devices.

    When I put the Binary string into the trigger it is not working. Any ideas?

    Thanks

    Jamie

    Comment


      #3
      drule hasn't been on the forums in a couple of months. I'm not sure what's happened to him.

      Have you enabled debug and watched the log to see what the data captured looks like? I suspect it's being escaped with \ or other characters (and/or line feeds).

      Comment


        #4
        Great plugin, was just having a play to see what it was capable of and I am very impressed. I have a question though, is it possible in the event trigger (this may be a feature request) to have a trigger if the string contains the phrase, rather than the string is the phrase?

        Thanks
        HS3 PRO, Win10, WeatherXML, HSTouch, Pushover, UltraGCIR, Heaps of Jon00 Plugins, Just sold and about to move so very slim system.

        Facebook | Twitter | Flickr | Google+ | Website | YouTube

        Comment


          #5
          I'm back! Sorry for the disappearance. I had a whole bunch of other things demanding my time and then Hurricane Sandy came along and caused some major damage.

          Anyway, I'll be posting a quick update in a few minutes. The new version includes:
          You can now specify encoding types for triggers. This means you can define hex strings or c-escaped strings to match for event triggers. Bad news: existing triggers will need to be edited to select "raw text" as their type or the update may cause them to stop working.

          "Persistent TCP Clients" will restart if the plugin determines that they have dropped. The initial reconnect attempt will occur immediately. If that attempt fails, the plugin will continue to attempt to reconnect periodically at an interval defined in the plugin's config page (defaults to every 10 seconds).

          You can now trigger an event when a persistent TCP client connects and/or disconnects.

          Scripting access. You can now use scripts to send stuff to connections. Right now I've only defined two script commands but expect to grow this over time based on any requests I may get. I'll give some examples in a later post.

          My apologies once again for the long interval between my posts and thanks to cheeryfool for keeping an eye on things for me. He earned himself a copy of the update a couple of days early ;-)

          -David

          Now posted at: http://forums.homeseer.com/showthread.php?t=155438
          Last edited by drule; December 5, 2012, 01:20 PM. Reason: File posted

          Comment


            #6
            Scripting access examples. From a script you can send either a predefined command to a existing connection, or a 'dynamic' string to a existing connection. For example:
            Code:
            Public Sub Main(ByVal Params As Object)
                Dim IPP As Object = hs.Plugin("DR IP/Serial PlugIn")
                IPP.Send("Mute", "c_Samsung_c1")
            End Sub
            sends the predefined command Mute to the connection called c_Samsung_c1.
            Code:
            Public Sub Main(ByVal Params As Object)
                Dim IPP As Object = hs.Plugin("DR IP/Serial PlugIn")
                IPP.Send("Hello\sworld\r\n", "C Escaped", "c_Samsung_c1")
            End Sub
            would send Hello World as a C Escaped string to the connection called c_Samsung_c1.

            I think there's loads of other potential uses for this interface and I welcome suggestions for new features.

            -David

            Comment


              #7
              Originally posted by jhuthwaite View Post
              David,

              Firsly, fantastic plug-in. I am in the process of setting up communication to a Philips Dynalite system using an RS485-RS232 gateway. This enables me to send Hex bytes to the Dynalite system to control lighting, fans, blinds etc.

              I was hoping that I could also trigger events using Hex (Binary) strings to enable me to track the status of all these devices.

              When I put the Binary string into the trigger it is not working. Any ideas?

              Thanks

              Jamie
              Hi Jamie, the latest update should make this work for you.

              Comment


                #8
                Input mangled over serial

                First, thanks for this excellent plugin.

                I'm having an issue with the serial type connection when used with my receiver. I have a Yamaha RX-A3000, and when I connect to it (using your plugin) via the serial interface, I can send it commands correctly, but when I receive the input, it arrives in various, random chunks. This prevents me from using the input to trigger events.

                If I use the IP connection type, the input looks fine and I can trigger events. Also, if I connect with putty to the serial port, I can see the input arrive in the correct format. I've tried adjusting the threshold setting to no avail.

                Any thoughts?

                Also, I was having an issue where my commands would be halfway lost after restarting homeseer. The Yamaha command format looks something like this:

                @MAIN:PWR=Standby\r\n (C-escaped) ... I had to switch to binary, otherwise the commands get cut to @MAIN:PWR and the remainder is lost. I assume this happens because you are using '=' as a delimeter in your code.. can you confirm?

                Regards,

                Comment


                  #9
                  Originally posted by ivanhoek View Post
                  I'm having an issue with the serial type connection when used with my receiver. I have a Yamaha RX-A3000, and when I connect to it (using your plugin) via the serial interface, I can send it commands correctly, but when I receive the input, it arrives in various, random chunks. This prevents me from using the input to trigger events.

                  If I use the IP connection type, the input looks fine and I can trigger events. Also, if I connect with putty to the serial port, I can see the input arrive in the correct format. I've tried adjusting the threshold setting to no avail.

                  Any thoughts?
                  Would it be possible to use putty to capture some data arriving on the serial port to a text file? Then can you set the plugin's debug level up to 5 and grab the log entries for the same data as the plugin sees it? Send me those and I'll have a go at figuring out what's going wrong. It might take a few passes to get it going, so please bear with me.

                  Originally posted by ivanhoek View Post
                  @MAIN:PWR=Standby\r\n (C-escaped) ... I had to switch to binary, otherwise the commands get cut to @MAIN:PWR and the remainder is lost. I assume this happens because you are using '=' as a delimeter in your code.. can you confirm?

                  Regards,
                  Confirmed. I'm currently using '=' as a delimiter in the code that reads the commands out of the ini file. So when you set the command up the first time, it is correct but when you restart homeseer and the command is read back in from the file, it breaks. I'll have a tinker with that portion of the code and see what I can do. Good catch!

                  Regards
                  -David

                  Comment


                    #10
                    Originally posted by drule View Post
                    Confirmed. I'm currently using '=' as a delimiter in the code that reads the commands out of the ini file. So when you set the command up the first time, it is correct but when you restart homeseer and the command is read back in from the file, it breaks.
                    I just posted a fix for this.

                    Comment


                      #11
                      Originally posted by drule View Post
                      Would it be possible to use putty to capture some data arriving on the serial port to a text file? Then can you set the plugin's debug level up to 5 and grab the log entries for the same data as the plugin sees it? Send me those and I'll have a go at figuring out what's going wrong. It might take a few passes to get it going, so please bear with me.

                      Confirmed. I'm currently using '=' as a delimiter in the code that reads the commands out of the ini file. So when you set the command up the first time, it is correct but when you restart homeseer and the command is read back in from the file, it breaks. I'll have a tinker with that portion of the code and see what I can do. Good catch!

                      Regards
                      -David
                      David,

                      I will try to grab those logs soon. I'm currently traveling around, and this complicates things a little for me. However, this is what happens:

                      When using the IP connection, each full response from the receiver generates an IP packet. However, when using the serial connection, it seems like the input comes in haphazardly, sometimes in 1 byte chunks, others in 2 bytes or even 13byte chunks. The layout of these chunks isn't consistent. It almost looks like jitter... It seems like the plugin is reading the port and grabbing input ASAP, rather than waiting for the \r\n (CRLF) terminator to flush the buffer.

                      Do you use buffering? If you do, what would be useful is if you could let the user specify a terminator/delimeter, that way I could specify /r/n and the response should be flushed from the buffer when that string appears.

                      I think the jitter may be caused due to the way that my system interacts with the serial port. I run Homeseer in an ESXi VM, Win7 32bit guest. I'm sharing the USB-Serial 4port device to it via ESXi.

                      When I look at the response over Putty, it looks fine since Putty is rendering all output serially, regardless of jitter.

                      Thoughts?

                      Comment


                        #12
                        Originally posted by ivanhoek View Post
                        Do you use buffering? If you do, what would be useful is if you could let the user specify a terminator/delimeter, that way I could specify /r/n and the response should be flushed from the buffer when that string appears.
                        Hi Ivanhoek,

                        Thanks for your input. I've been giving this problem some thought. Right now, the plugin has no serial buffering to speak of. All I currently do is to set the ReceivedBytesThreadhold of the serial port to the value specified on the config page.

                        What I'm proposing to do is to introduce a buffer, say 1024 bytes long, read serial data into that buffer and only flush it when there's a match with a defined event trigger. To prevent the buffer filling with incorrect or stale data (for instance if you were to have a device sending data to the serial port for which there is no trigger defined, or there is a trigger but it is misdefined) I'll add a timer to flush the buffer if there have been no matches within a specified period of time.

                        Does this sound like it might work for you?

                        Regards
                        -David

                        Comment


                          #13
                          I just posted an update with my proposed serial buffer. Please give it a go and see if it helps.

                          Thanks
                          -David

                          Comment


                            #14
                            Being new to homeseer and a current irule user, I am interested in this plugin. Although I am so new I am not sure of how to install this plugin? I don't see a link to download the new plugin. I went to the web page to install new plugins and did not see this plugin. So I am basically clueless as to where I download the plugin and how to install it?

                            Question I have:
                            Are you using the irule interface to control your avr etc. Currently I use irule in combination with 2 itach IP2SL's, to control my projector and Onkyo AVR.

                            I have been trying to research how get homeseer to control my hometheater. I was thinking hstouch but the more I looked at it, the more I realized it might not be as easy as Irule.

                            So I came upon this thread and am interested in getting this functioning. I really appreciate any help.

                            Bill

                            Comment


                              #15
                              Originally posted by hunter69 View Post
                              So I came upon this thread and am interested in getting this functioning. I really appreciate any help.

                              Bill
                              Hi Bill,

                              Welcome to the club! :-) I developed the plugin first and foremost because I wanted a way to control Homeseer from iRule. To install the plugin, download the zip file from here: http://forums.homeseer.com/showthread.php?t=155438, and unzip the .dll file to your Homeseer directory (usually c:\program files\homeseer). When you restart homeseer, the plugin should appear in the setup/interfaces menu from where you can enable it.

                              For basic iRule use, in iRule create a device called 'homeseer'. Then add network codes to that device. For example you could add a network code named 'test1' with the data field set to 'test1'. Then on your device (iPad/iPod, etc) add a network gateway linked to the 'homeseer' device with the ip address of your homeseer server and an appropriate port. I use port 6969 for no particular reason other than cheap, British smutty humour.

                              Then in the plugin's config page, add a connection defined as a TCP host, listening on port 6969. After that you should be able to create an event with a trigger type of "DR IP/Serial Received Trigger" and a Raw-Text string of 'test1'.

                              That should get you started using the plugin with iRule. There's some other iRule directed functionality intended to support iRule feedbacks that you might like to try too. I'm still playing with it myself so the final shape of that piece of the plugin may change over time.

                              Regards
                              -David

                              Comment

                              Working...
                              X