Announcement

Collapse
No announcement yet.

V1.0.0.166 - Linux and Serial Ports

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

    V1.0.0.166 - Linux and Serial Ports

    For the past few years I have been successfully using the Arduino plugin running under HS3 (latest version) under Windows.

    As part of my work to migrate to HS4, I am first migrating to Linux - my version of Windows is a big old and I don't want to purchase a new license. Linux should work fine. I have successfully moved everything running under HS3 to Linux - multiple plugins plus Jon00 helper libraries.

    The only issue I have run into is one of my Arduino plugins uses serial to communicate - not Wifi (the other uses Wifi). The issue is the Plug-ins -> Arduino Plugin -> Arduino Plugin Config running under Linux no longer provides any means to select the serial port - it's always set to WiFi. Looking at other threads there was a mention of Serial Ports under Linux not being supported but it wasn't official just what seemed like speculation.

    The interesting thing is the log file has the message:
    Sep-17 2:31:28 PM Arduino Plugin New Com port Found
    this at least implies it is aware of the com ports. I thought perhaps I could manually config the port (/dev/ttyACM0) but the board configurations appear to be stored in SQL or someplace since none of the config is in any of the .ini files that I have found.

    This particular board explicitly uses USB serial because it manages the UPS configurations and loss of power is part of its job (sort of like turning on a generator type of arrangement). As such WiFI would be highly undesirable (too many way it could break that are not part of its job to detect) - as I mentioned this worked great under Windows. The sketch running on that board is relatively complex using the Arduino API with lots of custom code running on the sketch in order to control the various devices reporting back to HS.

    Am I running into an HS3 limitation with Arduino plugin support or are serial ports simply not supported? I am totally willing to help add support if that would help - debug, etc.

    Trying to figure out how to proceed - currently I am blocked with my ability to use the Arduino plugin under Linux. Moving back to Windows does not feel like the correct solution to me.

    Thanks for any advice on how to proceed.

    -Jeff

    P.S. - Feature request - an API command to send a log entry back to HS to be logged :-) If you write a complex sketch using the API logging can be problematic getting access to it. Not talking about logging the API commands but debug info from the sketch itself. :-)

    #2
    januszczyk,

    I can confirm there is no support for com ports on Linux as I have no system to test this on and when I did add support for it which is why you are seeing logging it was a complete mess and I could not get it to function correctly. What bard type are you using as you could look at an ethernet connection and even ad POE.

    I like your idea of debugging for the API. I will add this to the list of future enhancements.


    Greig.
    Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
    X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
    Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
    Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
    Scripts =
    Various

    Comment


      #3
      enigmatheatre , januszczyk,
      If the Arduino (enigmatheatre) plug-in can communicate using an IP address, have you attempted to redirect the serial port to an IP address and then use the IP address in the plug-in?

      For example, in Linux there is a package called ser2net that will redirect your serial port to an IP address. Normally one would redirect the port for use by others. I have also used it to overcome issues in various programs that did not allow the use of the serial port located on the same hardware as the program itself.

      While I have not used ser2net with this particular plug-in, I believe nonetheless that this will work for you.

      For the ser2net.conf file entry you would use something on the order of...

      localhost,2001:raw:0:/dev/tty0:115200

      Which states...

      Use the IP address of the localhost
      Assign port 2001 to the serial port
      raw enables the port and transfers all data as-is
      Use the device tty0 for the local serial port
      Set the baud rate to 115200

      If the address of the Linux machine is 10.0.0.2
      This would redirect the local serial port tty0, to the IP:Port combination of 10.0.0.2:2001

      When you connect to 10.0.0.2:2001 it's the same as connecting to tty0, albeit with a slight processing delay.

      If you would like me to try this out for you I would be more than willing to do so.

      Hope this helps,

      Roger D

      Comment


        #4
        What Arduino board are you using? You could try an ethernet shield from a hard wired connection.

        BTW. The Znet uses ser2net to link the Zwave hat to IP using a raspberry pi. I don't think ser2net will run on an arduino so this is probably not a solution for you..

        Comment


          #5
          I have several UPS in use at my home. I use apcupsd on my Linux box to monitor the UPS. apcupsd is basically an open source copy of APC Powerchute software.

          Comment


            #6
            drhtmal,

            My mistake, you are correct. I was thinking in reverse. It's the Arduino that has to have the IP address.

            Roger D

            Comment


              #7
              On second thought…

              I stand by my original post I’m pretty sure that the method I outlined above will work for his use case. If the Arduino connects its serial port to the serial port on the Linux box then what I outlined above will work.

              Roger D

              Comment


                #8
                I can confirm there is no support for com ports on Linux as I have no system to test this on and when I did add support for it which is why you are seeing logging it was a complete mess and I could not get it to function correctly.
                I have used the .NET System.IO.Ports.SerialPort on both Linux and Windows on many applications without issues. In the Linux case there is no byte received callback so need to setup a polling timer to get the bytes from the UART before the UART fills up.

                Comment


                  #9
                  Roger D Sorry I didn't see your post.

                  I was not aware of the ser2net command... interesting. I did in fact put an ethernet shield on the board to work around the issue. However the overall size of the Arduino, relays, etc. was not too large for the housing it was in. So I ported everything to a Arduino MKRZero which is 25% of the overall size plus faster. It's not supported directly by the plugin - however if you use the API sketch then you can pretty much support anything you would like so I have it fully running and stable.

                  The primary reason I chose an MKRZero is it has a header for i2c plus there is a 2-relay shield and prototype board which has screw terminals for 4 A/D lines + power/ground. This makes it super convenient to connect to other sensors, motion detectors, etc. Most of the other Arduino I've used need additional shields or custom board work to have relays and screw headers and that means no longer small. The only minor issue the MKRZero has is no EEPROM but it does support SPI based SD cards so there are better alternatives for storing data.

                  Still I may play with the ser2net command to think about the future. Looks like it could be fun. :-)

                  Thanks for the info.
                  -Jeff

                  Comment


                    #10
                    BTW - do notifications work? I have then enabled and things like mentioned, etc are supposed to send me an email but I've never received anything. I checked spam, etc. all seems good.

                    Very odd.

                    Comment


                      #11
                      januszczyk

                      Who was the notifications question for?

                      BTW, if you try the ser2net option and you have any issues let me know. I have used this in the past with the raspberry pi and HomeSeer when the plug-in I was wanting to use did not support using any serial port other than the preselected one that was hard coded into the plug-in. I simply redirected the serial port I wanted to use on my Raspberry Pi to my local IP address and then used the IP address option in the plug-in. Worked like a treat! Have also redirected the Z-Wave serial interface to an IP address so that I could connect to it from a Windows PC and use the PC Controller software from Silicon Labs to backup the NVM.

                      Roger D

                      Comment

                      Working...
                      X