Home AMX User Forum AMX General Discussion

help to restablish a broken communication

Hello!

I?ve got a problem with the communications between the master (telnet port) and a videoconference device.

The problem is that the videoconference initializes much later than the master, so when i connect both at the same time, the master tries to set a communication socket with the videoconference, and it fails, so i have to reset the master after the videoconference is fully online, to retry to establish the communication.
The communication protocol to connect the videoconference through the telnet port is made in a closed Duet module, so i can?t see or change any code inside.

Now i would like to know if there is a way to launch a module within a conditional statement or if a module can be created at runtime. So i could launch the communication module after the videoconference is online.
If it is not possible, is there a way to reset the telenet port to restablish the communication??

Code example:

dvVidConf = 0:3:0 // videoconference device
vdvVidConf = 41001:1:0

define_module 'LifeSize_Room_Comm_dr1_0_0' mVidConfDev1(vdvVidConf, dvVidConf)


Thanks to all!!!!!!

Comments

  • DHawthorneDHawthorne Posts: 4,584
    I'm reasonably certain any inclusion of the keyword DEFINE_MODULE gets processed regardless of it's place in code, and without regard to any code block it's in; in other words, I don't thin you can delay startup.

    If that is how the equipment behaves, the module, simply put, needs a way to delay opening it's connection or resetting it. There are provisions in this in the standard API ... the REINIT send_command, in particular. If the module conforms properly, you should be able to send that after your startup delay to connect or re-connect.
  • MorgoZMorgoZ Posts: 116
    Hello and thanks,

    the problem is that if the videoconference is not online when the master startup, the connection socket can not be established when master is online (because videoconference is not), and no command can be sent to the videoconference once it is online, because there is no communication socket open.
    So i would need to establish the communication with the videoconference some minutes after the master is online.... or maybe to try to reconnect the telnet port (don?t know if this can be done) or delaying the master startup.

    Salutes!
  • PhreaKPhreaK Posts: 966
    What DHawthorne was getting at is that you can use a wait in your define start to give your codec suffecient time to start up then send it a 'REINIT' command (if it conforms to the the SNAPI) to establish comms once its up and going.
  • MorgoZMorgoZ Posts: 116
    I?m sorry, but i still don?t understand what do you mean to do.

    A wait in my define start? Do you mean to include a Wait inside the Start code of the module? I can?t, because the module is pre-compiled and closed, i don?t have access to its code.

    Or if you meant to put a Wait in my Main Start code (not the Start of the module) with a "REINIT" command, it will have no effect, because the problem is that the connection to the videoconference is made when the module is initiated (at the master online event), at this time, the videoconference is not ready to establish a connection, so even with a Wait of an hour and a REINIT, any command send to the videoconference will get lost, because the connection at the initialization didn?t work.... so there is no connection at all, and then, no commands can be sent even with the videoconference online.

    Thanks for the answers anyway ;)
    Salutes.
  • PhreaKPhreaK Posts: 966
    The 'REINIT" command doesn't actually go to the physical video conference unit. By sending that command to the virtual device used by the module instance you are instructing the module to re-initiallize, re-establishing communications with the real device in the process.

    Basically:
    DEFINE_START
    
    WAIT nTimeForCodecToStart {
        SEND_COMMAND vdvVC, "'REINIT'"
    }
    
    DEFINE_MODULE 'Module_Name' mdlVC(vdvVC, dvVC)
    

    This is all assuming that the module you are using conforms to the SNAPI.
  • MorgoZMorgoZ Posts: 116
    If i do that, the "DEFINE_MODULE 'Module_Name' mdlVC(vdvVC, dvVC)" will launch before the Wait statement, at the master startup. Because the videoconference is offline, the socket will be close forever, and no communication with the videoconfernce available.
    So, when the wait completes, the REINIT command will be sent nowhere, because the socket was not intialized.

    I hope to have explained it properly.

    Thanks for your help.
  • ericmedleyericmedley Posts: 4,177
    MorgoZ wrote: »
    If i do that, the "DEFINE_MODULE 'Module_Name' mdlVC(vdvVC, dvVC)" will launch before the Wait statement, at the master startup. Because the videoconference is offline, the socket will be close forever, and no communication with the videoconfernce available.
    So, when the wait completes, the REINIT command will be sent nowhere, because the socket was not intialized.

    I hope to have explained it properly.

    Thanks for your help.

    The module probably has a set of commands that it runs to initiate a conversation with the Teleconf unit. These, as you point out, are probably along the lines of:
    1) open an IP port
    2) attempt to communicate with the device.
    3) if attempt works, send commands to device to determine its status and setup things that need to be setup.
    4) if attempted communication fails, wait some period and try again.
    5) if further attempts fail, give up and await insturctions.

    The REiNIT command being sent to the virtual device probably restarts this process in the module. That's the common usage for the REINIT command. It basically says, "I need you to start over from the beginning."

    So, if you know that a power cycle recovery takes the AMX system (let's say) 45 seconds, to get going and the teleconference unit takes say 2 minutes, put a 900 tick wait and an 'REINIT' command and that will restart the module 90 seconds after the AMX program starts running. You'll probably need to experiment with the timing a bit.

    I think your cofusion is that you think that the module might be trying to communicate right at the beginning of the program startup. This may or may not be the case. Most modules I know typically wait about 20-30 seconds before they try anything. We all know by now to give anything in startup a few seconds for things to settle down.

    hope that helps
    e
  • MorgoZ wrote: »
    If i do that, the "DEFINE_MODULE 'Module_Name' mdlVC(vdvVC, dvVC)" will launch before the Wait statement, at the master startup. Because the videoconference is offline, the socket will be close forever, and no communication with the videoconfernce available.
    So, when the wait completes, the REINIT command will be sent nowhere, because the socket was not intialized.

    I hope to have explained it properly.

    Thanks for your help.

    I'm thinking that you did not set the PROPERTIES of the Module. This is where you input the IP address of the CODEC. Below are the instructions from the help file with the module that you are using. It makes note to send a REINIT command to the module after changing properties (like the IP address);

    Set the value of property <key> to <value>. This must be followed by the REINIT command to take effect. These values are not initialized by default.

    <key> : IP_Address
    <value> : string representing the IP Address of the
    Device, which may be obtained from it?s GUI

    <key> : User_Name
    <value> : the user name to use for login if using IP
    Control. The device default is ?auto?.

    <key> : Password
    <value> : the password to use for login if using IP
    Control. The device default is ?lifesize?.

    Example: send_command vdvVC,'PROPERTY-IP_Address,192.168.1.100'
  • Here's an example from AMX's implemetation in their demo code.

    DATA_EVENT[vdvVidConf]
    {
    ONLINE:
    {
    // For IP control, set IP address here:
    // SEND_COMMAND vdvVidConf,'PROPERTY-IP_Address,192.168.100.142'

    // If the login password is not the default ("lifesize") add it here:
    // SEND_COMMAND vdvVidConf,'PROPERTY-Password,lifesize'

    // After any PROPERTY- commands, send REINIT
    // SEND_COMMAND vdvVidConf,'REINIT'
    }
    }
  • MorgoZMorgoZ Posts: 116
    Ok, thanks to all

    the problem was that the f*****ing REINIT command functions ONLY if the first time that you execute it, the videoconference is ON, if the videoconference is OFF and you execute de REINIT, nothing happens (obviously), but if later you turn on the videoconference and re-execute the REINIT command.... nothing happens and the videoconference will be unplugged to the system forever.

    If the REINIT command is executed when the videoconference is ON (everything ok), and then you reset the videoconference (not the master) and try to REINIT again.... nothing happens and the videoconference will be unplugged to the system forever.

    For the rest of the situations, the REINIT works correct, it means when the master is reset or when the videoconference AND the master are reset.

    So, to solve my problem i made a not so clean code, in wich i test if the videoconference is on or off (testing the telnet port of its IP), so the REINIT command is executed the first time only if the videoconference is on, and if at any time it detects that the videoconference is off, the client is asked to reset the master.
    So for me is important to get the REINIT command out of the online event, as it is recommended, to first test if the videoconference is ready or not to get REINIT.


    The code:

    *** The "state" variable tell if the videoconference is off(0), on(1) or a connection error (3)
    *** vcConPort = 0:3:0

    DATA_EVENT[vcConPort]
    {
    onerror:
    {

    state = 3

    }
    }


    wait(600)
    {
    vidConfLastState = state

    ip_client_open(vcPort,vcIP,1)
    //Wait for error
    wait(400) 'iniciarVideoconferencia'
    {

    if(state != 3)
    {
    //No error
    ip_client_close(vcPort)
    //Init videoconference
    if(vidConfLastState == 0)
    {
    SEND_COMMAND vdvVidConf,'REINIT'
    }
    }
    else
    {
    //Error
    //If the connection was open, send message
    if(vidConfLastState == 1)
    {
    Error('Error al conectar con videoconferencia. Se ha perdido la conexi?n con la master iniciada, es necesario reinicio de Master.','')
    SiNoPopup('Se ha perdido la conexi?n con la videoconferencia. Es necesario comprobar si recibe alimentaci?n y reiniciar el sistema. ?Desea reiniciar el sistema ahora?')

    wait_until (respuestaSiNo != 0)
    {
    if(respuestaSiNo == 1)
    {
    //Reboot of TPI
    reboot(dvTpiProGeneral)
    //Reboot of master
    reboot(0:0:0)
    }
    }

    }
    state = 0
    }
    }
    }


    P.D: Could anyone tell me what are the tags to insert code in a post?
  • MorgoZ wrote: »
    Ok, thanks to all

    the problem was that the f*****ing REINIT command functions ONLY if the first time that you execute it, the videoconference is ON, if the videoconference is OFF and you execute de REINIT, nothing happens (obviously), but if later you turn on the videoconference and re-execute the REINIT command.... nothing happens and the videoconference will be unplugged to the system forever.

    If the REINIT command is executed when the videoconference is ON (everything ok), and then you reset the videoconference (not the master) and try to REINIT again.... nothing happens and the videoconference will be unplugged to the system forever.

    For the rest of the situations, the REINIT works correct, it means when the master is reset or when the videoconference AND the master are reset.

    So, to solve my problem i made a not so clean code, in wich i test if the videoconference is on or off (testing the telnet port of its IP), so the REINIT command is executed the first time only if the videoconference is on, and if at any time it detects that the videoconference is off, the client is asked to reset the master.
    So for me is important to get the REINIT command out of the online event, as it is recommended, to first test if the videoconference is ready or not to get REINIT.


    The code:

    *** The "state" variable tell if the videoconference is off(0), on(1) or a connection error (3)
    *** vcConPort = 0:3:0

    DATA_EVENT[vcConPort]
    {
    onerror:
    {

    state = 3

    }
    }


    wait(600)
    {
    vidConfLastState = state

    ip_client_open(vcPort,vcIP,1)
    //Wait for error
    wait(400) 'iniciarVideoconferencia'
    {

    if(state != 3)
    {
    //No error
    ip_client_close(vcPort)
    //Init videoconference
    if(vidConfLastState == 0)
    {
    SEND_COMMAND vdvVidConf,'REINIT'
    }
    }
    else
    {
    //Error
    //If the connection was open, send message
    if(vidConfLastState == 1)
    {
    Error('Error al conectar con videoconferencia. Se ha perdido la conexi?n con la master iniciada, es necesario reinicio de Master.','')
    SiNoPopup('Se ha perdido la conexi?n con la videoconferencia. Es necesario comprobar si recibe alimentaci?n y reiniciar el sistema. ?Desea reiniciar el sistema ahora?')

    wait_until (respuestaSiNo != 0)
    {
    if(respuestaSiNo == 1)
    {
    //Reboot of TPI
    reboot(dvTpiProGeneral)
    //Reboot of master
    reboot(0:0:0)
    }
    }

    }
    state = 0
    }
    }
    }


    P.D: Could anyone tell me what are the tags to insert code in a post?

    <code>
    put your code here
    </code>
    < is [
    > is]

    I had to write it this way so you could see it.
  • [noparse]
    [/noparse]
         your code here
    [noparse]
    
    [/noparse]
    your code here
    

    [/OT]
  • MorgoZMorgoZ Posts: 116
    Thanks!!!
    Thanks in code ;)
    
Sign In or Register to comment.