*nix date to PLC date and back
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > *nix date to PLC date and back




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    *nix date to PLC date and back  
CptDondo


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-07 06:23 PM

I am working on a project where my *nix box will talk to a PLC.  (A PLC
is sort of a brain-damaged computer...)

The PLC in question returns the date in the following 6 byte sequence:

0	year (0-99)	current year (BCD value)
1	month (1-12)	current month (BCD value)
2	day (1-31)	current day (BCD value)
3	hour (0-23)	current hour (BCD value)
4	minute (0-59)	current minute (BCD value)
5	second (0-59)	current second (BCD value)

The year is assumed to start at 2000.

I need to convert this monster to a *nix type long int (32 bit) date and
back.

On the PLC I have a BCD to int conversion which will take byte-pairs and
covert them to 16 bit ints.  I can multiply, divide, etc.

From this I need to build the *nix date....

I can't quite get my head around the conversion algorithm.  Most
resources on the web use stuff like PERL and awk, none of which I have
available.

So.... Anyone know the algorithm for calculating the *nix date?

Thanks,

--Yan





[ Post a follow-up to this message ]



    Re: *nix date to PLC date and back  
John Gordon


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-24-07 01:03 AM

In <12rco513dfbhkf7@corp.supernews.com> CptDondo <yan@NsOeSiPnAeMr.com> writ
es:

> I need to convert this monster to a *nix type long int (32 bit) date and
> back.

Fill in a "struct tm" with the values from the PLC, then call mktime()
on it.

--
John Gordon             "... What with you being his parents and all,
gordon@panix.com         I think that you could be trusted not to shaft
him."  -- Robert Chang, rec.games.board






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 02:16 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register