[ECOS] Closing/disabling a device

Bernard Fouché bernard.fouche@kuantic.com
Tue Dec 13 16:57:00 GMT 2011


Le 12/12/2011 16:14, Frank Pagliughi a écrit :
> Hey All,
>
> I'm looking to interface a serial GPS unit to an Atmel AT91 using 
> eCos. GPS units constantly stream out data at 4800 baud, but I 
> actually only need to get data from the unit once every few hours to 
> check time and position. The idea is to have a thread wake up, read 
> the data, then go back to sleep. The code (ported from Linux) uses the 
> stdio FILE input routines (fopen, fgetc, etc)
>
> But the data arriving consistently from the GPS is filling up the 
> buffer in the AT91 serial driver and I can't figure out how to empty 
> or clear it. I tried CYG_IO_GET_CONFIG_SERIAL_INPUT_FLUSH, and also to 
> just close the port (fclose) while the thread is sleeping.
>
> I have started looking at the driver to see if the ability to 
> flush/drain the buffers is implemented, but I think I would prefer the 
> second option - closing down the driver to disable interrupts for that 
> serial port while it's not needed.
>
> I don't see a low-level mechanism to do this. Am I missing something? 
> Is there low-level code that trickles down to a driver when an 
> application calls close() or fclose() on a device?
>

I have the same problem (not for one for a single serial port but 4 of 
them plus many other peripherals). eCos starts all the drivers it knows 
as soon as it boots. It seems that the solution would be to implement 
CYGPKG_POWER in the concerned drivers, however I wonder how one could do 
it in a clean way when the UART is the generic 16x5x serial driver 
(dunno if AT91 has such a driver) since power control is specific to 
each MCU/CPU family. The quick and ugly solution is to hack the UART 
registers from the application when the driver has to be silenced and to 
restore them later when needed. The CYGPKG_POWER package is available 
but AFAIK there is no example of an implementation in the public eCos 
repository.

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list