An object name is an unsigned thirty-two bit entity
associated with the object by the user. The data type
rtems_name
is used to store object names.
Although not required by RTEMS, object names are often
composed of four ASCII characters which help identify that object.
For example, a task which causes a light to blink might be
called "LITE". The rtems_build_name
routine
is provided to build an object name from four ASCII characters.
The following example illustrates this:
rtems_object_name my_name; my_name = rtems_build_name( 'L', 'I', 'T', 'E' );
However, it is not required that the application use ASCII characters to build object names. For example, if an application requires one-hundred tasks, it would be difficult to assign meaningful ASCII names to each task. A more convenient approach would be to name them the binary values one through one-hundred, respectively.
RTEMS provides a helper routine, rtems_object_get_name
,
which can be used to obtain the name of any RTEMS object using just
its ID. This routine attempts to convert the name into a printable string.
The following example illustrates the use of this method to print an object name:
#include <rtems.h> #include <rtems/bspIo.h> void print_name(rtems_id the_object) { char buffer[10]; /* name assumed to be 10 characters or less */ char *result; result = rtems_object_get_name( id, sizeof(buffer), buffer ); printk( "ID=0x%08x name=%s\n", id, ((result) ? result : "no name") ); }
Copyright © 1988-2008 OAR Corporation