/*
* /src/NTP/ntp4-dev/libparse/clk_trimtaip.c,v 4.11 2005/04/16 17:32:10 kardel RELEASE_20050508_A
*
* clk_trimtaip.c,v 4.11 2005/04/16 17:32:10 kardel RELEASE_20050508_A
*
* Trimble SV6 clock support - several collected codepieces
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
* Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
clock_time->usecond *= 1000;
/* Check that the checksum is right */
for (i=OFFS(O_CHKSUM)-1; i >= 0; i--) calc_csum ^= buffer[i];
recv_csum = (hexval(buffer[OFFS(O_CHKSUM)]) << 4) |
hexval(buffer[OFFS(O_CHKSUM)+1]);
if (recv_csum < 0) return CVT_FAIL|CVT_BADTIME;
if (((u_char) recv_csum) != calc_csum) return CVT_FAIL|CVT_BADTIME;
clock_time->utcoffset = 0;
/* What should flags be set to ? */
clock_time->flags = PARSEB_UTC;
/* if the current GPS fix is 9 (unknown), reject */
if (0 > gpsfix || gpsfix > 9) clock_time->flags |= PARSEB_POWERUP;
return CVT_OK;
}
/*
* parse_inp_fnc_t inp_trimtaip
*
* grab data from input stream
*/
static u_long
inp_trimtaip(
parse_t *parseio,
char ch,
timestamp_t *tstamp
)
{
unsigned int rtc;