Ankündigung

Einklappen
Keine Ankündigung bisher.

Need help with multiple connection TCP

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    Need help with multiple connection TCP

    Hello,
    i need to start recording in 6 Mobotix cams simultaneously, but i have no luck.
    Only 2 or 3 cams starts recording, other doesn't.
    I've tried many times with different pieces of code, but with no luck.
    I don't understand why not ALL cams starts recording, only the first 2 or 3 random.
    Can someone help me ?

    [highlight=epc]
    TCP_MXREC10=5
    TCP_MXREC11=5
    TCP_MXREC15=5
    TCP_MXREC12=5
    TCP_MXREC14=5
    TCP_MXREC5=5
    evTrig= Event triggered by Microwave motion detectors
    if evTrig then {
    // Mobotix Nord 10
    TCP_MXREC10=connecttcp(8000u16,192.168.1.10) ;
    // Mobotix Sud 11
    TCP_MXREC11=connecttcp(8000u16,192.168.1.11) ;
    // Mobotix Ingresso360 15
    TCP_MXREC15=connecttcp(8000u16,192.168.1.15) ;
    // Mobotix Ovest 12
    TCP_MXREC12=connecttcp(8000u16,192.168.1.12) ;
    // Mobotix Garage360 14
    TCP_MXREC14=connecttcp(8000u16,192.168.1.14) ;
    // Mobotix Est 5
    TCP_MXREC5=connecttcp(8000u16,192.168.1.5) ;
    } endif
    // After connection OK, send telegram
    if after(TCP_MXREC10==0,1000u64) then sendtcp(8000u16,192.168.1.10,$REC$);closetcp(8000u 16,192.168.1.10) endif
    if after(TCP_MXREC11==0,1000u64) then sendtcp(8000u16,192.168.1.11,$REC$);closetcp(8000u 16,192.168.1.11) endif
    if after(TCP_MXREC15==0,1000u64) then sendtcp(8000u16,192.168.1.15,$REC$);closetcp(8000u 16,192.168.1.15) endif
    if after(TCP_MXREC12==0,1000u64) then sendtcp(8000u16,192.168.1.12,$REC$);closetcp(8000u 16,192.168.1.12) endif
    if after(TCP_MXREC14==0,1000u64) then sendtcp(8000u16,192.168.1.14,$REC$);closetcp(8000u 16,192.168.1.14) endif
    if after(TCP_MXREC5==0,1000u64) then sendtcp(8000u16,192.168.1.5,$REC$);closetcp(8000u1 6,192.168.1.5) endif
    [/highlight]

    #2
    Ciao Massimo,

    your demand could be solved easier by a macro based solution.

    This is the untested code for a macro (save the code within a text file called IP_Cam_Recording.lib):

    [highlight=epc]
    //
    // -----------------------------------------------------------------------------------------------------------
    // Macro for Event Based IP Camera Recording
    // -----------------------------------------------------------------------------------------------------------
    //

    :begin IPCamRecording(Cam_Start, Cam_IP, Cam_Port, Cam_Command)

    Cam_Init = after(systemstart(), 5000u64)

    Cam_Command = $$
    Cam_Start = 0b01
    Cam_IP = 0u32
    Cam_Port = 0u16
    Cam_IP_Connected = 0u32
    Cam_Port_Connected = 0u16
    Cam_TCP_Error_Counter = 0u08
    Cam_TCP_ConnectionState = 6u08

    Cam_Query_State_Idle = 0u08
    Cam_Query_State_QueryStarted = 1u08
    Cam_Query_State_QuerySuccess = 2u08
    Cam_Query_State = Cam_Query_State_Idle

    if (after(Cam_Init,1u64) or Cam_Start == EIN) \\
    and Cam_TCP_ConnectionState >= 2u08 then \\
    Cam_Init = AUS; \\
    Cam_TCP_ConnectionState = connecttcp(Cam_Port, Cam_IP) \\
    endif

    if change(Cam_TCP_ConnectionState) \\
    and Cam_TCP_ConnectionState == 0u08 then \\
    Cam_TCP_Error_Counter = 0u08; \\
    sendtcp(Cam_Port, Cam_IP,Cam_ Command); \\
    Cam_Query_State = Cam_Query_State_QuerySuccess \\
    endif

    if change(Cam_TCP_ConnectionState) \\
    and Cam_TCP_ConnectionState >= 2u08 \\
    and Cam_TCP_ConnectionState <= 6u08 \\
    and Cam_TCP_Error_Counter <= 5u08 then \\
    Cam_TCP_Error_Counter = Cam_TCP_Error_Counter + 1u08; \\
    Cam_Init = EIN \\
    endif

    if after(Cam_Query_State == Cam_Query_State_QuerySuccess, 1u64) \\
    and (Cam_TCP_ConnectionState == 0u08 \\
    or Cam_TCP_ConnectionState == 1u08) then \\
    closetcp(Cam_Port, Cam_IP); \\
    Cam_TCP_ConnectionState = 7u08; \\
    Cam_Query_State = Cam_Query_State_Idle \\
    endif

    :end
    [/highlight]

    Within the main code section you need to include the macro and start it by an if clause, e.g.:

    if evTrig1 == EIN then IPCamRecording(EIN, 192.168.1.10, 8000u16, $REC$) endif

    if evTrig2 == EIN then IPCamRecording(EIN, 192.168.1.11, 8000u16, $REC$) endif

    tante saluti

    Michael

    Kommentar


      #3
      Sehr geehrter Herr Michael,
      Danke! Ich pruefe und gebe ihnen Bescheid ob diese Macro funktioniert.
      Eine Frage:
      Does the Macro run on another thread?

      Massimo

      Kommentar


        #4
        I am using the general structure of the TCP process within several macros.

        best regards

        Michael

        Kommentar


          #5
          With some modifications it works, but it seems that instantiating multiple TCP connection at the same time is not good.
          Approximately, between each connecttcp i need to put a sleep of at least 150 ms.
          Same between connecttcp and sendtcp.

          Thanks for your help.

          Kommentar


            #6
            Good news.

            Sometimes I appreciate also to include delays in the process.

            Please share the final macro with the community by uploading it here.

            Kommentar


              #7
              Zitat von TheMax74 Beitrag anzeigen
              With some modifications it works, but it seems that instantiating multiple TCP connection at the same time is not good.
              Approximately, between each connecttcp i need to put a sleep of at least 150 ms.
              Although this runs and is shurely a good coding pratice:
              To really find, what is going on, a wireshark log is needed. In Gerneral, it should be possible to open serveral connections at a time (in one processing cycle). It could be, that the timing of the connections becomes a bit slower, and e.g. the camera doesnot accept the packets or vice a versa.
              Same between connecttcp and sendtcp.
              This holds for this, too. A log would be necessary.
              offizielles Supportforum für den Enertex® EibPC: https://knx-user-forum.de/eibpc/
              Enertex Produkte kaufen

              Kommentar


                #8
                Featurewunsch....

                nachdem vor Allem im SoHo Bereich Switche mit Port-Mirror selten sind:
                wär das nicht ein Featurewunsch für den eibPC?
                Natürlich nur den Traffic der den eibPC betrifft...

                Die die IP-Aktionen häufig Probleme durch nicht nachvollziehbares Verhalten auslösen, wäre so ein Logger eine feine Sache
                EPIX
                ...und möge der Saft mit euch sein...
                Getippt von meinen Zeigefingern auf einer QWERTZ Tastatur

                Kommentar

                Lädt...
                X