Drivers for Serial based Coms, need advice

10 May 2011

Hi All,

I have been busy trying to write a driver for a Serial based sensor (Windsonic) and have some basic questions.

First of all its actually pretty tricky writing a fully "encapsulated" driver without access to the "user context". Since quick execution times are critical for interrupt driven routines but these tend to be highly used in order to keep all the driver logic within the driver itself. So one ends up with all sorts of Timers, Tickers etc ....

Is the alternative to split the driver up and keep the serial comms in the main loop and simply pass/receive data to the driver? i.e. the sensor driver does not really know how its getting and sending the data?

To make matters harder my particular sensor seems to only tolerate character to character input with pauses between each character.. so I need to space the sending of every character to the sensor by like 100ms (as if a user was entering it on his keyboard)

anyone have any thoughts or tips on this?

Thanks, Serge

10 May 2011

Hi

A standard 'trick' is to use Parity Even together with 8 bits transmission and set the other side to 8 bits no parity. That way you have one extra bit as inter character delay. But the inter character delay got this way depends on the baud-rate.

Beware though that most USB-serial cables / chip sets buffer characters until the buffer is full (or a certain time has elapsed) and then send them back to front at the highest speed possible without any inter character delay.