Jump to main content | Jump to Primary Navigation | Jump to Sub Navigation
| Previous tutorial | Back to main tutorial page |
DevBot provides many built-in property types that are usable in drivers and controller code. See type.h for more information about the API these types provide. In most respects, external types are identical to these internal types, but they must be loaded before they can be used. They may also have third-party APIs which do not conform to those of the internal types.
Although drivers will typically link against and register any external types their properties require, controller programs must also link against and register any external types they employ.
This tutorial assumes you are aware of the 'short' type, manufactured in Drivers 4: Creating custom types.
The function bot_type_register() must be invoked to load an external type. Invoking this function adds the type to DevBot's internal registry, allowing it to be used by user/controller code. External types should provide an accessor which returns a BotPropertyType for use with this registration function (e.g. bot_short_get_type).
bot_type_register(bot_short_get_type());
int16_t shrt = bot_property_get_short(p);
A list of accessors (including bot_property_get_short) can be found in Drivers 4: Creating custom types.
int main(int argc, char **argv) { BotHost *host = bot_host_create("127.0.0.1:1234"); /* Register the type with DevBot */ bot_type_register(bot_short_get_type()); /* Look up the 'short' property */ BotProperty *p = bot_host_register_property(host, "Device/ShortProperty"); /* Obtain the property value and display it */ int16_t shrt = bot_property_get_short(p); printf("value was: %hd\n", shrt); return 0; }
| Previous tutorial | Back to main tutorial page |