Am Dienstag 10 März 2009 20:02:23 schrieb JoJo jojo: > Hi > > On Tue, Mar 10, 2009 at 9:49 PM, GWater <[email protected]> wrote: > > Could you please provide us with a log? > > > > > > BTW I have a nice python script to extract the sensor_init. No need for > > copying the values with grep and hands-on anymore. > > > > GWater > > post the python script ;-) > > its kinda like chin-pokemon ;-) > gotta collect them all ! > > so far i got perl/java/tcl/c/ > > -JoJo > > --~--~---------~--~----~------------~-------~--~----~ > Lets make microdia webcams plug'n play, (currently plug'n pray) > To post to this group, send email to [email protected] > Visit us online https://groups.google.com/group/microdia > -~----------~----~----~----~------~----~------~--~---
But this pokemon actually works with the current version of our driver and not the old summer 2008 versions. (I realize GPL2+ is an unusual choice for a python script especially since it is so short. But hey - people can always ask me to relicense ;) .) GWater
#!/usr/bin/python # -*- coding: utf-8 -*- ## # @file sn9c20x-sensor-init-parser.py # @author Josua Grawitter <[email protected]> # @date 2009-3-11 # # @brief Reformat SniffUSB logs to code usable by the sn9c20x driver # # @note Copyright (C) Josua Grawitter # # @par Licences # # 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; either version 2 of the License, or # any later version. # # 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 ## import sys from PyQt4 import QtGui class I2CMessage: def __init__(self, urb=''): outp = self.analyse_raw_urb(urb) self.slave = outp[1] self.register = outp[2] self.readflag = 0 if (outp[0] & 2): self.readflag = 1 self.datalen = ((outp[0] >> 4) & 7) -1 self.data = [] for i in range(self.datalen): self.data.append(outp[i+3]) def analyse_raw_urb(self, urb=''): lines = urb.splitlines() for line in lines: if '0:' in line: buf = line.lstrip(' 0: ') break buf = ''.join((buf.split())) outp = [] for i in range(0, len(buf)/2): byte = buf[2*i:2*i+2] outp.append(int(byte, 16)) return outp def print_i2cmsg(self): if self.slave & int('50',16) == int('50',16): if self.datalen is 2: print '\t{0x%02x, 0x%04x},' % (self.register, ((self.data[0] << 8)+self.data[1])) elif self.datalen is 4: print '\t{0x%02x, 0x%04x},' % (self.register, ((self.data[0] << 8)+self.data[1])) print '\t{0x%02x, 0x%04x},' % (self.register+1, ((self.data[2] << 8)+self.data[3])) else: if self.datalen is 1: print '\t{0x%02x, 0x%02x},' % (self.register, self.data[0]) elif self.datalen is 2: print '\t{0x%02x, 0x%02x},' % (self.register, self.data[0]) print '\t{0x%02x, 0x%02x},' % (self.register+1, self.data[1]) elif self.datalen is 3: print '\t{0x%02x, 0x%02x},' % (self.register, self.data[0]) print '\t{0x%02x, 0x%02x},' % (self.register+1, self.data[1]) print '\t{0x%02x, 0x%02x},' % (self.register+2, self.data[2]) elif self.datalen is 4: print '\t{0x%02x, 0x%02x},' % (self.register, self.data[0]) print '\t{0x%02x, 0x%02x},' % (self.register+1, self.data[1]) print '\t{0x%02x, 0x%02x},' % (self.register+2, self.data[2]) print '\t{0x%02x, 0x%02x},' % (self.register+3, self.data[3]) class I2CLog: def __init__(self, filename): self.log = open(filename).read() self.i2cmessages = [] self.create_i2cmessages() self.remove_invalid() def create_i2cmessages(self): endurb = 0 i2cmessages = [] while endurb is not -1: starturb = self.log.find('going down', endurb) endurb = self.log.find('[', starturb) rurb = self.log[starturb-10:endurb] if 'USBD_TRANSFER_DIRECTION_OUT' in rurb: if '000010c0' in rurb: self.i2cmessages.append(I2CMessage(rurb)) def remove_invalid(self): i = 0 while i < len(self.i2cmessages): if self.i2cmessages[i].datalen < 1: self.i2cmessages[i:i+1] = [] i -= 1 elif self.i2cmessages[i].readflag is 1: self.i2cmessages[i:i+1] = [] i -= 1 i += 1 def print_i2cmessages(self): print 'struct sn9c20x_i2c_regs generic_init[] = {' for msg in self.i2cmessages: msg.print_i2cmsg() print '};' def main(): filename = sys.argv[1] onelog = I2CLog(filename) onelog.print_i2cmessages() """ app = QtGui.QApplication(sys.argv) mainwindow = QtGui.QWidget() mainwindow.resize(250, 150) mainwindow.setWindowTitle('sn9c20x I2C parsing') mainwindow.show() sys.exit(app.exec_()) """ if __name__ == "__main__": main()
signature.asc
Description: This is a digitally signed message part.
