Error management in C++ on linux for devices



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
.



Relevant Pages

  • Re: how to use iic(4)
    ... other over an opto-isolated I2C-compatible bus, ... The iic character device driver provides generic i/o to any iicbus ... managed by the iicbus system. ...
    (freebsd-hackers)
  • Re: PoR and AHB Configuration in WINCE
    ... Q. When do you need a device driver, assuming you are trying to work ... to interract with a piece of hardware. ... there is normally a bus driver and a peripheral driver. ... In short, possibly, if your reset chip is one of the more advanced ...
    (microsoft.public.windowsce.platbuilder)
  • Re: 1394 Virtual Device Driver
    ... > on the bus whether it be a 1394 pc or a 1394 dsp. ... > a message to a second virtual device driver both located on the same ... Send an IRP down to the port driver and have it ... >>> between a physical device driver and a virtual device driver (On the ...
    (microsoft.public.development.device.drivers)
  • Re: Overland Data neo 2000/MSL series drive + OpenVMS 8.2>
    ... I asked the customer if he has anything else on the same bus. ... Double termination would cause some scsi issues I would suspect. ... There'd be nothing to mention to MOUNT, if a device driver hadn't been ... tape driver recognizes this tape device within this context, ...
    (comp.os.vms)
  • Re: Programming hardware controls
    ... If the device has a fairly simple serial port or parallel port ... protocol you can do it from high level java. ... For anything else, you need to write a device driver, usually in C++ ... Roedy Green Canadian Mind Products ...
    (comp.lang.java.programmer)