Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 293841 Details for
Bug 431379
System freeze on reading from usb-serial device
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
Perl script for reading raw data from AT91xx based GPS-Loggers
iTU4l.pl (text/plain), 14.39 KB, created by
Dmitry Burstein
on 2008-02-03 21:50:51 UTC
(
hide
)
Description:
Perl script for reading raw data from AT91xx based GPS-Loggers
Filename:
MIME Type:
Creator:
Dmitry Burstein
Created:
2008-02-03 21:50:51 UTC
Size:
14.39 KB
patch
obsolete
>#!/usr/bin/perl -w >############################################################################### ># THIS SOFTWARE IS FREE SOFTWARE! IT IS LICENCED UNDER THE GNU PUBLIC LICENCE ># ># This program is free software; you can redistribute it and/or modify ># it under the terms of the GNU General Public License as published by ># the Free Software Foundation; version 2 of the License ># ># This program is distributed in the hope that it will be useful, ># but WITHOUT ANY WARRANTY; without even the implied warranty of ># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ># GNU General Public License for more details. ># ># You should have received a copy of the GNU General Public License ># along with this program; if not, write to the Free Software ># Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >############################################################################### ># (c) Hartmut Schimmel, 07.10.2007 > ># 07.10.2007 sml first release ># 08.10.2007 sml added option -e ># 13.10.2007 sml improved alarm handler for better timing and less cpu usage ># outfile extension changed to .sr to be compatible with windows ># 31.10.2007 sml support for GisTeq PhotoTrackr added ># 02.01.2008 sml better chipset names > > ># TODO ># extract hardware and firmware revisions from the info dump ># add support for __write__ logger settings > > >use IO::Handle; >use Getopt::Std; > >use strict; > >STDOUT->autoflush(1); > > > >############################################################################### ># Declarations and definitions >############################################################################### >use constant NULL => chr 0; >use constant MEMSIZE => 3993600; > >my $dump; >my %o; > > > >############################################################################### ># Usage >############################################################################### >( my $prg = $0 ) =~ s/^.*\/([^\/]+)$/$1/g; > >sub usage { > die <<EOF; > >$prg reads the memory from the XAIOX iTrackU and Gisteq PhhotoTrackr GPS logger >to a file. The format of this file is the same as from the .sr file of XAiOX >Windows tool. > >(c) Hartmut Schimmel, $prg\@schimmelnetz.de, 2007/10/13 > >Usage: $prg [options] > >Options: -a automatic mode: detect the right USB device and read > out the data from the logger. This should be the > normal way. > > -s scan only for the USB device to which the logger is > connected, no memory reading will be done > > -d <device> USB device to use, if the automatic detection does > not work, includes memory reading > > -i only print out information about the logger settings > > -o <file> write output to this file instead of the default file > name, which is generated from the actual system time > > -e erase logger data, for security only possible together > with reading the memory to disk, always combine with > -d <device> or -a > > >Example: $prg -s # scan > > $prg -d /dev/ttyUSB1 # use /dev/ttyUSB1 as device > > $prg -i # print information about the logger settings > > $prg -o my_gps_log.sr # write to file named "my_gps_log.sr" > > $prg -e # erase all track data on the logger > > however, in most cases it should do what you want if you only type > > $prg -a > > >This software is published under the GPL V2.0 > >EOF >} > > >usage if ( $#ARGV == -1 ); >usage unless getopts('asd:io:e', \%o); > > >die "It does not make sense to combine the options -a and -d\n" > if ( (defined $o{a}) and (defined $o{d})); >die "It does not make sense to combine the options -s and -d\n" > if ( (defined $o{s}) and (defined $o{d})); >die "Option -e (erase) is not accepted without memory reading for security\n" . > "reasons. So combine -e always with -a or -d <device>\n" > if ( (defined $o{e}) and not ((defined $o{d}) or (defined $o{a}))); > > >$o{a} = '' unless defined $o{d}; >my @device; >push @device, $o{d} if defined $o{d}; > > > >############################################################################### ># Autodetect device magic ;-) >############################################################################### >if (( defined $o{s}) or ( defined $o{a})) { > > > # Scan directories which typical contain USB devivece files > foreach my $dir ( qw( /dev /dev/usb/tts )) { > > if ( opendir DH, $dir ) { > print "Searching for USB device files in $dir\n"; > > while ( defined( $_ = readdir DH)) { > > # /dev/usb/tty device files all should match > if ( $dir eq '/dev/usb/tts' ) { > push @device, "$dir/$_"; > } > # other devices names should contain at least USB > else { > next unless /^(.*USB.*\d+).*$/i; > push @device, "$dir/$1"; > } > } > close DH; > } > else { > print "Skipping $dir because it does not exist\n"; > } > } > > > if ( $#device >= 0 ) { > print "\nFound USB devices:\n"; > foreach ( sort @device ) { > print " $_\n"; > } > } > else { > die <<EOF; > >No USB devices found. To find them please follow the instructions on > >http://www.schimmelnetz.de/projekte/iTU4l/usb.html > >Good luck. > >EOF > } >} > > >############################################################################# ># Check for stty >############################################################################# ># speed seems to be auto-detected, so only 8N1 raw needs to be set >die <<EOF unless !system('which stty > /dev/null'); > >We need the stty tool to set mode 8N1 raw to the serial device. It should be >available on most common Linux/Unix systems. However here it is missing. >Please install it according to your distributions rules. For Debian and >Ubuntu it is included in the package 'coreutils'. To install it you have to >type as root: > >apt-get install coreutils > >Please tell the author of $prg, how stty is installed on other >distributions than Debian and Ubuntu. > >EOF > > > >############################################################################### ># install an alarm handler to interrupt a pending access to the device >############################################################################### >my $was_timeout = 0; >$SIG{ALRM} = sub { $was_timeout = 1; exit 1 }; > > > >############################################################################### ># Try to access the devices we have found above >############################################################################### >print "\nTrying to talk to the USB device(s)\n"; >my $device_found = 0; >foreach my $device ( sort @device ) { > > > # Serial device settings > if ( !system( "stty cs8 raw < $device") ) { > print " Set $device to mode 8N1 raw using the stty system command\n"; > } > else { > print " Error while setting $device to 8N1 raw mode: $!\n"; > next; > } > > > my $name; > > $was_timeout = 0; > eval { > > # open the serial device > unless ( open( SERIAL, "+<$device") ) { > print " Error while opening $device: $!\n"; > $was_timeout = 1; > exit 1; > } > > > print " Opened $device\n"; > SERIAL->autoflush(1); > > > # try to Initialize the logger > print SERIAL "WP AP-Exit" . NULL; # close possibly pending session > print SERIAL "W'P Camera Detect" . NULL; # init new session > > alarm(2); # (re)set timeout after 2 sec > while (1) { > sysread( SERIAL, $_, 1) or die $!; > last if $_ eq NULL; > $name .= $_; > } > }; > alarm(0); # no timeout > > if ( $was_timeout == 1 ) { > print " Timeout occured during access to $device - assuming that this\n" . > " device is not the right one\n\n"; > next; > } > else { > print " Device $device answered with \'$name\'\n"; > if ( $name eq 'WP GPS+BT' ) { > print " *** fine, $device is it ***\n\n"; > $device_found = 1; > last; > } > else { > print " *** unexpected, assuming that this device is not the right " . > "one\n\n"; > next; > } > } >} >print "USB device talk test finished\n"; >die <<EOF if $device_found == 0; > >USB devices found, but not detected as the GPS logger we searched. To find >it please follow the instructions on > >http://www.schimmelnetz.de/projekte/iTU4l/usb.html > >EOF > ># Exit here if only scan was wanted >exit 0 if defined $o{s}; > > > >############################################################################### ># Request device info >############################################################################### >print "\nGetting device information and configuration data from the logger\n"; ># 0x5B 0xB0 >print SERIAL chr(91) . chr(176) . NULL . NULL . NULL . NULL . NULL; > >my $device_info; >for ( my $byte = 1; ; $byte++) { > > $was_timeout = 0; > eval { > alarm(2); # (re)set timeout after 2 sec > sysread( SERIAL, $_, 1) or die $!; > }; > last if $was_timeout == 1; > $device_info .= $_; >} >alarm(0); # no timeout > >my ( $dummy0, $serial_no, $dummy1, $type, $dummy2 ) = > unpack( "L L A32 A8 A*", $device_info); > > ># Serial No. : Byte 8-5 : unsigned 32 bit ># Type : Byte 41-48: Bytestring > > >my $chipset = "unknown"; >if ( $type eq "BT-CD100" ) { > $chipset = "XAiOX iTrackU - Nemerix"; >} >elsif ( $type eq "BT-CD110" ) { # not shure, which chipset the Gisteq has > $chipset = "Gisteq PhotoTrackr - Nemerix"; >} >elsif ( $type eq "BT-CD160" ) { # does BT-CD160 realy means SIRFIII ? > $chipset = "XAiOX iTrackU - SIRFIII"; >} >print " Type : $type\n"; >print " Chipset : $chipset\n"; >print " Serial No. : $serial_no\n"; >print " Hardware Rev. : (detection not yet supported)\n"; >print " Firmware Rev. : (detection not yet supported)\n"; > > > >############################################################################### ># Request configuration settings >############################################################################### ># 0x62 0xB6 >print SERIAL chr(98) . chr(182) . NULL . NULL . NULL . NULL . NULL; > >my $config_setting; >$was_timeout = 0; >for ( my $byte = 1; ; $byte++) { > > eval { > alarm(2); # (re)set timeout after 2 sec > sysread( SERIAL, $_, 1) or die $!; > }; > last if $was_timeout == 1; > $config_setting .= $_; >} >alarm(0); # no timeout > >my ( $time, $distance, $sensitivy, $dummy3, $tag, $dummy4 ) = > unpack( "L L C A15 C A*", $config_setting); > ># Time : Byte 4-1: unsigned 32 bit ># Distance : Byte 8-5: unsigned 32 bit ># Sensitivity: Byte 9: 2-high, 1-middle, 3-low, 0-disable ># Tag : Byte 25: 0-off, 1-on > > > >$time = "unused" if $time == 0xFFFFFFFF; >$distance = "unused" if $distance == 0xFFFFFFFF; > >print " Sensitivity : $sensitivy ("; >if ( $sensitivy == 0 ) { print "disabled)\n" }; >if ( $sensitivy == 1 ) { print "middle)\n" }; >if ( $sensitivy == 3 ) { print "low)\n" }; >if ( $sensitivy == 2 ) { print "high)\n" }; > >print " Tag : $tag ("; >if ( $tag == 0 ) { print "off)\n" }; >if ( $tag == 1 ) { print "on)\n" }; > > >print " Time-Step : $time", $time eq 'unused' ? "\n":" sec\n"; >print " Distance-Step : $distance", $distance eq 'unused' ? "\n":" meter\n"; > >if ( $time eq 'unused' ) { > printf "Based on Distance-Step there will fit about %d km into the logger\n", > MEMSIZE / 16 * $distance / 1000; >} >elsif ( $distance eq 'unused' ) { > printf "Based on Time-Step there will fit about %.1f days into the logger\n", > MEMSIZE / 16 * $time / 3600 / 24; >} > ># Exit here if only information was wanted >exit 0 if defined $o{i}; > > > >############################################################################### ># Request the memory dump >############################################################################### >print "\nReading memory\n"; ># 0x60 0xB5 >print SERIAL chr(96) . chr(181) . NULL . NULL . NULL . NULL . NULL; > > >my $kbyte = 0; > >$was_timeout = 0; >for ( my $byte = 1; ; $byte++) { > > eval { > alarm(2); # (re)set timeout after 2 sec > sysread( SERIAL, $_, 1) or die $!; > }; > last if $was_timeout == 1; > > $dump .= $_; > if ( int( $byte / 1024 / 10) > $kbyte / 10 ) { > $kbyte = int( $byte / 1024 ); > printf " %04d kByte\r", $kbyte; > } >} >alarm(0); # no timeout >printf " %d Bytes read\n", length( $dump); > > > >############################################################################### ># Check for correct end of data >############################################################################### ># 57 50 20 55 70 64 61 74 65 20 4F 76 65 72 00 WP Update Over. >die <<EOF unless substr( $dump, -15) eq "WP Update Over" . chr(0); > >ERROR: Recieved date not complete, missing 'WP Update Over' ant the end - Abort > >EOF > > > >############################################################################### ># Erase logger >############################################################################### >if ( defined $o{e} ) { > print "\nErasing memory\n"; > > > $was_timeout = 0; > my $answer; > > eval { > > # 0x61 0xB6 > print SERIAL chr(97) . chr(182) . NULL . NULL . NULL . NULL . NULL; > > while (1) { > alarm(2); # (re)set timeout after 2 sec > sysread( SERIAL, $_, 1) or die $!; > last if $_ eq NULL; > $answer .= $_; > } > }; > alarm(0); # no timeout > > if ( $was_timeout == 1 ) { > print " Timeout occured during erase\n"; > } > if ( $answer ne 'WP Update Over' ) { > print " Unexpected answer\n"; > } >} > > > >############################################################################### ># Close session >############################################################################### >print SERIAL "WP AP-Exit" . NULL; >close SERIAL; > > > >############################################################################### ># Write dump to outfile >############################################################################### >my $outfile; >if ( defined $o{o} ) { > $outfile = $o{o}; >} >else { > my $now = time(); > my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime( $now); > $mon++; $year += 1900; > > $outfile = sprintf( "iTU4l_%04d%02d%02d%02d%02d%02d.sr", > $year, $mday, $mon, $hour, $min, $sec); >} > ># cut away the "WP Update Over" at the end >$dump = substr( $dump, 0, (int( length($dump)/16 ) - 1) * 16); > >print "Writing ", length( $dump), " Bytes to $outfile\n"; >open OUTFILE, ">$outfile" or die "Error while writing $outfile: $!\n"; > > >print OUTFILE $dump; >close OUTFILE; > > > >print "All done.\n"; >exit 0; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 431379
: 293841 |
296661
|
296683
|
296859
|
296903
|
296951