Page 113 - Designing Autonomous Mobile Robots : Inside the Mindo f an Intellegent Machine
P. 113

Chapter 6

            Flags

            Flags are nothing more than variables (usually booleans, bytes, or integers) that can
            take on a limited number of values, each of which has a specific assigned meaning.
            Flags are a powerful tool in communications. Flags can be sent to slaves and they can
            be retrieved from slaves. One of the most common uses of such flags is to place them
            in a block of data that is regularly monitored by the host. The flag might tell the
            host that there is some other data, somewhere in the blackboard of the slave that it
            needs to look at. Flags can also request that the host perform emergency shutdown,
            or any number of other actions.

            Two of the most common flags are the slave computer mode and status. By checking
            these integers or bytes, the host can tell if the slave is doing what it should be doing
            (mode), and if it is experiencing any problems doing it (status). Error numbers are
            another common example of flags.

            To understand the power of flags, consider that the host computer might receive from a
            slave a simple byte representing one of 255 possible error codes. Although this code
            required only a single byte to be communicated, it may result in the operator receiv-
            ing a whole paragraph of explanation about the nature of the error. A word of
            warning about flags is prudent at this point. If more than one of the conditions that
            a flag represents can be true at the same time, a numeric flag can only represent one
            of these conditions at a time. In these cases, the bits of a byte or integer can each
            serve as a flag, allowing any combination to be set at the same time. The other so-
            lution is to use individual flags for each condition, but this is very wasteful of band-
            width as an entire integer must be read to test each condition.

            Templates

            Although we have already indicated that we will try to group data contiguously in a
            slave’s blackboard if we expect to request it at the same time, there will always be
            times when we want data from a range of different noncontiguous memory locations.
            When this is the case, the overhead for requesting a few bytes here and there can be
            very high.

            Thus we need a template. A template is a script that the host loads into the memory
            of the slave in reserved locations. The script contains a list of starting addresses and
            the block size for each of these. The last of these pointers is followed by a zero-
            length block that serves to terminate the template.






                                                    96
   108   109   110   111   112   113   114   115   116   117   118