File: statusmsg.c

package info (click to toggle)
dgpsip 1.33-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 324 kB
  • ctags: 161
  • sloc: ansic: 1,981; sh: 327; makefile: 50
file content (79 lines) | stat: -rw-r--r-- 1,955 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/******************************************************************************
*									      *
*	File:     statusmsg.c						      *
*	Author:   Wolfgang Rupprecht <wolfgang@capsicum.wsrcc.com>	      *
*	Created:  Tue Aug 24 12:40:49 PDT 1999				      *
*	Contents: process status_msgs                                         *
*									      *
*	Copyright (c) 1999 Wolfgang Rupprecht.				      *
*	All rights reserved.						      *
*									      *
*	$Id: statusmsg.c,v 1.2 1999/08/24 20:58:26 wolfgang Exp $								      *
******************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>

#include "config.h"
#include "rtcm.h"

void
status_byte(u_char b)
{
    static u_char   buffer[32];
    static u_char  *ptr = buffer;

    /*    printf("-\tstatus\t-\t%d 0x%x\n", b, b); */

    if (ptr >= (buffer + sizeof(buffer))) {	/* overflowing? roll buffer */
	ptr = buffer;
    }
    *ptr++ = b;
    switch (*buffer) {
    case 0xc1:
	if ((ptr - buffer) >= 6) {/* 6-byte request confirmation */
	    u_int           freq;
	    u_int           baud;

	    freq = ((buffer[1] & 0x3f) << 6) | (buffer[2] & 0x3f);
	    switch (buffer[3]) {
	    case 0xd4:
		baud = 25;
		break;
	    case 0xd5:
		baud = 50;
		break;
	    case 0xd6:
		baud = 100;
		break;
	    case 0xd7:
		baud = 200;
		break;
	    default:
		baud = 0;
		break;
	    }
	    printf("f\t%d\t%d\n", freq, baud);
	    ptr = buffer;	/* reset buffer */
	}
	break;
    case 0xc8:
	if ((ptr - buffer) >= 4) {/* 4-byte request status */
	    u_int           stren;
	    u_int           snr;

	    stren = ((buffer[1] & 0x3f) << 6) | (buffer[2] & 0x3f);
	    snr = buffer[3] & 0x3f;
	    printf("s\t%d\t%d\n", stren, snr);
	    ptr = buffer;	/* reset buffer */
	}
	break;
    default:			/* unknown -- punt */
#ifdef DEBUG
	printf("-\tstatus\t-\t%d\t0x%x\n", b, b);
#endif
	ptr = buffer;		/* reset buffer */
	break;
    }
}