Announcement

Collapse
No announcement yet.

SNAPConnect RPC call through E10

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

  • SNAPConnect RPC call through E10

    Hi, I have questions regarding SNAPConnect and E10.

    My SNAPConnect application is running in PC(SNAPConnect Python library 3.1) and I would like to invoke RPC call(unicast or mcast) through E10 to SNAP network. I wonder opening serial port in PC and in E10 and have several questions:

    1 Do I need to stop Usermain.py in E10 because it opens serial port to connect to RF engine before my SNAPConnect application can talk to SNAP network directly

    2 If the answer to question 1 is no, then how to do that?

    3 When I try to launch the XML‐RPC process in E10 by typing "python /root/snapconnect/SnapXmlRpc.pyc", I got error messages:

    Traceback (most recent call last):
    File "snapconnect\SnapXmlRpc.py", line 13, in <module>
    File "snapconnect\snap.py", line 20, in <module>
    File "snapconnect\dispatchers.py", line 12, in <module>
    ImportError: No module named snaplib



    Please help. Thanks.
    Last edited by Roland338; 08-21-2013, 07:36 AM.

  • #2
    @Roland338 - note that the SNAP Connect Python library is much different thing to the previous XML-RPC client/server installation.
    1 Do I need to stop Usermain.py in E10 because it opens serial port to connect to RF engine before my SNAPConnect application can talk to SNAP network directly

    2 If the answer to question 1 is no, then how to do that?
    Yes, you can certainly stop this process. UserMain.py is simply an example way to do things. This is platform on which you are free to start things as you see fit (there are always several ways to do things on a Linux box).

    You can/should make the serial connections in your own application that uses the SNAP Connect library.
    sigpic
    Proven Solutions for the Internet of Things
    www.synapse-wireless.com

    Comment


    • #3
      If I don't want to stop usermain.py which open serial connection to RF engine,then how can my application(Snapconnect applciation running in PC with Snapconnect python library 3.1) talk to SNAP network?

      Comment


      • #4
        Is there a reason why you would not just combine the contents of the UserMain example into your application? Seems like you are only interested in UserMain because it opens the serial port. You can do this from any app.

        There are many ways to share information between two python applications running on the same box - Ex. Sockets, Google ProtocolBufs, shared memory, etc...
        sigpic
        Proven Solutions for the Internet of Things
        www.synapse-wireless.com

        Comment


        • #5
          In our use case, E10 works as Hub to manage remote units. SNAPConnect application running in PC works as user GUI. So is it possible for my application to talk to SNAP network through E10? For example, invoking rpc call mcast_rpc(1, 5, "vmStat", 4, 10) in my application.

          Providing sample code really appreciated.

          Comment


          • #6
            Yes, you can connect to an E10 application from a PC GUI (SNAP Connect based) over TCP/IP.

            There are two API functions to do this:

            Code:
            accept_tcp(self, auth_info=server_auth, ip='', port=snaptcp.SNAP_IP_PORT, tcp_keepalives=False, forward_groups=None)
            and

            Code:
            connect_tcp(self, host, auth_info=client_auth, port=None, retry_timeout=60, secure=False, forward_groups=None, tcp_keepalives=False, cache_dns_lookup=False)
            One side (doesn't matter which) will initiate with a "connect" the other waits for connections with an "accept"

            The SNAP Connect Python Package manual has more information

            Once connected, your PC application can send RPCs out into the remote RF network (and receive responses too).
            sigpic
            Proven Solutions for the Internet of Things
            www.synapse-wireless.com

            Comment


            • #7
              Check out the "Remote Connection Capabilities" section in the SNAP Connect Python Package manual
              Last edited by Jheath; 08-23-2013, 01:24 PM. Reason: typo
              sigpic
              Proven Solutions for the Internet of Things
              www.synapse-wireless.com

              Comment


              • #8
                Thanks!

                I am new to E10 and first time to use remote connection. After TCP connection is built between PC SNAPConnec application and E10, how to invoke RPC call? Is it the same way as SNAPConnect application attached on bridge node. For example:

                def main():
                global comm
                funcdir = {
                'tellVmStat': tellVmStat,
                'returnE10Addr' : returnE10Addr,

                }

                comm = snap.Snap(funcs=funcdir)
                comm.connect_tcp(host='192.168.1.18', auth_info=client_auth,port=None, retry_timeout=60, secure=False,tcp_keepalives=False, cache_dns_lookup=False)
                comm.mcast_rpc(1, 5, "vmStat", 4, 10)
                comm.loop()

                Is above code correct for the application to use TCP to communicate with SNAP network through E10? I found that I got message"Authenticated connection established" but my tellVmStat() didn't get called.

                Update: comm.rpc() call no problem. comm.mcast_rpc() didn't work
                Last edited by Roland338; 08-23-2013, 10:02 AM.

                Comment


                • #9
                  Originally posted by Roland338 View Post
                  After TCP connection is built between PC SNAPConnec application and E10, how to invoke RPC call? Is it the same way as SNAPConnect application attached on bridge node. For example:

                  def main():
                  global comm
                  funcdir = {
                  'tellVmStat': tellVmStat,
                  'returnE10Addr' : returnE10Addr,

                  }

                  comm = snap.Snap(funcs=funcdir)
                  comm.connect_tcp(host='192.168.1.18', auth_info=client_auth,port=None, retry_timeout=60, secure=False,tcp_keepalives=False, cache_dns_lookup=False)
                  comm.mcast_rpc(1, 5, "vmStat", 4, 10)
                  comm.loop()
                  Yes, the SNAP system will take care of routing out the appropriate interfaces. In your case, the mcast RPC will be sent out every interface that has been connected/enabled.

                  Side Note: Look into using the .poll() vs. the .loop() method if you would like to execute other tasks while awaiting incoming RPCs.

                  Originally posted by Roland338 View Post
                  Is above code correct for the application to use TCP to communicate with SNAP network through E10? I found that I got message"Authenticated connection established" but my tellVmStat() didn't get called.

                  Update: comm.rpc() call no problem. comm.mcast_rpc() didn't work
                  See the note above regarding the use of the .poll() method instead of .loop().

                  However, there should be not issue in receiving and processing a mcast vs. ucast message.

                  Using a sniffer, do you see the tellVmStat() or vmStat() go out over the RF?

                  Side Note for others tuning in: Watch that the TTL is sufficient to reach the destination node. Serial connections (like the one between the E10 bridge and the E10 Linux software) count as a hop.
                  sigpic
                  Proven Solutions for the Internet of Things
                  www.synapse-wireless.com

                  Comment


                  • #10
                    Hi Jonathan,

                    With Sniffer,I didn't see vmStat going out of RF but for Unicast messages, Sniffer can catch it. It is strange.

                    I did check E10 bridge node NVs Multi-cast Processed Groups(1), Multi-cast Forwarded(1) Groups,Mesh Override(0), Mesh Routing Maximum Hop Limit(5),Mesh Routing Initial Hop Limit(2),Mesh Routing RREQ Retries(3). The NVs setting seems fine.

                    With Portal, I did remote connection to E10. Everything works fine.

                    I modified the message loop() to poll(). There is no difference for the result.


                    Any clues on this? I attached my source code. Please have a look.Thanks!
                    Attached Files
                    Last edited by Roland338; 08-23-2013, 02:41 PM. Reason: add files

                    Comment


                    • #11
                      Originally posted by Roland338 View Post
                      With Sniffer,I didn't see vmStat going out of RF but for Unicast messages, Sniffer can catch it. It is strange.
                      What addresses are tied to your E10 (Bridge and Linux), Remote Device, and SNAPConnect software (PC)?

                      Are you attempting to send the RPC from the E10 or the PC app?

                      I would suggest defining a little function on each device that either prints a message to the console or blinks an LED, then call this using both the .rpc() and .mcast_rpc() functions
                      sigpic
                      Proven Solutions for the Internet of Things
                      www.synapse-wireless.com

                      Comment


                      • #12
                        Originally posted by Roland338 View Post
                        I did check E10 bridge node NVs Multi-cast Processed Groups(1), Multi-cast Forwarded(1) Groups,Mesh Override(0), Mesh Routing Maximum Hop Limit(5),Mesh Routing Initial Hop Limit(2),Mesh Routing RREQ Retries(3). The NVs setting seems fine.
                        These are correct. Try deleting your nvparam.dat file as well on both E10 and PC to set to the default values too.
                        sigpic
                        Proven Solutions for the Internet of Things
                        www.synapse-wireless.com

                        Comment


                        • #13
                          Originally posted by Jheath View Post
                          What addresses are tied to your E10 (Bridge and Linux), Remote Device, and SNAPConnect software (PC)?

                          Are you attempting to send the RPC from the E10 or the PC app?

                          I would suggest defining a little function on each device that either prints a message to the console or blinks an LED, then call this using both the .rpc() and .mcast_rpc() functions

                          My PC Snapconnect app----- 000020
                          E10 Bridge ------------------0480AD
                          E10 Linux ------------------5E4719
                          Remote unit----------------04BAFE

                          I was attempting sending RPC call from my PC app to remote units through E10. My RPC call from PC app to remote unit 04BAFE through E10 is no problem. My mcast_rpc() from PC app is failed and that is the problem. In my case,Portal can communicate with my remote units through E10 whatever it is unicast or multicast RPC call and I am wondering how Portal does it.

                          The output info from PC app is following:
                          Permanent license created on 2012-02-14 14:14:45.343000 for 000020
                          2013-08-27 09:44:12 DEBUG: Initiating connection to 192.168.1.18:48625
                          2013-08-27 09:44:12 DEBUG: New SNAPtcpConnection 0.0.0.0:49213 to
                          192.168.1.18:48625
                          2013-08-27 09:44:12 DEBUG: send: 0001.vmStat(4, 10)
                          2013-08-27 09:44:12 DEBUG: send: 04bafe.callback('getHw', 'gethwver')
                          2013-08-27 09:44:12 DEBUG: Sent RREQ for 04bafe
                          2013-08-27 09:44:12 DEBUG: Authenticated connection established
                          2013-08-27 09:44:12 DEBUG: RREQ retry #1 for 04bafe
                          2013-08-27 09:44:12 DEBUG: Added route to 04bafe
                          2013-08-27 09:44:12 DEBUG: RREP hop limit reached or was for our address
                          2013-08-27 09:44:12 DEBUG: Added route to 04bafe
                          2013-08-27 09:44:12 DEBUG: RREP hop limit reached or was for our address
                          2013-08-27 09:44:13 DEBUG: rpc: 04bafe.getHw('1004',)
                          getHw from 04bafe of version 1004
                          2013-08-27 09:44:27 DEBUG: Route entry for 5e4719 removed because timeout reached
                          2013-08-27 09:44:27 DEBUG: Removing route entry for 5e4719
                          2013-08-27 09:44:28 DEBUG: Route entry for 04bafe removed because timeout reached
                          2013-08-27 09:44:28 DEBUG: Removing route entry for 04bafe
                          Last edited by Roland338; 08-28-2013, 09:35 AM. Reason: add debug info

                          Comment


                          • #14
                            Originally posted by Roland338 View Post

                            I was attempting sending RPC call from my PC app to remote units through E10. My RPC call from PC app to remote unit 04BAFE through E10 is no problem. My mcast_rpc() from PC app is failed and that is the problem. In my case,Portal can communicate with my remote units through E10 whatever it is unicast or multicast RPC call and I am wondering how Portal do it.
                            Does the mcastRpc from your PC app have adequate TTL to cover the hops needed to reach the end node (04BAFE)?

                            What does a sniffer show that's different (Portal's mcast vs. your PC App)?
                            sigpic
                            Proven Solutions for the Internet of Things
                            www.synapse-wireless.com

                            Comment


                            • #15
                              Originally posted by Roland338 View Post
                              The output info from PC app is following:
                              Permanent license created on 2012-02-14 14:14:45.343000 for 000020
                              2013-08-27 09:44:12 DEBUG: Initiating connection to 192.168.1.18:48625
                              2013-08-27 09:44:12 DEBUG: New SNAPtcpConnection 0.0.0.0:49213 to
                              192.168.1.18:48625
                              2013-08-27 09:44:12 DEBUG: send: 0001.vmStat(4, 10)
                              2013-08-27 09:44:12 DEBUG: send: 04bafe.callback('getHw', 'gethwver')
                              2013-08-27 09:44:12 DEBUG: Sent RREQ for 04bafe
                              2013-08-27 09:44:12 DEBUG: Authenticated connection established
                              2013-08-27 09:44:12 DEBUG: RREQ retry #1 for 04bafe
                              2013-08-27 09:44:12 DEBUG: Added route to 04bafe
                              2013-08-27 09:44:12 DEBUG: RREP hop limit reached or was for our address
                              2013-08-27 09:44:12 DEBUG: Added route to 04bafe
                              2013-08-27 09:44:12 DEBUG: RREP hop limit reached or was for our address
                              2013-08-27 09:44:13 DEBUG: rpc: 04bafe.getHw('1004',)
                              getHw from 04bafe of version 1004
                              2013-08-27 09:44:27 DEBUG: Route entry for 5e4719 removed because timeout reached
                              2013-08-27 09:44:27 DEBUG: Removing route entry for 5e4719
                              2013-08-27 09:44:28 DEBUG: Route entry for 04bafe removed because timeout reached
                              2013-08-27 09:44:28 DEBUG: Removing route entry for 04bafe
                              This debug only indicates that a unicast message was sent (it follows the route formation process then flush due to timers).
                              sigpic
                              Proven Solutions for the Internet of Things
                              www.synapse-wireless.com

                              Comment

                              X