Web lists-archives.com

Re: [Spca50x-devs] FYI: status of 0ac8:307b




On Mon, 19 Jan 2009 11:48:58 +0600
AQUARIUS <aquarius2002@xxxxxxx> wrote:

> Hello.
> When I do usbsnoop with a 1 seconds of video stream, the log file is
> 40 megabytes.
> May be I can cut any part of it?

Hello,

I attached a usbsnoop parsing tool. It extracts and formats all the
important information.

Regards.

-- 
Ken ar c'hentan	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/
#!/bin/sh
# -*- tcl -*- \
exec tclsh "$0" ${1+"$@"}

proc isoc {fd} {
puts "isoc"
	while {[gets $fd line] >= 0} {
		switch -regexp -- $line {
		    "  URB " break
		}
	}
	return $line
}

proc vendor {fd} {
# outgoing message
	global nowtime prevtime
	set out 0
	set b {}
	while {[gets $fd line] >= 0} {
		switch -regexp -- $line {
		    "  URB " break
		    DIRECTION_OUT {
			set out 1
		    }
		    TransferBufferLength {
#			set l 0x[lindex $line 3]
		    }
		    00000..0: {
			if {$out} {
				if {[string length $b] != 0} {
					append b "\n\t\t  "
				}
				append b [lrange $line 1 end]
			}
		    }
		    "Request" {
			set r [format %02x 0x[lindex $line 2]]
		    }
		    "Value" {
			set v [format %04x 0x[lindex $line 2]]
		    }
		    "Index" {
			set i [format %04x 0x[lindex $line 2]]
		    }
		}
	}
	if {$out} {
		puts " SET $r $v $i $b"
	}
	return $line
}

proc ctrl {fd} {
# incoming message
	global nowtime prevtime
	set in 0
	set b {}
	set setup 0
	while {[gets $fd line] >= 0} {
		switch -regexp -- $line {
		    "  URB " break
		    DIRECTION_IN {
			set in 1
		    }
		    SetupPacket {
			set setup 1
		    }
		    "  00000" {
			if {!$in} continue
			if {!$setup} {
				if {[string length $b] == 0} {
					set b [lrange $line 1 end]
				} else {
					append b "\n<\t\t  "
					append b [lrange $line 1 end]
				}
			} else {
				set r [lindex $line 2]
				set v [lindex $line 4][lindex $line 3]
				set i [lindex $line 6][lindex $line 5]
			}
		    }
		}
	}
	if {$in} {
		puts "<GET $r $v $i $b"
	}
	return $line
}

proc interf {fd} {
# select interface
	set i {??}
	set a {??}
	while {[gets $fd line] >= 0} {
		switch -regexp -- $line {
		    "  URB " break
		    InterfaceNumber {
			set i [format %02x 0x[lindex $line 3]]
		    }
		    AlternateSetting {
			set a [format %02x 0x[lindex $line 3]]
		    }
		}
	}
	puts " intf $i alt $a"
	return $line
}

proc feature {fd} {
puts "feat"
	while {[gets $fd line] >= 0} {
		switch -regexp -- $line {
		    "  URB " break
		}
	}
	return $line
}

proc transf {fd} {
# bulk or interrupt transfer
	set in 0
	set b {}
	while {[gets $fd line] >= 0} {
		switch -regexp -- $line {
		    DIRECTION_IN {
			set in 1
		    }
		    "  00000" {
			if {[string length $b] == 0} {
				set b [lrange $line 1 end]
			} else {
				append b "\n\t\t  "
				append b [lrange $line 1 end]
			}
		    }
		    "  URB " break
		}
	}
	if {[string length $b] == 0} return
	if {$in} {
		puts "<Bulk/Int IN  $b"
	} else {
		puts " Bulk/Int OUT $b"
	}
	return $line
}

proc main {fn} {
	global nowtime prevtime
	if {[catch {open $fn r} fd]} {
		puts "cannot open '$fn'"
		exit 1
	}
	set nowtime 0
	set prevtime 0
	while {[gets $fd line] >= 0} {
		switch -regexp -- $line {
		    URB_FUNCTION_ISOCH_TRANSFER {
			set line [isoc $fd]
		    }
		    URB_FUNCTION_VENDOR {
			set line [vendor $fd]
		    }
		    URB_FUNCTION_CONTROL_TRANSFER {
			set line [ctrl $fd]
		    }
		    URB_FUNCTION_SELECT_INTERFACE {
			set line [interf $fd]
		    }
		    URB_FUNCTION_SET_FEATURE_TO_DEVICE {
			set line [feature $fd]
		    }
		    URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER {
			set line [transf $fd]
		    }
		}
		if {[regexp {\[([0-9]+) ms\]} $line dum ntime]} {
			set prevtime $nowtime
			set nowtime $ntime
			if {[string first down $line] > 0} {
				if {$nowtime > $prevtime + 2} {
					puts "== ([expr {$nowtime - $prevtime}] ms)"
				}
			}
			if {$nowtime > $prevtime + 200} {
				puts "== \[$nowtime ms\]"
			}
		}
	}
}

main $argv
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Spca50x-devs mailing list
Spca50x-devs@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/spca50x-devs