aaah now I understand. It wont matter with accuracy. The time slot only needs to be larger than it takes for the device to send one data block (I Think about 2 seconds), and smaller than the interval between two data blocks (device is set to send one data block each 30 sec). Its just a way to know "ooh, now the device is finished talking so lets parse the contents of the data block".

Since its Waits until one character is available, and then waits 7 seconds for the data block, the code will resynchronize itself with the device all the time, even if the device waits 29 seconds or 31 seconds to send a data block instead of 30 seconds, thus it will Always be 7.X seconds from the device starts talking, thus in reality it will not "slip" over real time.

Your sleep code is extremely fragile against DST Changes. Imagine what happens when it comes a DST -1h change (from summer time to Winter time) during your while loop. Whoops, the code will instead wait 1 hour and 7 seconds.


In reply to Re^4: How I unconditionally wait for data in 7 seconds? by sebastiannielsen2
in thread How I unconditionally wait for data in 7 seconds? by sebastiannielsen2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.