Missing time.h posix

View: New views
7 Messages — Rating Filter:   Alert me  

Missing time.h posix

by Daniele Basile :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,
we need to use some functions of posix standard time library. We want to use
some time functions that convert unix time to a tm structure, or vice versa,
(ie, mktime, gmtime..), but the avr libc doesn't include them.
Do you plan to include time.h in avr libc in future? if not, how do we
contribute to avr libc?

Regards,
Daniele.

--
|  [D]-o Ing. Daniele Basile - asterix@...
|   ||}-o  Develer S.r.l., R&D dept.
|  [B]-o  http://www.develer.com/


_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

RE: Missing time.h posix

by Weddington, Eric :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 

> -----Original Message-----
> From:
> avr-libc-dev-bounces+eric.weddington=atmel.com@...
> [mailto:avr-libc-dev-bounces+eric.weddington=atmel.com@nongnu.
> org] On Behalf Of Daniele Basile
> Sent: Friday, October 09, 2009 6:10 PM
> To: avr-libc-dev@...
> Subject: [avr-libc-dev] Missing time.h posix
>
> Hello,
> we need to use some functions of posix standard time library.
> We want to use
> some time functions that convert unix time to a tm structure,
> or vice versa,
> (ie, mktime, gmtime..), but the avr libc doesn't include them.
> Do you plan to include time.h in avr libc in future? if not,
> how do we
> contribute to avr libc?
>

Hi Daniele,

I believe I know some other people over at Develer. ;-) You can contribute like any other open source project: just submit a patch. Please submit patches to the Patch Tracker on the avr-libc project on Savannah.

We have had people ask about time.h in the past. The problem with it is that there is no common hardware standard on the AVR for timekeeping. So our standard answer has always been that we can't generally support time.h because there's no common way to do this for all AVR projects. However we're always open to new ideas and if you have a proposal then let's please discuss.

Thanks,
Eric Weddington


_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Re: Missing time.h posix

by Daniele Basile :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Weddington, Eric ha scritto:

>  
>
>> -----Original Message-----
>> From:
>> avr-libc-dev-bounces+eric.weddington=atmel.com@...
>> [mailto:avr-libc-dev-bounces+eric.weddington=atmel.com@nongnu.
>> org] On Behalf Of Daniele Basile
>> Sent: Friday, October 09, 2009 6:10 PM
>> To: avr-libc-dev@...
>> Subject: [avr-libc-dev] Missing time.h posix
>>
>> Hello,
>> we need to use some functions of posix standard time library.
>> We want to use
>> some time functions that convert unix time to a tm structure,
>> or vice versa,
>> (ie, mktime, gmtime..), but the avr libc doesn't include them.
>> Do you plan to include time.h in avr libc in future? if not,
>> how do we
>> contribute to avr libc?
>>
>
> Hi Daniele,
>
> I believe I know some other people over at Develer. ;-) You can contribute like any other open source project: just submit a patch. Please submit patches to the Patch Tracker on the avr-libc project on Savannah.
>
> We have had people ask about time.h in the past. The problem with it is that there is no common hardware standard on the AVR for timekeeping. So our standard answer has always been that we can't generally support time.h because there's no common way to do this for all AVR projects. However we're always open to new ideas and if you have a proposal then let's please discuss.
>
We know this problem and we think that is not simple to solve. However some time
functions makes only conversion operation, like mktime or gmtime, so we could
choose one subset of time functions that can work on every avr. We think this is
enough for all commons operation that need to manipulate time/date data. For
example we want to store time stamp that we had read from gps receiver and then
print its string representation; to do this we want to convert time stamp to
unix time and then use asctime to print it.

Let me know what you think.

Regards,
Daniele.


--
|  [D]-o Ing. Daniele Basile - asterix@...
|   ||}-o  Develer S.r.l., R&D dept.
|  [B]-o  http://www.develer.com/


_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Re: Missing time.h posix

by Frédéric Nadeau-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I once had to write one for a project. It's not that complicated to
simply convert an 32 bit integer to a GTM time if you cut the corners.
Since we had no big requirements, here what we had not done:
- Leap seconds handling
- Timezone handling
- Localize printf

Basically we only had unix2struct, struct2unix and a print time function.

I think it would be hard to have a library that would match a UNIX
system. We were always a few second off from a computer but it didn't
cause any issue for us at the time.

if your interested i could post our code, mind you the time to string
function yield result in French, but that is just some constant string
to change.

At the time I was looking to do something decent for asctim() but then
it depends on where you are in the world for daylight saving as well
as the mood of the head of the country to decide to change the dates
at which saving day light is used. I know OpenBSD uses a file in /etc
to solve the issue. It's only 34bytes(fits well in either
ram/programspace/eeprom) but it's only for /Canada/Eastern. It became
quite complicated for our requirements at the time.

--
Frédéric Nadeau ing. jr


_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Re: Missing time.h posix

by Bob Paddock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Oct 9, 2009 at 8:39 AM, Daniele Basile <asterix@...> wrote:

> we need to use some functions of posix standard time library. We want to use
> some time functions that convert unix time to a tm structure, or vice versa,
> (ie, mktime, gmtime..), but the avr libc doesn't include them.

What is your goal by using these time functions?

While simple to use they are not considered safe,
MISRA Rule 20.12, nor are they accurate as they
rarely handle leap seconds correctly; xx:xx:60.
Proper Timezone handling is even unlikely to even
fit in the memory space of most smaller AVRs.

Checkout the archives of the LeapSecs mailing list:

http://six.pairlist.net/mailman/listinfo/leapsecs

and the TimeNuts mailing list:

http://leapsecond.com/time-nuts.htm

to find out how complicated the seeming simple function
of tracking Time accurately truly is.

LeapSecs deal truly with Time, and frequently GPS time,
while TimeNuts deals more with Time and Frequency Standards (These
are the people that put Atomic Clocks on their back and hike to the top
of mountains to check Relativity).  GPS issues are also a frequent topic.

I put some simple time structure to seconds/seconds to time structure
source code, on my web site at http://www.designer-iii.com/Time . This
code is from
1992 and needs converted to modern standards and needs far more
validation before it can be used in mission critical applications.

Is there any merit to making them part of AVR-LibC?  They don't handle
timezones, nor leap seconds.

Alternatives format to POSIX epic second counting are packed BCD,
and packed binary.

The book "Embedded Systems Building Blocks" Second Edition or later,
by Jean J. Labrosse covers the packed binary format.  Books should
be on any Embedded Developers bookshelf.

--
http://www.wearablesmartsensors.com/
http://www.softwaresafety.net/
http://www.designer-iii.com/
http://www.unusualresearch.com/


_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Re: Missing time.h posix

by Daniele Basile :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Frédéric Nadeau ha scritto:
 > I once had to write one for a project. It's not that complicated to
 > simply convert an 32 bit integer to a GTM time if you cut the corners.
 > Since we had no big requirements, here what we had not done:
 > - Leap seconds handling
 > - Timezone handling
 > - Localize printf
 >
 > Basically we only had unix2struct, struct2unix and a print time function.
 >

We had considered also this solution, but we are developing a RTOS (BeRTOS),
that runs on various target, like arm, and we would use a standard posix
library. In this way we not have a time functions custom implementation, and we
believe is more clean to have time.h in avrlibc, like in arm toolchain.

 > I think it would be hard to have a library that would match a UNIX
 > system. We were always a few second off from a computer but it didn't
 > cause any issue for us at the time.
 >

That is true, but we think to implement only functions that have sense on avr
target, like mktime.

 > if your interested i could post our code, mind you the time to string
 > function yield result in French, but that is just some constant string
 > to change.
 >

I am interested, could you post it, please?

 > At the time I was looking to do something decent for asctim() but then
 > it depends on where you are in the world for daylight saving as well
 > as the mood of the head of the country to decide to change the dates
 > at which saving day light is used. I know OpenBSD uses a file in /etc
 > to solve the issue. It's only 34bytes(fits well in either
 > ram/programspace/eeprom) but it's only for /Canada/Eastern. It became
 > quite complicated for our requirements at the time.
 >

I have see newlib implementation of asctime and they use standard
representation, without localize the time string. I am in accord to this
implementation, because we only use time.h conversion functions, and day light
is already considered in unix time that you use. Otherwise if you want localize
time string you could use tm structure and implement your custom time string
representation. I believe that in most case you doesn't need to localize time
string representation.

--
|  [D]-o Ing. Daniele Basile - asterix@...
|   ||}-o  Develer S.r.l., R&D dept.
|  [B]-o  http://www.develer.com - http://www.bertos.org


_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Re: Missing time.h posix

by Daniele Basile :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bob Paddock ha scritto:
 > On Fri, Oct 9, 2009 at 8:39 AM, Daniele Basile <asterix@...> wrote:
 >
 >> we need to use some functions of posix standard time library. We want to use
 >> some time functions that convert unix time to a tm structure, or vice versa,
 >> (ie, mktime, gmtime..), but the avr libc doesn't include them.
 >
 > What is your goal by using these time functions?
 >

Our scope is simple, for example I have this nmea sentence:

$GPRMC,143811.000,A,4351.0794,N,01108.8684,E,0.00,,021009,,,A*77\r\n

where "143811.000" is time stamp in format hhmmss.sss and "021009" date stamp in
format ddmmyy, now I want to manage these time stamp..
to do this I can fill a tm structure then using mktime and obtain unix time.
With unix time I could print it, or use it for other computation.

This example explain our scope, that is to use only conversion functions, not to
provide fully posix time library, because is more difficult to create a generic
implementation for all time functions.

Generally we think that posix time avrlibc implementation could provide only
conversion functions, that could have sense on avr target, for all other type
applications everyone should implement theirs time functions.


--
|  [D]-o Ing. Daniele Basile - asterix@...
|   ||}-o  Develer S.r.l., R&D dept.
|  [B]-o  http://www.develer.com - http://www.bertos.org


_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev