Hello all,
I'm software developer. I'm new on embedded devices and in c++. I've a troble about how to mange error while openning device driver and configuring the devices (hw) for the first time.
That is, in microcontrolers, it's assumed that I/O is done using processor registers, so it's assumed that allways are available, for example to access to a serial port to communicate throw LinBus. If at initialization any error is detected, a value is returned, but nothing is destroied.
In contrast, in linux, to access to a serial port, a device file must be opened (ex /dev/ttyS1), but if no serial port is available, then an error is returned. But if we develop in C++, and if no port is present, an exception is thrown, and the object in construction is destroyed. But the questions are:
- The sensor should open the bus on its constructor? If I want to reconnect to the bus, I need to recreate the sensor object, and the bus?
- It's prefereable to use a initialize function member in the driver to open the bus and configure the sensor? I can communicate with the device without initial configuration.
- So If i can open the bus, but I can't initialize the device in device driver constructor, then the device driver is destroied by the exception.
How do you manage the creation of a device driver and device initialization?
Thanks in advance. Joaquim Duran