Serial port handling

Discussion in 'Questions (Windows Mobile)' started by mjcoon, Jun 25, 2008.

  1. mjcoon

    mjcoon Well-Known Member Licensed User

    I have been using the serial library with some partial success, and am looking how I may avoid data loss. This is with no lower-level handshaking, just a package protocol (actually from Garmin for their GPS).

    The Help for the serial keywords doesn't say much about how they interact. For instance I assume that doing InputArray() empties the input buffer so that the same data cannot be read again.

    But what is the effect of the Timeout? What actions does it influence, and how to tell if there has been a timeout event?

    Regards, Mike.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    InputArray reads (and empties) all the data that is waiting in the input buffer.
    It is however possible that while you read the data, new data arrives.

    Timeout affects the time to wait before the program raises a timeout error when you read or write data to the serial port.
    The default is Infinite.
    If a timeout occurs an error will be raised.
     
  3. agraham

    agraham Expert Licensed User

    I hesitate to correct the master :sign0188: but on my system it is 100mS! I investigated why. See "private void SharedNew()" in the Serial object!
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    :signOops: You are absolutely right!
     
  5. mjcoon

    mjcoon Well-Known Member Licensed User

    Ah, thanks for correcting the "infinite" timeout; I had already tried displaying the default value and infinity might have overloaded the message box somewhat! :signOops:

    100mS isn't very long, so now I wonder why I haven't triggered this timeout already.

    I have now started looking at ErrorLabel and exception handling...

    Regards, Mike
     
  6. agraham

    agraham Expert Licensed User

    For infinite timeout set the property to -1. Any other positive number is the timeout in mS. Any other -ve number will trigger an exception.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice