A driver must export:
---------------------
ErrorCode drvInit(void);
ErrorCode drvFinal(void);
ErrorCode getName(uint8 **name); // returns eg. { "org", "neuraldk", "serial" }
ErrorCode getParams(uint8 **params); // returns eg. { DriverTypeUint32, "port", "1-3" }
ErrorCode getHierarchy(DriverHierarchyItem **items, uint32 *numItems); // must be sorted!
A driver will be read in by the system, and it's namespace and name will be gathered through the drivers getName() function. It's hierarchy may or not be saved.
When a user app or shell wishes to control an object it can do the following:
Driver driver;
uint8 data[1024];
ec = driverCreate(&driver, "org.neuraldk.serial(1)");
if(!ec && driver)
{
driverSet(driver, "baudrate", 9600 );
driverGet(driver, "buffer(1024)", &data );
// note that we can't have driverSet(driver, "buffer", 1024, &data) as then that leaves open
// a hole whereby a user could driverSet(driver, "buffer", 1024) and ndk would have no
// idea that 'data' had been left out (as this would have to be taken care of by a ...)
}
driverDestroy(&driver);
Keep in mind that the user could, just as easily, create a driver starting at the beginning of the namespace:
driverCreate(&driver, "org.neuraldk");
And have access to everything. Should this be allowed?
Typedef Documentation