AnsweredAssumed Answered

VRF-Interface_event

Question asked by VRFuser on Mar 6, 1997
send q VRF-Interface_event vrf SERGEY_ERMOLIN@HP-SantaClara-om2.om.hp.com

from: Greg Goebel / HP-MXD
      gvg@lvld.hp.com / 970-679-3030 / FAX 970-679-5971
to:   VRf-Sergey Ermolin
date: Friday, 07 March 1997 1015 MST

>      A piece of my program has to read binary data from a serial port and
>      then parse it. The problem is that the length of the data (number of
>      bytes can be anywhere from 0 (no data available) to 15).
>     
>      Using Interface Event for serial port seemed to be the winning
>      solution since when set on "WAIT", its "event" pin fires the number of
>      bytes received which can be plugged into intput pin "A" of serial
>      interface DIO object configured for READ BINARY x BYTE ARRAY:a. This
>      configuration works fine when there are some data available to be
>      read. When there is no data on serial interface, the program
>      hopelessly hangs as timeout feature of Interface Event does not seem
>      to be working.
>     
>      I am attaching the source code for the program for those who care and
>      are able to read it.
>     
>      Questions:
>      1. Is there a workaround for this situation besides abandoning
>      Interface Event and reading input string one byte at a time?

>      2. Does HP VEE 4.0 addresses this situation?
>     
>      Regards,
>     
>      Sergey Ermolin
>      HP - Santa Clara Division

Sir:

Timeouts don't apply to interface operations objects ... it's just a status
check and you can either hang on it (WAIT) or poll on it (NO WAIT).  It's
intended to be used in a parallel branch or thread to just sit and wait until
something happens.

You can synthesize a timeout if you like, though, with a little work:

    +-------+
    | Start |
    +---+---+   +------------+
        |       | Set Global |
    +---+---+   +------------+
    | now() +-->|     t0     |
    +---+---+   +------------+
        |
    +---+---+
    | Until |
    | Break +---------------+
    +---+---+               |
        |       +-----------+-----------+
   +----+----+  |      DAV serial9      |   +--------------+
   | Message |  +-----------------------+   | If/Then/Else |
   | Box:    |  | Interface [  serial ] |   +-------+------+
   | "Done!" |  | Action    [ NO WAIT ] +-->| A > 0 | then +----------+
   +---------+  | Event     [   DAV   ] |   |       | else +--+       |
                +-----------------------+   +-------+------+  |       |
                                                              |       |
                +---------------------------------------------+  +----+----+
                |                                                | Message |
                |                                                | Box:    |
          +-----+------+   +--------------+                      | "DAV!"  |
          |  Formula   |   | If/Then/Else |                      +----+----+
          +------------+   +-------+------+                           |
          | now() - T0 +-->| A > 5 | then +---------------+       +---+---+
          +------------+   |       | else +--+            |       | Break |
                           +-------+------+  |            |       +-------+
                                             |            |
                                         +---+---+  +-----+-----+
                          | Next  |  | Message   |
                          +-------+  | Box:      |
                                  | "Timeout" |
                                  +-----+-----+
                                     |
                                                      +---+---+
                                    | Break |
                                    +-------+

This program sets an initial time in a global variable t0, then polls for
DAV using the Interface Event object in NO WAIT mode.  The Interface Event
object returns the amount of serial data buffered; if it's greater than 0,
you get a message box indicating success -- and then you break from the
loop.

If it is zero, the program then subtracts the initial time from the current
time; if it's greater than the timeout specified (5 seconds in this example),
you get a message box saying "Timeout" and break from the loop.  Otherwise
the program loops back for another poll.

This looks a little cluttered but it should be easy to build a UserFunction
on similar principles.

[<>] regards -- gvg



Outcomes