[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference 49.910::kav30

Title:VAX on VMEbus: KAV30
Notice:Could have been as fast as 68K but its a VAX!
Moderator:CSSVMS::KAV30_SUPP
Created:Thu Apr 18 1991
Last Modified:Fri Aug 02 1996
Last Successful Update:Fri Jun 06 1997
Number of topics:159
Total number of notes:645

50.0. "KAV$SET_CLOCK and leap years" by ZYDECO::BODA (Realtime Products Support) Wed Apr 01 1992 03:03

Since I'm not sure where qar's should be submitted, I'm posting this problem
report here on behalf of one of our customers at Penn State University.

Thanks,

Alan Boda
Realtime Products Support
---------------------------------------------------------------------------------



1  PRIORITY OF PROBLEM
   1.1  Priority:  4
   1.2  Current Date:  31-MAR-1992 (Tuesday)
   1.3  Answer Needed By:  14-APR-1992 (Tuesday)

2  CUSTOMER INFORMATION
   2.1  Company Name:  Penn State University
   2.2  Contact Name:  Bob Spooner
   2.3  Contact Telephone Number:  (814)863-7015
   2.4  CHAMP/CSC Sequence Number:  A920325-374
   2.5  Problem Owner:  HARUMF::BODA

3  HARDWARE CONFIGURATION
   3.1  DEC Target CPU:  KAV30
   3.2  DEC Host CPU:  VAX 3400

4  SOFTWARE INFORMATION
   4.1  VAXELN Version:  V4.3
   4.2  VMS Version:  V5.4-3
   4.3  KAV Toolkit V1.0

5  PROBLEM STATEMENT
   5.1  Failing Software Component:  KAV30 Clock Utility
   5.2  Summary

   KAV30 battery-backed up clock utility doesn't recognize 1992 as  a  leap
   year  if KAV$SET_CLOCK has been used to set the real-time clock from the
   VAXELN system time.

   5.3  Specifics

   The KAV30 user ROM utility for the  battery-backed  up  clock  does  not
   recognize 1992 as a leap year if the real-time clock had been previously
   set using KAV$SET_CLOCK from the VAXELN system time.  Therefore  setting
   the  VAXELN  system  time  from the battery-backed up clock is incorrect
   after Feb 29, 1992.

   I wrote the sample program below to check whether  the  KAV30  real-time
   clock  is  valid.     If  not, the program prompts for the current time,
   sets the VAXELN system time, and then sets the realtime clock.  In  this
   test  case, I first disabled the battery and reenabled it.  When running
   my test program, it  sees  that  the  realtime  clock  is  not  set  and
   therefore  prompts for the current time.  I respond to my program prompt
   and set the time to:

   Enter the current time (e.g. DD-MMM-YYYY HH:MM:SS):  28-FEB-1992 23:59:30
   System time = 28-FEB-1992 23:59:30.01

   After 30+ seconds, I halt the KAV30.  Then running the user ROM  utility
   $2008'0048, it erroneously shows the date as follows:

   >>> UNJAM


   >>> INIT

   >>> START 20080048

    KAV30 ROM utility to set the battery-backed-up clock.
      The current state of the battery-backed-up clock:
        Clock setting is VALID.   Clock is RUNNING.
        Friday 01-MAR-1992 00:00:58    Julian=060, leap_year=1990
      Do you want to change the date/time? (1=yes)[no]:

   If I then actually  set  the  date  correctly  and  rerun  the  test  it
   correctly shows the leap_year to be 1992:

      Do you want to change the date/time? (1=yes)[no]: 1
        |
      Input time: DD-MMM-YYYY HH:MM [AM|PM], (if no 'AM'/'PM', hours must be 0-23)
      Input time: 29-FEB-1992 18:30
        |
      The new setting of the battery-backed-up clock:
        Clock setting is VALID.   Clock is STOPPED.
        Saturday 29-FEB-1992 18:30:00    Julian=060, leap_year=1992
      Hit RETURN to start the clock with the above setting...
    Utility finished. (starting utility to display clock)...

   6  SAMPLE PROGRAM (INCLUDES BUILD INSTRUCTIONS IN COMMENTS)
   #module kav_set_time
   /*                                                                            */
   /*              COPYRIGHT �1992 DIGITAL EQUIPMENT CORPORATION                 */
   /*                                                                            */
   /*   THIS SOFTWARE MAY BE COPIED WITHOUT FEE PROVIDED THAT THE  COPIES  ARE   */
   /*   NOT  MADE OR DISTRIBUTED FOR DIRECT COMMERCIAL ADVANTAGE,  THAT CREDIT   */
   /*   TO THE SOURCE IS GIVEN AND THAT THIS ENTIRE COPYRIGHT NOTICE IS INCLUDED.*/
   /*                                                                            */
   /*   THE  INFORMATION  IN  THIS  SOFTWARE  SHOULD  NOT  BE  CONSTRUED  AS A   */
   /*   COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.                             */
   /*                                                                            */
   /*   DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY FOR THE USE,     */
   /*   SUPPORT, OR RELIABILITY OF THIS SOFTWARE.  THIS SOFTWARE IS              */
   /*   DISTRIBUTED "AS IS."                                                     */
   /*                                                                            */
   /*
   **++
   **  FACILITY:  SET_KAV_TIME
   **
   **  MODULE DESCRIPTION:
   **
   **   This program assures that the system time is set 
   **   on a KAV30.
   **
   **  AUTHORS:
   **
   **      ATB
   **
   **  CREATION DATE:  15-JAN-1992
   **
   **  SYSTEM:  VAXELN V4.2
   **        VAXELN KAV Toolkit Extensions for VMS V1.0
   **
   **  DESIGN ISSUES:
   **
   **      This program checks to see if the KAV30 Real Time Calendar Clock
   **   (RTC) has been set.  If not, it prompts at the display for the current
   **   time. It then sets both the RTC as well as the VAX system time.  If the 
   **   RTC has been set, the program checks to see if SYSTEM PARAMETER #1 
   **   has been set such that the system time is automatically set at 
   **   startup time.  If not, the VAX system time is set from the RTC time.
   **   Please note that the rtVAX-300 (which the KAV30 uses), unlike other
   **   CVAX-based cpu's (e.g., KA640, KA650), does not implement the TODR
   **   register.
   **
   **
   **  COMPILE AND LINK COMMANDS:
   **   $set ver
   **   $CC/debug/noopt 'p1' + eln$:vaxelnc/lib
   **   $link/debug/map/full 'p1' + ELN$:KAV$RTL_OBJLIB.OLB/LIB + -
   **    eln$:crtlshare/lib +-
   **    eln$:rtlshare/lib + eln$:rtl/lib
   **   $ebuild/map/full/kernel=eln$:300ker_kav30.exe 'p1'
   **   $set nover
   **
   **  SAMPLE EBUILD .DAT FILE:
   **   characteristic /remote_cli /shared_status /net_device=EZA -
   **   /noserver /objects=1024 /io_region=1024 /target=24 -
   **   /sys1_param=%X800000FF
   **   program SET_KAV_TIME /warm_debug 
   **   device EZA /vector=%X130 /net_def
   **   terminal CONSOLE /scope
   **
   **  MODIFICATION HISTORY:
   **
   **      15-JAN-1992  atb - created
   **--
   */

   /*
   **
   **  INCLUDE FILES
   **
   */

   #include $vaxelnc
   #include "eln$:kavdef.h"
   #include descrip
   #include stdio
   #pragma inline (show_time)
   #include $kernelmsg
   #include chfdef

   #define BUFFER_LENGTH 100

       globalref ker$gl_system_parameter1;

       BOOLEAN good_time_string;    

   main ()
   {

       struct dsc$descriptor tstring;
       LARGE_INTEGER current_time;
       int status;
       unsigned long rtc_functions;
       unsigned char buffer[BUFFER_LENGTH];
       void dummy_ast();    
       void display_status();
       BOOLEAN check_time_error();

   /*    
   **  Check to see if the RTC calendar/clock has ever been set.  A value
   **  of KER$_TIME_NOT_SET will be returned if it hasn't.  Assume it hasn't
   **  been set if any other value other than KER$_SUCCESS is returned as well.
   */    
       rtc_functions = KAV$M_READ_CALENDAR;
       kav$rtc( &status,
                rtc_functions,
             &buffer[0],
             10,
                &dummy_ast,
                0 );
       if (status != KER$_SUCCESS) 
   /*    
   **  The RTC time has never been set. Prompt for it and set both the RTC
   **  time as well as the system time.
   */    
       {

        for (;;)
        {
            good_time_string = TRUE;
            printf ("Enter the current time (e.g. DD-MMM-YYYY HH:MM:SS):  ");
            fgets (buffer, sizeof buffer, stdin);
            tstring.dsc$a_pointer = buffer;
            tstring.dsc$w_length = strlen (buffer) - 1;
            vaxc$establish (check_time_error);    
            current_time = eln$time_value (&tstring);
            vaxc$establish (0);    
            if (good_time_string)
                   break;
        }
        ker$set_time (NULL, &current_time);
        kav$set_clock( &status,
                       KAV$K_SET_RTC_TIME|KAV$M_RTC_24_HOUR );
       }
       else
   /*    
   **  This path is needed only if the system parameter #1 has not been
   **  set to %X800000FF.  If it is set, this allows the VAX system time to be 
   **  set from the KAV30 calendar/clock automatically.
   */    
       {
        if (ker$gl_system_parameter1 != 0X800000FF)
        {
            printf( "Setting system time from RTC.\n");
            kav$set_clock( &status,
                           KAV$K_SET_VAX_TIME );
        }
        else
            printf("System Time has been set during system initialization.\n");
       }
       ker$get_time (NULL, &current_time);
       show_time ("System time", &current_time);
   }

   /*
    * General purpose routine to convert a 64 bit time into a time string and
    *  display it with a meaningful identifier
    */
   static int show_time (char *identifier, LARGE_INTEGER *mytime)
   {
       char buffer [132];

       eln$time_string (buffer, mytime);
       printf ("%s = %.*s\n", identifier, ELN$K_TIME_STRING_SIZE, buffer);
   }

   /* This routine is never used but is needed for its address */
   void dummy_ast()  
   {
   int i;
       i = 1234;
   return;
   }

   /*    
   **  General status display utility.  Assumes message files are built in.
   */    
   void display_status(status)
   long status;
   {
       VARYING_STRING(255) stat_str;

       eln$get_status_text (status, 0, &stat_str);
       printf ("%.*s\n", stat_str.count, stat_str.data );
   }

   /*    
   **  Used for exception handling on the ELN$TIME_VALUE.
   */    
   BOOLEAN check_time_error(signal_ptr, mechanism_ptr)
       struct chf$signal_array *signal_ptr;
       struct chf$mech_array *mechanism_ptr;
   {
       display_status( signal_ptr->chf$l_sig_name);
       good_time_string = FALSE;
       return ( TRUE );
   }    

T.RTitleUserPersonal
Name
DateLines
50.1Clarification: The KAV Toolkit V1.1 was used with VAXELN V4.3 in -.1 testZYDECO::BODARealtime Products SupportWed Apr 01 1992 03:540
50.2HERR::CROSBIEFri Apr 03 1992 14:277
    Hi Alan,
    
    Thanks for the qar and providing the sample program, the KAV$SET_CLOCK
    and KAV$RTC system services will correctly handle leap years in the
    next release.
    
    Graham