[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Change from 3.23 to 3.24 - program doesn't work?
From: |
Gary E. Miller |
Subject: |
Re: Change from 3.23 to 3.24 - program doesn't work? |
Date: |
Sun, 19 Jun 2022 23:41:51 -0700 |
Yo David!
I can't see how that ever worked. Your program does not check
if the receiver JSON has the data you are trying to read.
Take a look at example.c for ideas on what is missing.
On Mon, 20 Jun 2022 06:26:46 +0100
David Taylor <gm8arv@yahoo.co.uk> wrote:
> I have a program which works under 3.23 but appears to run but not
> read gps data under 3.24. The part I am uncertain about is:
>
> status = gps_open (GPSD_SHARED_MEMORY, DEFAULT_GPSD_PORT,
> &gpsdata);
>
> #if GPSD_API_MAJOR_VERSION >= 7
> if (gps_read (&gpsdata, NULL, 0) == -1) {
> #else
> if (gps_read (&gpsdata) == -1) {
> #endif
> } else {
>
> used = gpsdata.satellites_used;
> visible = gpsdata.satellites_visible;
> int i; double snr_total=0;
> for(i=0; i<=visible; i++) {
> if (gpsdata.skyview[i].used > 0 && gpsdata.skyview[i].ss >
> 1) { snr_total+=gpsdata.skyview[i].ss;
> }
> }
> gps_close (&gpsdata);
>
> I am uncertain whether any changes would affect this code.
>
> This is a fresh install of 3.24, compiled from source, on a fresh
> install of the Raspberry Pi OS. cgps works correctly. gpsd started
> manually shows as running. No attempt to use systemd - yet.
>
> Versions:
>
> Linux RasPi-22 5.15.32-v7l+ #1538 SMP Thu Mar 31 19:39:41 BST 2022
> armv7l GNU/Linux
>
> cgps: 3.24.1~dev (revision release-3.24-138-g5a53fe309)
>
>
> The full program below in case it helps....
>
> ____________________________________
> /* Copyright (c) 2018-2021 David Taylor <gpsd@david.taylor.name>
>
> Permission to use, copy, modify, and distribute this software for
> any purpose without fee is hereby granted, provided that the above
> copyright notice and this permission notice appear in all copies.
>
> The user of the software is responsible for ensuring the accuracy
> of any data produced by the software.
>
> This software may not be used in safety-critical
> or life-critical systems. */
>
> #include <gps.h>
> #include <stdio.h>
> #include <string.h>
>
> int main (int argc, char **argv) {
> int status, used, visible;
> struct gps_data_t gpsdata;
>
> #define OID_VISIBLE ".1.3.6.1.2.1.25.1.31"
> #define OID_USED ".1.3.6.1.2.1.25.1.32"
> #define OID_SNR_AVG ".1.3.6.1.2.1.25.1.33"
>
> if ((argc > 2) && (strcmp ("-g", argv[1]) == 0))
> {
> status = gps_open (GPSD_SHARED_MEMORY, DEFAULT_GPSD_PORT,
> &gpsdata);
>
> #if GPSD_API_MAJOR_VERSION >= 7
> if (gps_read (&gpsdata, NULL, 0) == -1) {
> #else
> if (gps_read (&gpsdata) == -1) {
> #endif
> } else {
>
> used = gpsdata.satellites_used;
> visible = gpsdata.satellites_visible;
> int i; double snr_total=0;
> for(i=0; i<=visible; i++) {
> if (gpsdata.skyview[i].used > 0 && gpsdata.skyview[i].ss >
> 1) { snr_total+=gpsdata.skyview[i].ss;
> }
> }
> gps_close (&gpsdata);
> double snr_avg = 0.0;
> if (used > 0) {
> snr_avg = snr_total / used;
> }
> if (strcmp (OID_VISIBLE, argv[2]) == 0) {
> printf (OID_VISIBLE);
> printf ("\n");
> printf ("gauge\n");
> printf ("%d\n", visible);
> }
> if (strcmp (OID_USED, argv[2]) == 0) {
> printf (OID_USED);
> printf ("\n");
> printf ("gauge\n");
> printf ("%d\n", used);
> }
> if (strcmp (OID_SNR_AVG, argv[2]) == 0) {
> printf (OID_SNR_AVG);
> printf ("\n");
> printf ("gauge\n");
> printf ("%lf\n", snr_avg);
> }
> }
> }
> return 0;
> }
> ____________________________________
>
> Thanks,
> David
RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
gem@rellim.com Tel:+1 541 382 8588
Veritas liberabit vos. -- Quid est veritas?
"If you can't measure it, you can't improve it." - Lord Kelvin
pgp9B06nJiJuJ.pgp
Description: OpenPGP digital signature
- Change from 3.23 to 3.24 - program doesn't work?, David Taylor, 2022/06/20
- Re: Change from 3.23 to 3.24 - program doesn't work?,
Gary E. Miller <=
- Re: Change from 3.23 to 3.24 - program doesn't work?, David Taylor, 2022/06/20
- Re: Change from 3.23 to 3.24 - program doesn't work?, David Taylor, 2022/06/20
- Re: Change from 3.23 to 3.24 - program doesn't work?, David Taylor, 2022/06/20
- Re: Change from 3.23 to 3.24 - program doesn't work?, Gary E. Miller, 2022/06/20
- Re: Change from 3.23 to 3.24 - program doesn't work?, David Taylor, 2022/06/20
- Re: Change from 3.23 to 3.24 - program doesn't work?, Mike Tubby, 2022/06/21
- Re: Change from 3.23 to 3.24 - program doesn't work?, David Taylor, 2022/06/21
- Re: Change from 3.23 to 3.24 - program doesn't work?, Gary E. Miller, 2022/06/21
- Re: Change from 3.23 to 3.24 - program doesn't work?, Mike Tubby, 2022/06/22