Loading ...
Sorry, an error occurred while loading the content.

Format of time and date to send to Linux system?

Expand Messages
  • lslonim2
    Hi. I m an embedded programmer, doing code for a board that is part of a distributed system that will interface to a Linux central controller. My board does
    Message 1 of 6 , Oct 4, 2009
    • 0 Attachment
      Hi. I'm an embedded programmer, doing code for a board that is part of a distributed system that will interface to a Linux central controller. My board does not run an OS.

      I need to send time and date info from an on-board battery backed clock to the Linux system for time-stamping events, and it needs to send me info if my clock has a dead battery.

      I'm trying to find out what format Linux wants, so that when I send it up to central, the guy handling that end will have less work to do. There's nobody to ask yet since that job isn't filled.

      My clock chip is hh:mm:ss. In searching the web, it seems Linux time is kept as a raw time since 1970, but my little processor can't handle the work to go into and out of that format.

      So my question is: Is there a standard Linux format for transmitting time in hh:mm:ss format, and if so, what are the system calls that use it?

      Thanks very much,

      Lloyd
    • J
      ... Hey Lloyd, This is a VERY uneducated opinion, but you re in the wrong place to ask that, though I imagine that there are some here who could and may give
      Message 2 of 6 , Oct 4, 2009
      • 0 Attachment
        On Sun, Oct 4, 2009 at 11:56, lslonim2 <lslonim@...> wrote:
        >
        > So my question is: Is there a standard Linux format for transmitting time in hh:mm:ss format, and if so, what are the system calls that use it?
        >
        > Thanks very much,
        >
        > Lloyd

        Hey Lloyd,

        This is a VERY uneducated opinion, but you're in the wrong place to
        ask that, though I imagine that there are some here who could and may
        give you a good answer. If you're trying to run an embedded Linux,
        you really should try a list specific to Embedded Linuxes.

        On the more generic side, check the various headers for time (I think
        the big one is time.h??) in the linux source tree.

        I think most things make use of the gettimeofday() call to query the
        hardware clock on a given system. I'm not a C programmer, but I know
        just enough to be dangerous :-)

        As for format, I think you are correct that the standard is indeed
        Unix time (seconds since 1970) but that may be handled differently by
        Embedded OSs given the limited memory and processor power available in
        embedded systems.

        I wish I could tell you more, but maybe that'll give you a place to
        start, and maybe someone else here who does some kernel programming
        could correct me or fill in the details.

        Cheers,
        Jeff

        --

        Ogden Nash  - "The trouble with a kitten is that when it grows up,
        it's always a cat."
      • Cameron Simpson
        ... Just send hh:mm:ss and make sure your Linux guy knows the format. It s pretty trivial to convert a human time into a UNIX seconds-since-1970 on the Linux
        Message 3 of 6 , Oct 4, 2009
        • 0 Attachment
          On 04Oct2009 15:56, lslonim2 <lslonim@...> wrote:
          | Hi. I'm an embedded programmer, doing code for a board that is part of a distributed system that will interface to a Linux central controller. My board does not run an OS.
          | I need to send time and date info from an on-board battery backed clock to the Linux system for time-stamping events, and it needs to send me info if my clock has a dead battery.
          | I'm trying to find out what format Linux wants, so that when I send it up to central, the guy handling that end will have less work to do. There's nobody to ask yet since that job isn't filled.
          | My clock chip is hh:mm:ss. In searching the web, it seems Linux time is kept as a raw time since 1970, but my little processor can't handle the work to go into and out of that format.
          | So my question is: Is there a standard Linux format for transmitting time in hh:mm:ss format, and if so, what are the system calls that use it?

          Just send hh:mm:ss and make sure your Linux guy knows the format. It's
          pretty trivial to convert a "human" time into a UNIX seconds-since-1970
          on the Linux machine using standard library calls present on all UNIX
          machines, specificly the ones using the "tm" struct.

          If you only have hh:mm:ss then the Linux end will have to assume today's date
          but that's easily done. It will also need to know the timezone your embedded
          box is using (personally I would go with GMT/UTC if you can trust the people
          configuring your board to set it correctly - no summer time issues or other
          things to worry about).

          Cheers,
          --
          Cameron Simpson <cs@...> DoD#743
          http://www.cskk.ezoshosting.com/cs/

          Theoretical Physicist,N.:A physicist whose existence is postulated, to make
          the numbers balance but who is never actually observed in the laboratory.
        • loyal_barber
          ... Not that I have anything to add, but I just want to thank Cameron personally for ALL of his input on discussion topics on this group in my 1.5 years. He
          Message 4 of 6 , Oct 5, 2009
          • 0 Attachment
            --- In LINUX_Newbies@yahoogroups.com, Cameron Simpson <cs@...> wrote:
            >
            > On 04Oct2009 15:56, lslonim2 <lslonim@...> wrote:
            > | Hi. I'm an embedded programmer,
            > <snip>
            > I would go with GMT/UTC if you can trust the people
            > configuring your board to set it correctly - no summer time issues or other
            > things to worry about).
            >
            > Cheers,
            > --
            > Cameron Simpson <cs@...> DoD#743

            Not that I have anything to add, but I just want to thank Cameron
            personally for ALL of his input on discussion topics on this group
            in my 1.5 years. He is always insightful and always useful.

            Loyal
          • Don Cooley
            On Mon, 05 Oct 2009 15:22:23 -0000 ... I second that opinion. I always learn something from him. -- Regards, Don Cooley While most peoples opinions change,
            Message 5 of 6 , Oct 5, 2009
            • 0 Attachment
              On Mon, 05 Oct 2009 15:22:23 -0000
              "loyal_barber" <loyal_barber@...> wrote:

              >
              >
              > --- In LINUX_Newbies@yahoogroups.com, Cameron Simpson <cs@...> wrote:
              > >
              > > On 04Oct2009 15:56, lslonim2 <lslonim@...> wrote:
              > > | Hi. I'm an embedded programmer,
              > > <snip>
              > > I would go with GMT/UTC if you can trust the people
              > > configuring your board to set it correctly - no summer time issues
              > > or other things to worry about).
              > >
              > > Cheers,
              > > --
              > > Cameron Simpson <cs@...> DoD#743
              >
              > Not that I have anything to add, but I just want to thank Cameron
              > personally for ALL of his input on discussion topics on this group
              > in my 1.5 years. He is always insightful and always useful.
              >
              > Loyal
              >
              >

              I second that opinion. I always learn something from him.

              --
              Regards,
              Don Cooley


              While most peoples' opinions change, the conviction of their
              correctness never does.
            • lslonim2
              Thanks Cameron, the tm struct had what I needed. Lloyd ... snip ... ... ship...
              Message 6 of 6 , Oct 5, 2009
              • 0 Attachment
                Thanks Cameron, the tm struct had what I needed.

                Lloyd

                --- In LINUX_Newbies@yahoogroups.com, Cameron Simpson <cs@...> wrote:

                snip ...

                > Just send hh:mm:ss and make sure your Linux guy knows the format. It's
                > pretty trivial to convert a "human" time into a UNIX seconds-since-1970
                > on the Linux machine using standard library calls present on all UNIX
                > machines, specificly the ones using the "tm" struct.

                ship...

                >
                > Cheers,
                > --
                > Cameron Simpson <cs@...> DoD#743
                > http://www.cskk.ezoshosting.com/cs/
                >
                > Theoretical Physicist,N.:A physicist whose existence is postulated, to make
                > the numbers balance but who is never actually observed in the laboratory.
                >
              Your message has been successfully submitted and would be delivered to recipients shortly.