Menu

Issue with GetTime on Raspberry

sledge1977
2015-01-09
2015-01-13
  • sledge1977

    sledge1977 - 2015-01-09

    Hi,

    I tested your library on Windows and Linux and found it very usefull and
    easy to use.
    But I had a problem using it on my Raspberry and BananaPi.
    The library compiled without any problems, but the select statement blocked
    the system even though the timeout was set to 2 seconds (using the example
    provided).
    I found that the statement:
    unsigned long long milisec = now.tv_sec * 1000 + now.tv_usec / 1000.0;
    in util.cc
    evaluated to 0 on my Raspberry.
    I changed it to:
    unsigned long long milisec = (now.tv_sec*(long
    long)1000000+now.tv_usec)/1000.0;
    This works for me.

    Thanks for this great library.

    Jens

     
    • sledge1977

      sledge1977 - 2015-01-09

      Hi again,

      can you explain why you have this while loop in bool
      SocketGroup::listen(unsigned milisec, void* reference)
      while(getTime() < finTime || !executedOnce)

      I don't understand what this loop does.

      In my opinion you are loading the timer parameter of select. This blocks
      select for this time. The while loop does the same by comparing the start
      time with the current time.

      Jens

      2015-01-09 22:26 GMT+01:00 sledge1977 sledge1977@users.sf.net:

      Hi,

      I tested your library on Windows and Linux and found it very usefull and
      easy to use.
      But I had a problem using it on my Raspberry and BananaPi.
      The library compiled without any problems, but the select statement blocked
      the system even though the timeout was set to 2 seconds (using the example
      provided).
      I found that the statement:
      unsigned long long milisec = now.tv_sec * 1000 + now.tv_usec / 1000.0;
      in util.cc
      evaluated to 0 on my Raspberry.
      I changed it to:
      unsigned long long milisec = (now.tv_sec*(long
      long)1000000+now.tv_usec)/1000.0;
      This works for me.

      Thanks for this great library.

      Jens

      Issue with GetTime on Raspberry
      http://sourceforge.net/p/netlinksockets/discussion/1101132/thread/65e46006/?limit=25#5c56


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/netlinksockets/discussion/1101132/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
      • Pedro Francisco Pareja Ruiz

        Hi Jens,

        First of all: thank you for your feedback. I have never tested it in a
        raspi and I take note of your fix for the next release to expand its
        compatibility :).

        The time passed to the Listen function is not a timeout time but a absolute
        time to be processing incoming requests/messages (if I passes 200 milisecs
        It will be listening during that time, no matter if there was an incoming
        message from the beginning) and that's the reason for the loop. Maybe it
        would be interesting to add both possibilities (to be a timeout time and to
        be the time listening no matter what) what do you think?

        Kind regards,
        Pedro Pareja.

        On 9 January 2015 at 23:21, sledge1977 sledge1977@users.sf.net wrote:

        Hi again,

        can you explain why you have this while loop in bool
        SocketGroup::listen(unsigned milisec, void* reference)
        while(getTime() < finTime || !executedOnce)

        I don't understand what this loop does.

        In my opinion you are loading the timer parameter of select. This blocks
        select for this time. The while loop does the same by comparing the start
        time with the current time.

        Jens

        2015-01-09 22:26 GMT+01:00 sledge1977 sledge1977@users.sf.net:

        Hi,

        I tested your library on Windows and Linux and found it very usefull and
        easy to use.
        But I had a problem using it on my Raspberry and BananaPi.
        The library compiled without any problems, but the select statement blocked
        the system even though the timeout was set to 2 seconds (using the example
        provided).
        I found that the statement:
        unsigned long long milisec = now.tv_sec * 1000 + now.tv_usec / 1000.0;
        in util.cc
        evaluated to 0 on my Raspberry.
        I changed it to:
        unsigned long long milisec = (now.tv_sec*(long
        long)1000000+now.tv_usec)/1000.0;
        This works for me.

        Thanks for this great library.
        Jens

        Issue with GetTime on Raspberry

        http://sourceforge.net/p/netlinksockets/discussion/1101132/thread/65e46006/?limit=25#5c56

        Sent from sourceforge.net because you indicated interest in
        https://sourceforge.net/p/netlinksockets/discussion/1101132/

        To unsubscribe from further messages, please visit
        https://sourceforge.net/auth/subscriptions/


        Issue with GetTime on Raspberry
        http://sourceforge.net/p/netlinksockets/discussion/1101132/thread/65e46006/?limit=25#5c56/f2be


        Sent from sourceforge.net because you indicated interest in
        https://sourceforge.net/p/netlinksockets/discussion/1101132/

        To unsubscribe from further messages, please visit
        https://sourceforge.net/auth/subscriptions/

         
        • sledge1977

          sledge1977 - 2015-01-10

          Hi Pedro,

          thanks for your mail.

          After some time yesterday I figured the reason for this loop. Thanks for
          clarification.

          It would be good to have a second funtion, so it comes back as soon as it
          has handled the first connection.

          I'm still having problems on my raspi. Setting the timeout to 0 seems to
          cause issued on the raspberry and I can't find the reason for that.

          I'm still using your sample application chatServer.cc, setting the timeout
          to 0.
          It is going through the main while loop about 10 to 20 times. After that it
          just hangs.

          I don't know where it hangs, but it is just hanging. No error, no CPU load,
          no memory consumption.

          Any ideas where I could look?

          I inserted a few printf to see where it is, but it seems that it just stops
          in the main while loop.

          Jens

          2015-01-10 14:42 GMT+01:00 Pedro Francisco Pareja Ruiz pedropareja@users.sf.net:

          Hi Jens,

          First of all: thank you for your feedback. I have never tested it in a
          raspi and I take note of your fix for the next release to expand its
          compatibility :).

          The time passed to the Listen function is not a timeout time but a absolute
          time to be processing incoming requests/messages (if I passes 200 milisecs
          It will be listening during that time, no matter if there was an incoming
          message from the beginning) and that's the reason for the loop. Maybe it
          would be interesting to add both possibilities (to be a timeout time and to
          be the time listening no matter what) what do you think?

          Kind regards,
          Pedro Pareja.

          On 9 January 2015 at 23:21, sledge1977 sledge1977@users.sf.net wrote:

          Hi again,

          can you explain why you have this while loop in bool
          SocketGroup::listen(unsigned milisec, void* reference)
          while(getTime() < finTime || !executedOnce)

          I don't understand what this loop does.

          In my opinion you are loading the timer parameter of select. This blocks
          select for this time. The while loop does the same by comparing the start
          time with the current time.

          Jens

          2015-01-09 22:26 GMT+01:00 sledge1977 sledge1977@users.sf.net:

          Hi,

          I tested your library on Windows and Linux and found it very usefull and
          easy to use.
          But I had a problem using it on my Raspberry and BananaPi.
          The library compiled without any problems, but the select statement blocked
          the system even though the timeout was set to 2 seconds (using the example
          provided).
          I found that the statement:
          unsigned long long milisec = now.tv_sec * 1000 + now.tv_usec / 1000.0;
          in util.cc
          evaluated to 0 on my Raspberry.
          I changed it to:
          unsigned long long milisec = (now.tv_sec*(long
          long)1000000+now.tv_usec)/1000.0;
          This works for me.

          Thanks for this great library.
          Jens

          Issue with GetTime on Raspberry

          http://sourceforge.net/p/netlinksockets/discussion/1101132/thread/65e46006/?limit=25#5c56

          Sent from sourceforge.net because you indicated interest in
          https://sourceforge.net/p/netlinksockets/discussion/1101132/

          To unsubscribe from further messages, please visit
          https://sourceforge.net/auth/subscriptions/


          Issue with GetTime on Raspberry

          http://sourceforge.net/p/netlinksockets/discussion/1101132/thread/65e46006/?limit=25#5c56/f2be

          Sent from sourceforge.net because you indicated interest in
          https://sourceforge.net/p/netlinksockets/discussion/1101132/

          To unsubscribe from further messages, please visit
          https://sourceforge.net/auth/subscriptions/


          Issue with GetTime on Raspberry
          http://sourceforge.net/p/netlinksockets/discussion/1101132/thread/65e46006/?limit=25#5c56/f2be/b692


          Sent from sourceforge.net because you indicated interest in
          https://sourceforge.net/p/netlinksockets/discussion/1101132/

          To unsubscribe from further messages, please visit
          https://sourceforge.net/auth/subscriptions/

           
          • Pedro Francisco Pareja Ruiz

            Try:

            unsigned long long milisec = (now.tv_sec*(long
            long)1000+now.tv_usec)/1000.0;

            Tell me if that fix your problem.

            On 10 January 2015 at 17:09, sledge1977 sledge1977@users.sf.net wrote:

            Hi Pedro,

            thanks for your mail.

            After some time yesterday I figured the reason for this loop. Thanks for
            clarification.

            It would be good to have a second funtion, so it comes back as soon as it
            has handled the first connection.

            I'm still having problems on my raspi. Setting the timeout to 0 seems to
            cause issued on the raspberry and I can't find the reason for that.

            I'm still using your sample application chatServer.cc, setting the timeout
            to 0.
            It is going through the main while loop about 10 to 20 times. After that it
            just hangs.

            I don't know where it hangs, but it is just hanging. No error, no CPU load,
            no memory consumption.

            Any ideas where I could look?

            I inserted a few printf to see where it is, but it seems that it just stops
            in the main while loop.

            Jens

            2015-01-10 14:42 GMT+01:00 Pedro Francisco Pareja Ruiz
            pedropareja@users.sf.net:

            Hi Jens,

            First of all: thank you for your feedback. I have never tested it in a
            raspi and I take note of your fix for the next release to expand its
            compatibility :).

            The time passed to the Listen function is not a timeout time but a absolute
            time to be processing incoming requests/messages (if I passes 200 milisecs
            It will be listening during that time, no matter if there was an incoming
            message from the beginning) and that's the reason for the loop. Maybe it
            would be interesting to add both possibilities (to be a timeout time and to
            be the time listening no matter what) what do you think?

            Kind regards,
            Pedro Pareja.

            On 9 January 2015 at 23:21, sledge1977 sledge1977@users.sf.net wrote:

            Hi again,

            can you explain why you have this while loop in bool
            SocketGroup::listen(unsigned milisec, void* reference)
            while(getTime() < finTime || !executedOnce)

            I don't understand what this loop does.

            In my opinion you are loading the timer parameter of select. This blocks
            select for this time. The while loop does the same by comparing the start
            time with the current time.

            Jens

            2015-01-09 22:26 GMT+01:00 sledge1977 sledge1977@users.sf.net:

            Hi,

            I tested your library on Windows and Linux and found it very usefull and
            easy to use.
            But I had a problem using it on my Raspberry and BananaPi.
            The library compiled without any problems, but the select statement blocked
            the system even though the timeout was set to 2 seconds (using the example
            provided).
            I found that the statement:
            unsigned long long milisec = now.tv_sec * 1000 + now.tv_usec / 1000.0;
            in util.cc
            evaluated to 0 on my Raspberry.
            I changed it to:
            unsigned long long milisec = (now.tv_sec*(long
            long)1000000+now.tv_usec)/1000.0;
            This works for me.

            Thanks for this great library.
            Jens

            Issue with GetTime on Raspberry

            http://sourceforge.net/p/netlinksockets/discussion/1101132/thread/65e46006/?limit=25#5c56

            Sent from sourceforge.net because you indicated interest in
            https://sourceforge.net/p/netlinksockets/discussion/1101132/

            To unsubscribe from further messages, please visit
            https://sourceforge.net/auth/subscriptions/


            Issue with GetTime on Raspberry

            http://sourceforge.net/p/netlinksockets/discussion/1101132/thread/65e46006/?limit=25#5c56/f2be

            Sent from sourceforge.net because you indicated interest in
            https://sourceforge.net/p/netlinksockets/discussion/1101132/

            To unsubscribe from further messages, please visit
            https://sourceforge.net/auth/subscriptions/


            Issue with GetTime on Raspberry

            http://sourceforge.net/p/netlinksockets/discussion/1101132/thread/65e46006/?limit=25#5c56/f2be/b692


            Sent from sourceforge.net because you indicated interest in
            https://sourceforge.net/p/netlinksockets/discussion/1101132/

            To unsubscribe from further messages, please visit
            https://sourceforge.net/auth/subscriptions/


            Issue with GetTime on Raspberry
            http://sourceforge.net/p/netlinksockets/discussion/1101132/thread/65e46006/?limit=25#5c56/f2be/b692/a960


            Sent from sourceforge.net because you indicated interest in
            https://sourceforge.net/p/netlinksockets/discussion/1101132/

            To unsubscribe from further messages, please visit
            https://sourceforge.net/auth/subscriptions/

             

Log in to post a comment.