IP programming

alvinyowalvinyow Junior MemberPosts: 27
Hi there,
I would like to have a full proof connection on the LAN. I came to know that the ip connection will be down automatically after several idle timing. So wat i did is to write a code to detect the offline/online activity of the network. A re-connection will be issue "IP open connection" if it is offline. Wandering if this is the best way to handle IP networking?

I had try with some IP devices and the open connection is easily done. But if the connection is down or disconnected. The connection will be gone forever or you will need to wait for several minute to hour before you can get it up again.

The fastest way to go around this is to reset the Master. But make sure that the wireless MVP touch panel is awake. I come to face lots of funny problem even by the MVP connect to the Master. If you happen to hv the master ready to perform while your MVP battery going to be flat and need to reboot after plug in the power adapter. The connectivity issue will surface.

I really need to understand more how the NI handle the IP connection well. Lots of problems like "connection refuse", error connecting, bla bla bla.....
Anyone with a great knowledge how to handle the IP connection would be much appreciate with your help. Someone had told me using the timeline to do the open and close connection at the regular interval. I dun really like this idea. But if there is no other way round to handle this. I might really need to attend to the idea above....

Many thanks for your reading.
Cheers

Comments

  • ericmedleyericmedley Senior Member - 4000+ posts Posts: 4,159
    I may not be understanding your issue correctly.

    I suppose I get around this because I choose to send the time to my touch panels from the master. I have a general update of all this done every second. Time/Date/Current outside temp / current inside temp for that zone, etc...

    This continuous communication must keep the IP connection alive.

    If you're having issues you might also check the settings of the NIC card. Although it will technically run at 100mb, I find that I need to force the card to run at 10mb / half duplex. If you think about what's going on, you really don't need the speed. 10meg will get the job done. I've found that trying to run the card at 100 seems to cause problems like you're describing.
  • alvinyowalvinyow Junior Member Posts: 27
    Sorry for my poor english.

    >>I suppose I get around this because I choose to send the time to my touch panels from the master. I have a general update of all this done every second. Time/Date/Current outside temp / current inside temp for that zone, etc...

    This continuous communication must keep the IP connection alive.
    >>

    So in order to keep the connection alive, I must need to use the timeline event. Instead of open and close connection, I could probably sending a null character to the device.

    >>If you're having issues you might also check the settings of the NIC card. Although it will technically run at 100mb, I find that I need to force the card to run at 10mb / half duplex. If you think about what's going on, you really don't need the speed. 10meg will get the job done. I've found that trying to run the card at 100 seems to cause problems like you're describing.
    >>

    But I'm not using any NIC here but a ethernet to serial device. Seems impossible to force the connection back to 10mb. The devices comes at default speed of 100mb. How could i force the AMX to talk on 10mb instead of 100mb? Wow, this is a real supprise...

    >>
    I may not be understanding your issue correctly.
    >>

    Actually there are few issue that i raised here.
    1. Connection of MVP to NI2100.
    ==> on every occassion, when the system get start up or power up. the DATA_Event will update the panel for the latest status of the online connectivity. I had few buttons on the panel to feedback the status of the connectivity because i had few IP devices.
    What happen if the MVP is not "on" at the time NI is powering up, of course the button on the panel will not be updated. So this could be the issue as well for the wireless connection for MVP to NI. I face this quite a few times. the MVP do not connect to the NI.
    But if i had the panel ready while booting the NI, my connection is almost perfect. With all the status feedback showing.

    2. If the IP connection drop!! it is extremely hard to get it back online even you try to do some close and open connection. It just dun work. I use the diagnostic tools to monitor the problem and found some error, likes "connection refuse", "client socket already close", etc....
    I just can't get the link back. So what i had to do is to reboot the master. Then everything will just working fine.

    3. To handle the re-connection i usually do it here in the DATA_Event
    the retry time=10
    is it too short?

    DATA_EVENT[MPSSWT] //MPSSWT
    {
    ONLINE:
    { bCOnline1 = TRUE; SEND_STRING 0,"'VIDEO SWITCHER READY',13" ON[dvTP01_2,3]}
    OFFLINE:
    {
    bCOnline1 = FALSE;
    OFF[dvTP01_2,3]
    IF (bCKOpen1)
    IP_CLIENT_CLOSE(MPSSWT.port);
    WAIT RETRY_TIME1
    IP_CLIENT_OPEN(MPSSWT.port,IP1,lServerPort1,TCP);
    }
    STRING:
    {
    //SEND_STRING NG_REL,"'pong',13"
    }
    ONERROR:
    {
    SEND_STRING 0,"'ERROR MPSSWT = ',DATA.NUMBER,13"
    SWITCH(DATA.NUMBER)
    {
    CASE 9: // Socket closed in response to IP_CLIENT_CLOSE
    CASE 17: // String was sent to a closed socket
    {
    }
    DEFAULT: // All other errors. May want to re-try connection
    {
    }
    }
    }
    }

    hope you have a more clearer picture now.

    Cheers
  • ericmedleyericmedley Senior Member - 4000+ posts Posts: 4,159
    to set the ethernet card on the NI-XXXX

    Telnet into the master

    send the command:

    SET ETHERNET MODE 10 HALF

    Then reboot.

    To check your settings type in

    GET ETHERNET MODE

    My guess is it's set to Auto right now.

    I'll bet that clears up a lot of your IP problems.

    em
  • alvinyowalvinyow Junior Member Posts: 27
    Many thanks
    Will try that out tomorrow.
    Will let you know if it does improve the connectivity
    thks again
  • Joe HebertJoe Hebert Junior Member Posts: 2,154
    ericmedley wrote:
    I suppose I get around this because I choose to send the time to my touch panels from the master. I have a general update of all this done every second. Time/Date/Current outside temp / current inside temp for that zone, etc...
    I?m curious as to why you choose to send the date and time every second instead of using the built in time/date buttons? (Address port=0-setup port, Address code=date or time) Have you experienced problems with the time/date buttons?

    I?m also curious as to how you get away with sending that much data to every TP every second. I take the opposite approach and only send data when I absolutely must, especially with systems that have a 10 or more TPs.
    ericmedley wrote:
    This continuous communication must keep the IP connection alive.
    Has anyone else found this to be true? If I need to send some data to the TPs every second to insure that they stay online continuously then I?ll start doing so.
  • DHawthorneDHawthorne Junior Member Posts: 4,584
    G4 panels use the master time and date on the built-in setup port buttons. It's a better way to do it than sending explicit text strings, because server time data is broadcast via UDP, and it won't bog things down establishing individual connections. I'm definitely in Joe's camp on this: the less you send your panel, the better. In a small system it doesn't matter much, but when you get multiple masters, multiple panels, and a lot of chatty devices, extraneous messaging is the Achilles' heel in a NetLinx system and can bring it crashing down if there is too much.
  • Marc ScheibeinMarc Scheibein Junior Member Posts: 669
    Joe Hebert wrote:
    I?m curious as to why you choose to send the date and time every second instead of using the built in time/date buttons? (Address port=0-setup port, Address code=date or time) Have you experienced problems with the time/date buttons?
    Time and Date is regularly sent within the ICSP communication. Every panel will take the time and date automatically from the master it is connected to. The update is also sent within the system if it is modified from a panel. Just in some older panel firmware (can't remember what panel and version) there was a problem that the new adjusted time and date was not set from the panel to the system.
    Has anyone else found this to be true? If I need to send some data to the TPs every second to insure that they stay online continuously then I?ll start doing so.

    A panel with power supply connected (also MVPs in docking stations or used w/ power supply, or NXTs with battery base and connected power supply) will hold the conection to the master continuously. There is no normal reason for the master or the panel to drop the connection.

    If a panel is used on battery, it will also shutdown if data is sent permanently. The shutdown time set in the battery setup works independently.
  • ericmedleyericmedley Senior Member - 4000+ posts Posts: 4,159
    Joe Hebert wrote:
    I’m curious as to why you choose to send the date and time every second instead of using the built in time/date buttons? (Address port=0-setup port, Address code=date or time) Have you experienced problems with the time/date buttons?

    I’m also curious as to how you get away with sending that much data to every TP every second. I take the opposite approach and only send data when I absolutely must, especially with systems that have a 10 or more TPs.


    Has anyone else found this to be true? If I need to send some data to the TPs every second to insure that they stay online continuously then I’ll start doing so.


    One of the customizations I allow is some of our clients like to see the time on their touch panels in different time zones in different rooms. (one client has an office in Chicago, so he likes his time on his home office TP to be Central. I also have a client who lives in here and likes his two offices to reflect time of his LA office and Houston.

    I also allow them to format the time in different ways. (2:42 PM CST, 14:42EDT, etc..., with seconds, without.)

    I've not had much trouble with panels and messages. I have some installations with 25 plus touch panels per system. Perhaps you have done some with more than that and had trouble. There's more than enough bandwidth (in theory) to handle that many messages. I've never seen any sluggishness, nor missed commands as a result of how i do it.

    And, I wasn't implying that you need to send messages to keep the IP connection alive. I was just saying that perhaps it did. I've found that when I loose a NIC card it tends to be the Ethernet Setting being set to Auto instead of 10 half.
  • DHawthorneDHawthorne Junior Member Posts: 4,584
    That does explain it :). Time zone conversion I hadn't thought of, but that is one reason I would have to admit makes sending the time that way necessary.
  • ericmedleyericmedley Senior Member - 4000+ posts Posts: 4,159
    DHawthorne wrote:
    That does explain it :). Time zone conversion I hadn't thought of, but that is one reason I would have to admit makes sending the time that way necessary.

    You can file that feature in the "don't give them something they didn't ask for.." department.

    I'm always amazed at what the client finds most useful in these systems. I write 20,000 lines of code to control everything in the house. The client gets all giddy about a little thing I wrote for the kitchen. It's a 5 way egg timer that keeps cooking times for up to 5 things. The timers can warn the entire house that the cake is now done... When they show off the system, that's the first place they go, the egg timer... Sheesh... :)
  • NMarkRobertsNMarkRoberts Junior Member Posts: 455
    ericmedley wrote:
    When they show off the system, that's the first place they go, the egg timer... Sheesh... :)

    Way cool! That's going into my next residential job. Any more?
  • alvinyowalvinyow Junior Member Posts: 27
    IP Programming

    hi everyone
    So far i had the IP communication things works but in a way of using timeline to connect and reconnect at certain interval. Not a great idea but it really work. Actually this is my only last thing to do to get the IP things up and running.
    Here is another funny problem i had face today, but still dun understand why the method below won't work. This is still apply to the same project as i mention.

    1st floor system (system 1)
    NI2100, MVP7500, 16 port Hub, other network devices
    dvMaster 0:1:0
    switcher 0:2:1 (network device)

    2nd floor (system 2)
    NI2100, MVP7500, 16 port Hub, other network devices
    dvMaster 0:1:0
    switcher 0:2:2 (network device)

    Both of the floor are link together. URL had been set and connected succesfully.
    My intention is to do send data from 1st floor to 2nd floor switcher and vice versa.
    Can i do SEND_STRING 0:2:2, "$01,$82,$83,$81"???
    Will this work? I had tried many times and do some checking on the data event on the upper floor if the data arrived... but fail.
    And how can i hv both the master talk to each other? as i can't do a global variables declaration so that the remote machine can identified the local machine status. How can i do this??
    Please help...
    Many thanks.
    Alvin
  • ericmedleyericmedley Senior Member - 4000+ posts Posts: 4,159
    alvinyow wrote:
    hi everyone
    So far i had the IP communication things works but in a way of using timeline to connect and reconnect at certain interval. Not a great idea but it really work. Actually this is my only last thing to do to get the IP things up and running.
    Here is another funny problem i had face today, but still dun understand why the method below won't work. This is still apply to the same project as i mention.

    1st floor system (system 1)
    NI2100, MVP7500, 16 port Hub, other network devices
    dvMaster 0:1:0
    switcher 0:2:1 (network device)

    2nd floor (system 2)
    NI2100, MVP7500, 16 port Hub, other network devices
    dvMaster 0:1:0
    switcher 0:2:2 (network device)

    Both of the floor are link together. URL had been set and connected succesfully.
    My intention is to do send data from 1st floor to 2nd floor switcher and vice versa.
    Can i do SEND_STRING 0:2:2, "$01,$82,$83,$81"???
    Will this work? I had tried many times and do some checking on the data event on the upper floor if the data arrived... but fail.
    And how can i hv both the master talk to each other? as i can't do a global variables declaration so that the remote machine can identified the local machine status. How can i do this??
    Please help...
    Many thanks.
    Alvin

    Well,

    If you intend to do master-to-master connections like you're describing perhaps you could approach it in a different manner and avoid using the IP connection.

    One side note: It has been mentioned here before but I notice that you're rather new. So, I'll restate it. It is important when connecting masters together to not make a loop. How this is done: In the URL list of Master one, make a connection to Master 2. However, do not go to Master 2 and make an URL connection back to Master 1. That may seem counter-intuitive. However, by making one master look for another, you have already established a two-way communication. you don't need to make the 2nd connection back.

    So, back to the matter at hand.

    What I'd do is create a virtual device and map that device in both master's programs. (assuming you're putting a program in both masters)

    so...
    code in master 1
    DEFINE_DEVICE
    
    vdv_Master_Com_1= 33001:01:1
    vdv_Master_Com_2= 33002:01:2
    
    

    and
    code in master 2
    DEFINE_DEVICE
    
    vdv_Master_Com_1= 33001:01:1
    vdv_Master_Com_2= 33002:01:2
    

    Now, you can send a command to each device and see it in the master of yoru choice.

    so from master 2
    SEND_STRING vdv_Master_Com_1, "$01,$82,$83,$81"
    

    and over in master 1's code
    DATA_EVENT[vdv_Master_Com_1]
    {
    STRING:
      {
      IF(FIND_SRTING(DATA.TEXT,"$01,$82,$83,$81",1)
        {
        // DO SOMETHING
       // AFTER DOING SOMETHING...
        SEND_STRING vdv_Master_Com_2,'got the string, thanx'
        }
      }
    }
    

    then, back in master 2
    DATA_EVENT[vdv_Master_Com_2]
    {
    STRING:
      {
      IF(FIND_SRTING(DATA.TEXT,'got the string, thanx',1)
        {
        // my message has been recieved...
        }
      }
    }
    
    


    Of note is that you can also do button pushes/button_events, level changes, channel state changes/channel_events with these devices as well.

    You could map out a whole series of buttons like, for example, Buttons 1-10 toggle power for whatever device at the site of the master, buttons 11-20 switch video sources for the display device at that end, etc...

    Levels or Channels can be used to transfer a variable value from one master to another.

    a crude example:

    in master 1
    IF(Master_1_Display_power_stat<>Master_1_Display_power_stat_temp)
    {
    [vdv_Master_Com_1,101]=Master_1_Display_power_stat
    Master_1_Display_power_stat_temp=Master_1_Display_power_stat
    }
    

    then in master 2
    channel_event[vdv_Master_Com_1,101]
    {
    on:
      {Master_1_Display_power_stat=1}
    off:
      {Master_1_Display_power_stat=0}
    }
    


    You can accomplish the same thing using IP communication. I have to do this with remote masters communicating with a master I have here at my office. However, if your masters are on the same local network, I'd use the built-in features of the Netlinx system.

    hope that helps.
  • alvinyowalvinyow Junior Member Posts: 27
    Wow........

    Hi Eric,
    Many thanks for your kind reply.
    So glad to know it is work is convieniently...
    Yup, I'm rather new in AMX and being not in the complex system setup before.
    This is my first trial. You advice really usefull.
    Thanks again
    Would love to try it soon.
    Alvin
Sign In or Register to comment.