gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-dev] [PATCH] Clean up code, now that it works.


From: Chris Kuethe
Subject: Re: [gpsd-dev] [PATCH] Clean up code, now that it works.
Date: Sat, 28 Mar 2015 20:06:18 -0700

I think the right way to do copyrights is just to add a line of the form

Copyright (C) YYYY[,YYYY] Name <email>

For each contributor, listing the years in which substantial
contributions have been made. Clearly, I haven't touched that script
in years, and in your case "Copyright (c) 2015 Sanjeev Gupta
<address@hidden>" should be sufficient.

Small nit: is there some reason you're changing the comment format? If
you're doing it to unify the code style could you fix all of that in
one change, and all the logic in a separate change?


On Sat, Mar 28, 2015 at 9:29 AM, Sanjeev Gupta <address@hidden> wrote:
> ---
>  contrib/skyview.php | 52 ++++++++++++++++++++++++++--------------------------
>  1 file changed, 26 insertions(+), 26 deletions(-)
>
> diff --git a/contrib/skyview.php b/contrib/skyview.php
> index c2326b5..340e86c 100755
> --- a/contrib/skyview.php
> +++ b/contrib/skyview.php
> @@ -1,7 +1,7 @@
>  <?php
>
>  # Copyright (c) 2006,2007 Chris Kuethe <address@hidden>
> -# Copyright (c) 2015 Sanjeev Gupta <address@hidden>
> +# Updated 2015 by Sanjeev Gupta <address@hidden>
>  #
>  # Permission to use, copy, modify, and distribute this software for any
>  # purpose with or without fee is hereby granted, provided that the above
> @@ -25,11 +25,11 @@
>  //
>  // Because it now reads a live stream, the program must be run with an
>  // option, "count", to specify the number of SKY messages it reads.  SKY
> -// messages are ussually emitted every 5 secs, so a number close to 700
> +// messages are usually emitted every 5 secs, so a number close to 700
>  // will cover an hour's worth.
>  //
>  // Tested to work with php5.6 , although earlier versions may work.
> -//
> +
>
>  $cellmode = 0;
>  if ($argc != 3){
> @@ -40,14 +40,14 @@ if ($argc != 3){
>         }
>  }
>
> +// How many samples to read of SKY messages.
> +$count = $argv[1] ;
> +
>  $sz = 640;
>  $cellsize = 5; # degrees
>  $radius = 8; # pixels
>  $filled = 0;
>
> -$j = 0 ;
> -$count = $argv[1] ;
> -
>  $im = imageCreate($sz, $sz);
>  $C = colorsetup($im);
>  skyview($im, $sz, $C);
> @@ -57,11 +57,11 @@ $sky = array();
>
>  error_reporting(E_ALL);
>
> -/* Get the port for the GPSD service. */
> +// Get the port for the GPSD service.
>  $service_port = 2947 ;
> -/* Get the IP address for the target host. */
> +// Get the IP address for the target host.
>  $address = "127.0.0.1" ;
> -/* Create a TCP/IP socket. */
> +// Create a TCP/IP socket.
>  $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
>  if ($socket === false) {
>      echo "socket_create() failed: reason: " . 
> socket_strerror(socket_last_error()) . "\n";
> @@ -72,19 +72,19 @@ if ($result === false) {
>      echo "socket_connect() failed.\nReason: ($result) " . 
> socket_strerror(socket_last_error($socket)) . "\n";
>  }
>
> -$in = "?WATCH={\"enable\":true,\"json\":true};" ;
> +// Send a WATCH command.
> +$cmd = "?WATCH={\"enable\":true,\"json\":true};" ;
>
> -$out = '';
> -
> -socket_write($socket, $in, strlen($in));
> +socket_write($socket, $cmd, strlen($in));
>
> -while (($out = socket_read($socket, 2048)) && ( $j < $count) ){
> +// Start the loop to start reading from gpsd.
> +$out = '';
> +$j = 0 ;
> +while (($out = socket_read($socket, 2048)) && ( $j < $count) ) {
>
>         if (strpos($out, "SKY")) {
> -
> -       $j = $j + 1;
> -
> -       $PRN = json_decode($out,true);
> +               $j = $j + 1;
> +               $PRN = json_decode($out,true);
>  // var_dump($PRN) ;
>  // object(stdClass)#12 (5)
>  //       ["PRN"]=>
> @@ -98,15 +98,15 @@ while (($out = socket_read($socket, 2048)) && ( $j < 
> $count) ){
>  //       ["used"]=>
>  //       bool(false)
>
> -       $n =  count($PRN["satellites"]) ;
> -
> -               for($i = 0; $i < $n; $i++){
> +               $n =  count($PRN["satellites"]) ;
> +               for($i = 0; $i < $n; $i++) {
> +                       $sv = $PRN["satellites"][$i]["PRN"] ;
> +                       $el = $PRN["satellites"][$i]["el"] ;
> +                       $az = $PRN["satellites"][$i]["az"] ;
> +                       $snr = $PRN["satellites"][$i]["ss"] ;
> +                       $u = $PRN["satellites"][$i]["used"] ;
>
> -        $sv = $PRN["satellites"][$i]["PRN"] ;
> -        $el = $PRN["satellites"][$i]["el"] ;
> -        $az = $PRN["satellites"][$i]["az"] ;
> -        $snr = $PRN["satellites"][$i]["ss"];
> -        $u = $PRN["satellites"][$i]["used"];
> +// Below this, Chris' original code, more or less. -- Sanjeev 20150326
>
>                         if ($cellmode){
>                                 $az = $cellsize * (int)($az/$cellsize);
> --
> 2.1.4
>
>



-- 
GDB has a 'break' feature; why doesn't it have 'fix' too?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]