gpsd-dev
[Top][All Lists]
Advanced

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

Re: [gpsd-dev] [PATCH] gpscat: fix incorrect test againt rfcomm for blue


From: Bernd Zeimetz
Subject: Re: [gpsd-dev] [PATCH] gpscat: fix incorrect test againt rfcomm for bluetooth address
Date: Tue, 10 Jan 2012 09:25:37 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111114 Icedove/3.1.16

On 01/09/2012 06:24 PM, Alban Browaeys wrote:
> We feed arguments[0] to the bluetooth socket so this has to be
> the address and cannot contains "rfcomm" string.
> ---
>  gpscat |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/gpscat b/gpscat
> index f3903fa..a4b8ed3 100755
> --- a/gpscat
> +++ b/gpscat
> @@ -70,12 +70,12 @@ if __name__ == '__main__':
>                  printusage()
>                  raise SystemExit, 1
>  
> -        if "rfcomm" in arguments[0]:     # Bluetooth special case
> +        if arguments[0][0] == '/':       # Ordinary device

Just because a path starts with / we should not assume that we have an
ordinary device here. Device nodes could be everywhere in theory, and a
path might be relative.

> +            tty = os.open(arguments[0], os.O_RDWR)
> +        else:     # Bluetooth special case

There should be a better way to detect if a device is a bluetooth device
imho. Just assuming that all non-"ordinary" devices are bluetooth
devices sounds wrong. I guess we'll have other weird devices one day.

>              s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, 
> socket.BTPROTO_RFCOMM)
>              s.connect((arguments[0], 1))
>              tty = s.fileno()
> -        else:                            # Ordinary device
> -            tty = os.open(arguments[0], os.O_RDWR)
>  
>          if speed != None:
>              (iflag, oflag, cflag, lflag, ispeed, ospeed, cc) = 
> termios.tcgetattr(tty)


-- 
 Bernd Zeimetz                            Debian GNU/Linux Developer
 http://bzed.de                                http://www.debian.org
 GPG Fingerprints: ECA1 E3F2 8E11 2432 D485 DD95 EB36 171A 6FF9 435F



reply via email to

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