コード例 #1
0
ファイル: tt4D.py プロジェクト: goldber/tt4ScriptOpen
def tt4ResumeScan():
    resumeCommand = [0x04, 0x00, 0x05, 0x00, 0x2F, 0x00, 0x04]
    success = 0x2F
    tt4.delayMs(1)
    while success != 0x1F:
        tt4.i2cw(TT4Addr, resumeCommand)
        try:
            GPIO.wait_for_edge(bInt, GPIO.FALLING, timeout=300)
            result = tt4.i2cr(TT4Addr, 5)
            success = result[2]
            print 'resume scan response {0}'.format(result)
        except KeyboardInterrupt:
            GPIO.cleanup()
コード例 #2
0
ファイル: tt4R.py プロジェクト: hwtseng1976/tt4ScriptOpen
def tt4SusScan():
    susCommand=[0x04,0x00,0x05,0x00,0x2F,0x00,0x03]
    success=0x2F
    #tt4.i2cw(TT4Addr,susCommand)
    tt4.delayMs(1)
    while success!=0x1F:
        tt4.i2cw(TT4Addr,susCommand)
        try:
            #tt4.i2cw(TT4Addr,susCommand)
            GPIO.wait_for_edge(bInt,GPIO.FALLING,timeout=300) 
            result=tt4.i2cr(TT4Addr,5)
            success=result[2]
            print 'suspend scan response {0}'.format(result)
        except KeyboardInterrupt:
            tt4.ldoPowerOff()  
            GPIO.cleanup()
コード例 #3
0
def tt4Sy(): 
    if len(sys.argv)<3 or len(sys.argv)>4:
        print 'wrong number of argument number'
        sys.exit()       
    elif len(sys.argv)==3 and sys.argv[2].startswith('--'):
        susTime=int(sys.argv[2][2:])
        fprint=0
        print 'suspend waiting time={0} sec' .format(susTime)        
    elif len(sys.argv)==4 and sys.argv[3].startswith('--'):
        susTime=int(sys.argv[2][2:]) # in sec
        filename=sys.argv[3][2:] 
        print filename
        fo = open(filename, "w")
        fprint=1
        print 'suspend waiting time={0} sec' .format(susTime)
    else:
        print 'wrong argument inputed'
        sys.exit()
       
    tt4.TT4Init()
    count=0
    tPalmon=0
    tInit=time.time()
    tPre=tInit
    print 'please put you palm on the screen.'
    print 'Please swipe the palm till suspend show finish'
    try:
        while True:
            if GPIO.input(bInt)==0 and tPalmon<=5000:
                #print 'time:%s INT Low'%time.time()
                count=count+1
                tNow=time.time()
                diff=(tNow-tPre)*1000
                tPalmon=(tNow-tInit)*1000
                tPre=tNow
                data1=tt4.readFgData(TT4Addr,3,10)
                a,b=tt4.TT4resolve(data1)
                count1=0
                #print a[0][4],a[0][3]
                if a[0][4]==0:
                    if a[0][3]==1:
                        print 'LO:{0}, large Object Detected' .format(a[0][3])
                        if fprint==1:
                            fo.write('RID:{0},TDF:{1},LO:{2},NE:{3},LargeObj\n'\
                            .format(a[0][1],diff,a[0][3],a[0][6]))
                    else:
                         print 'RID:{0}, liftoff' .format(a[0][1])
                         if fprint==1:
                            fo.write('RID:{0},TDF:{1},LO:{2},NE:{3},liftoff\n'\
                            .format(a[0][1],diff,a[0][3],a[0][6]))                                           
                else:
                    while count1<a[0][4]:
                        print 'RID:{0},TDF:{1},LO:{2},NE:{3},TIP:{4},EID:{5},TID:{6},{7},{8},{9},{10},{11},{12},'\
                        .format(a[0][1],diff,a[0][3],a[0][6],b[count1][1],\
                        b[count1][2],b[count1][3],b[count1][4],b[count1][5],\
                        b[count1][6],b[count1][7],b[count1][8],b[count1][9]) 
                        if fprint==1:
                            if count1==0:
                                fo.write('RID:{0},TDF:{1},LO:{2},NE:{3},'\
                                .format(a[0][1],diff,a[0][3],a[0][6]))
                                fo.write('Type:{0},TIP:{1},EID:{2},TID:{3},{4},{5},{6},{7},{8},{9},'\
                                .format(b[count1][0],b[count1][1],b[count1][2],b[count1][3],\
                                b[count1][4],b[count1][5],b[count1][6],b[count1][7],\
                                b[count1][8],b[count1][9])) 
                            else:
                                fo.write('Type:{0},TIP:{1},EID:{2},TID:{3},{4},{5},{6},{7},{8},{9},'\
                                .format(b[count1][0],b[count1][1],b[count1][2],b[count1][3],\
                                b[count1][4],b[count1][5],b[count1][6],b[count1][7],\
                                b[count1][8],b[count1][9])) 
            
                        count1=count1+1                   
                    if fprint==1:                
                        fo.write('\n')
                tt4.delayMs(0.5)
            elif tPalmon<=5000 and GPIO.input(bInt)==1:
                tcal=time.time()
                tPalmon=(tcal-tInit)*1000
                tt4.delayMs(1)            
            elif tPalmon>5000 and GPIO.input(bInt)==1:  # supend start
                tt4.tt4SusScan()
                print 'Scan susped start. Please swip the palm or finger on the screen'
                if fprint==1:
                    fo.write('Scan suspend start\n')
                tt4.delayMs(susTime*1000)               
                print 'Scan resume start. Please liftoff the palm and finger'
                tt4.tt4Resume()
                tInit=time.time()
                if fprint==1:
                    fo.write('Scan resumed\n')
                tPalmon=0
    except KeyboardInterrupt:
        print 'exit check :%s' %time.time()
        tt4.ldoPowerOff()               
        GPIO.cleanup()
        if fprint==1:
            fo.close()
コード例 #4
0
ファイル: tt4S.py プロジェクト: hwtseng1976/tt4ScriptOpen
def tt4GetScan(txNum,rxNum,cmdNum):
    cmdNumM=cmdNum
    cmdNumS=cmdNum+3
    retriveScanDataM=[0x04,0x00,0x0A,0x00,0x2F,0x00,0x2B,0x00,0x00,0xFF,0xFF,cmdNumM]
    retriveScanDataS=[0x04,0x00,0x0A,0x00,0x2F,0x00,0x2B,0x00,0x00,0xFF,0xFF,cmdNumS]    
    totalByte=(txNum*rxNum)    
    mutual=np.zeros((1,totalByte*2))
    self=np.zeros((1,(txNum+rxNum)*2))
    
    # start to retrive data
    tt4PanlScan()
    
    print 'Start to retrive Data'    
    countByte=0
    index=0
    executeCmd=1
    while countByte<totalByte: # read Mutal data
        if executeCmd==1:
            tt4.i2cw(TT4Addr,retriveScanDataM)
        else:
           executeCmd=0
        try:
            #GPIO.wait_for_edge(bInt,GPIO.FALLING,timeout=500)            
            if GPIO.input(bInt)==0:
                result=tt4.i2cr(TT4Addr,2)
                print result
                packetLength=(result[1]<<8)+result[0]
                result=tt4.i2cr(TT4Addr,packetLength)
                thisSensByte=(result[8]<<8)+result[7]
                countByte=countByte+thisSensByte
                print 'countByte byte:{0}' .format(countByte)
                print 'This sense total byte:{0}'.format(packetLength)
                retriveScanDataM[7]=countByte&0x00FF      # offset value         
                retriveScanDataM[8]=(countByte>>8)&0xFF   # offset value
                count=0         
                while count<(thisSensByte*2):
                    val=int((result[count+11]<<8)+result[count+10])
                    if cmdNum==2:
                        val=twos_comp(val,16)
                    else: 
                        val=val
                    mutual[0][index]=val 
                    count=count+2
                    index=index+1
                tt4.delayMs(0.5)
                executeCmd=1
            else:
                tt4.delayMs(1)
                executeCmd=0                
        except KeyboardInterrupt:
            tt4.ldoPowerOff() 
            GPIO.cleanup()
# start to retrive Self data
    tt4PanlScan()    
    print 'Start to retvie self data'
    index=0
    countByte=0
    executeCmd=1
    while countByte<(txNum+rxNum):
        if executeCmd==1:
            tt4.i2cw(TT4Addr,retriveScanDataS)
        try:
            #GPIO.wait_for_edge(bInt,GPIO.FALLING)
            if GPIO.input(bInt)==0:
                result=tt4.i2cr(TT4Addr,2)
                packetLength=(result[1]<<8)+result[0]
                result=tt4.i2cr(TT4Addr,packetLength)
                thisSensByte=(result[8]<<8)+result[7]
                countByte=countByte+thisSensByte
                print 'countByte:{0}'.format(countByte)
                print 'PacketLength:{0}'.format(packetLength)
                retriveScanDataS[7]=countByte&0x00FF            
                retriveScanDataS[8]=(countByte>>8)&0xFF 
                count=0          
                while count<(thisSensByte*2):
                    val=int((result[count+11]<<8)+result[count+10])
                    if cmdNum==2:
                        val=twos_comp(val,16)
                    self[0][index]=val 
                    count=count+2
                    index=index+1
                tt4.delayMs(0.5)
                executeCmd=1
            else:
                tt4.delayMs(1)
                executeCmd=0                
        except KeyboardInterrupt:
            tt4.ldoPowerOff()
            GPIO.cleanup()
    return mutual,self    
コード例 #5
0
ファイル: tt4S.py プロジェクト: hwtseng1976/tt4ScriptOpen
def tt4S():
    fprint=0
    if len(sys.argv)<3 or len(sys.argv)>5:
        print 'wrong argument'
        GPIO.cleanup()
        sys.exit()
    elif len(sys.argv)==3 and sys.argv[2].startswith('--'):
        print 'Without sav to file arguments'
        cmdNum=int(sys.argv[2][2:])
        print 'Command Number is: 0x%02x' %cmdNum
    elif len(sys.argv)==4 and sys.argv[3].startswith('--'):
        print 'with save to file arguments'
        cmdNum=int(sys.argv[2][2:])
        print 'Command Number is: 0x%02x' %cmdNum
        filename=sys.argv[3][2:]
        print 'fileName:{0}'.format(filename)          
        fo = open(filename, "w")
        fprint=1
    else:
        print 'wrong argument'
        
    tt4.TT4Init()
    tt4.delayMs(1)
    tt4.tt4SusScan()
    tt4.delayMs(1)
    [xNum,yNum]=tt4.tt4GetSysInf() #rx=x; tx=y
    totalByte=xNum*yNum*2      
    mutual=np.zeros((1,totalByte/2))
    self=np.zeros((1,(yNum+xNum)))    
    try:
        while True:
            print 'Initial get:%s' %time.time()      
            index=0
            indexTx=0        
            tt4.delayMs(2)           
            mutual,self=tt4GetScan(yNum,xNum,cmdNum)
            while index<(totalByte/2):
                print '{0},'.format(mutual[0][index]),
                if fprint==1:
                    fo.write('{0},'.format(mutual[0][index]))                      
                    index=index+1
                if index%xNum==0:
                    print '{0},'.format(self[0][indexTx+xNum]),
                    print ''
                    if fprint==1:
                        fo.write('{0}\n'.format(self[0][indexTx+xNum]))
                        indexTx=indexTx+1
                            
            for i in range(0,xNum):
                print '{0},'.format(self[0][i]),
                if fprint==1:
                    fo.write('{0},'.format(self[0][i]))
            print ''
            if fprint==1:
                fo.write('\n')
                fo.write('Page Start\n')
    except KeyboardInterrupt:
        print 'exit :%s' %time.time() 
        tt4.ldoPowerOff()  
        GPIO.cleanup()
        if fprint==1:
            fo.close()
コード例 #6
0
ファイル: tt4R.py プロジェクト: hwtseng1976/tt4ScriptOpen
def tt4GetRawData(txNum,rxNum):
    cmSelfTestCmd=[0x04,0x00,0x06,0x00,0x2F,0x00,0x26,0x05]
    cmGetRepCmd=[0x04,0x00,0x0A,0x00,0x2F,0x00,0x27,0x00,0x00,0xFF,0xFF,0x05]
    cpSelfTestCmd=[0x04,0x00,0x06,0x00,0x2F,0x00,0x26,0x06]
    cpGetRepCmd=[0x04,0x00,0x0A,0x00,0x2F,0x00,0x27,0x00,0x00,0xFF,0xFF,0x06]
    totalByte=(txNum*rxNum*2)+2    
    cmRawData=np.zeros((1,totalByte/2))
    #icpRawData=np.zeros((1,txNum+rxNum+2))
    cpRawData=np.zeros((1,(txNum*2+rxNum*2)))
    
    # start to do Cm Self test
    print 'start to do Cm Self test'
    statusResult=0xFFFF
    while statusResult!=0x0000:
        tt4.i2cw(TT4Addr,cmSelfTestCmd)
        try:        
            GPIO.wait_for_edge(bInt,GPIO.FALLING,timeout=300) 
            result=tt4.i2cr(TT4Addr,7)
            statusResult=(result[5]<<8)+result[6]
            print result
            if statusResult==0x0000:            
                print 'Cm Self Test Status+Result:0x%04x' %statusResult
            elif result[5]==0xff:
                print 'not support Cm self test ID 0x05'
                GPIO.cleanup()
                sys.exit()
            elif result[6]==0x01:
                print 'Cm self test Fail'
                GPIO.cleanup()
                sys.exit()               
        except KeyboardInterrupt:
            tt4.ldoPowerOff()  
            GPIO.cleanup()
    
    countByte=0
    index=0
    executeCmd=1
    while countByte<totalByte: # read Cm self test raw data;
        if executeCmd==1:
            tt4.i2cw(TT4Addr,cmGetRepCmd)
        try:
            #GPIO.wait_for_edge(bInt,GPIO.FALLING,timeout=500)            
            if GPIO.input(bInt)==0:
                result=tt4.i2cr(TT4Addr,2)
                print result
                packetLength=(result[1]<<8)+result[0]
                result=tt4.i2cr(TT4Addr,packetLength)
                thisSensByte=(result[8]<<8)+result[7]
                countByte=countByte+thisSensByte
                print 'countByte byte:{0}' .format(countByte)
                print 'This sense total byte:{0}'.format(packetLength)
                cmGetRepCmd[7]=countByte&0x00FF      # offset value         
                cmGetRepCmd[8]=(countByte>>8)&0xFF   # offset value
                count=0         
                while count<(thisSensByte):
                    cmRawData[0][index]=int((result[count+11]<<8)+result[count+10]) #fF/10
                    count=count+2
                    index=index+1
                tt4.delayMs(1)
                executeCmd=1
            else:
                tt4.delayMs(2)
                executeCmd=0                
        except KeyboardInterrupt:
            tt4.ldoPowerOff()
            GPIO.clearnup()
    #Send Cp Self test start     
    statusResult=0xFFFF     
    tt4.i2cw(TT4Addr,cpSelfTestCmd)     
    try:
        while statusResult==0xFFFF:
            GPIO.wait_for_edge(bInt,GPIO.FALLING,timeout=300) 
            result=tt4.i2cr(TT4Addr,7)
            statusResult=(result[5]<<8)+result[6]
            print result
            if statusResult==0x0000:            
                print 'Cp Self Test Status+Result:0x%04x' %statusResult
            elif result[5]==0xFF:
                print 'not support Cp self test ID 0x06'
                GPIO.cleanup()
                sys.exit()
            elif result[6]==0x01:
                print 'not support Cp self test fail'
                tt4.ldoPowerOff()
                GPIO.cleanup()
                sys.exit()           
    except KeyboardInterrupt:
        tt4.ldoPowerOff()
        GPIO.cleanup()
    index=0
    countByte=0
    executeCmd=1
    while countByte<(txNum+rxNum)*4:
        index=0
        #countByte=0
        tt4.i2cw(TT4Addr,cpGetRepCmd)
        try:
            #GPIO.wait_for_edge(bInt,GPIO.FALLING)
            if GPIO.input(bInt)==0:
                result=tt4.i2cr(TT4Addr,2)
                packetLength=(result[1]<<8)+result[0]
                result=tt4.i2cr(TT4Addr,packetLength)
                thisSensByte=(result[8]<<8)+result[7]
                countByte=countByte+thisSensByte
                print 'Cp countByte:{0}'.format(countByte)
                print 'Cp PacketLength:{0}'.format(packetLength)
                cpGetRepCmd[7]=countByte&0x00FF            
                cpGetRepCmd[8]=(countByte>>8)&0xFF 
                count=0          
                while count<(thisSensByte):
                    cpRawData[0][index]=int((result[count+11]<<8)+result[count+10]) #fF/10
                    count=count+2
                    index=index+1
                tt4.delayMs(1)
                executeCmd=1
            else:
                executeCmd=0
                tt4.delayMs(2)                
        except KeyboardInterrupt:
            tt4.ldoPowerOff() 
            GPIO.cleanup()
    return cmRawData,cpRawData    
コード例 #7
0
ファイル: tt4R.py プロジェクト: hwtseng1976/tt4ScriptOpen
def tt4R():
    fprint=0
    if len(sys.argv)<2 or len(sys.argv)>4:
        print 'no tx or rx number arguments or wrong arguments'
        GPIO.cleanup()
        sys.exit()
#    elif len(sys.argv)==3:
#        Print 'start to get the system information'
#        sysinf=int(sys.argv[2][2:])
#        if sysinf=='sysInf':
#            tt4GetSysInf()
#    elif len(sys.argv)==4:
#        print 'no save to file arguments'
#        txNum=int(sys.argv[2][2:])
#        rxNum=int(sys.argv[3][2:])
#        print 'txNum:{0},rxNum{1}'.format(txNum,rxNum)
#        fprint=0
    elif len(sys.argv)==3:
        print 'with save to file arguments'
        #txNum=int(sys.argv[2][2:])
        #rxNum=int(sys.argv[3][2:])
        filename=sys.argv[2][2:]
        print 'fileName:{0}'.format(filename)          
        fo = open(filename, "w")
        fprint=1
    
    tt4.TT4Init()
    tt4.delayMs(10)
    tt4SusScan()
    tt4.delayMs(10)
    [txNum,rxNum]=tt4GetSysInf()

    totalByte=txNum*rxNum*2+2      
    cmRawData=np.zeros((1,totalByte/2))
    cpRawData=np.zeros((1,(txNum+rxNum)*2))    

    while True:
        print 'Initial get:%s' %time.time()      
        index=0
        indexTx=0
        
        try:
            tt4.delayMs(1)
            cmRawData,cpRawData=tt4GetRawData(txNum,rxNum)
            while index<(totalByte/2):
                print '{0},'.format(cmRawData[0][index]),
                if fprint==1:
                    fo.write('{0},'.format(cmRawData[0][index]))                      
                index=index+1
                if index%rxNum==0:
                    print '{0},'.format(cpRawData[0][indexTx]),
                    print ''
                    if fprint==1:
                        fo.write('{0}\n'.format(cpRawData[0][indexTx]))
                        indexTx=indexTx+1
                        
            for i in range(txNum*2,txNum*2+rxNum-1):
                print '{0},'.format(cpRawData[0][i]),
                if fprint==1:
                    fo.write('{0},'.format(cpRawData[0][i]))
            print ''
            if fprint==1:
                fo.write('\n')
                fo.write('page start \n')
        except KeyboardInterrupt:
            print 'exit :%s' %time.time()
            tt4.ldoPowerOff()            
            GPIO.cleanup()
            if fprint==1:
                fo.close()
            break
コード例 #8
0
ファイル: tt4D.py プロジェクト: goldber/tt4ScriptOpen
def tt4GetMutual(txNum, rxNum):
    mrGetRepCmd = [
        0x04, 0x00, 0x0A, 0x00, 0x2F, 0x00, 0x2B, 0x00, 0x00, 0x7B, 0x00, 0x00
    ]
    mdGetRepCmd = [
        0x04, 0x00, 0x0A, 0x00, 0x2F, 0x00, 0x2B, 0x00, 0x00, 0x7B, 0x00, 0x02
    ]
    totalByte = (txNum * rxNum)
    mrGetData = np.zeros((1, totalByte))
    mdGetData = np.zeros((1, totalByte))

    try:
        print 'start to do get mutual raw'
        tt4PanelScan()
        tt4.delayMs(10)
        countByte = 0
        index = 0
        while countByte < totalByte:  # read mutual raw data;
            tt4.i2cw(TT4Addr, mrGetRepCmd)
            tt4.delayMs(1.5)
            if GPIO.input(bInt) == 0:
                result = tt4.i2cr(TT4Addr, 2)
                print result
                packetLength = (result[1] << 8) + result[0]
                result = tt4.i2cr(TT4Addr, packetLength)
                thisSensByte = (result[8] << 8) + result[7]
                countByte = countByte + thisSensByte
                print 'countByte byte:{0}'.format(countByte)
                print 'This sense total byte:{0}'.format(packetLength)
                mrGetRepCmd[7] = countByte & 0x00FF  # offset value
                mrGetRepCmd[8] = (countByte >> 8) & 0xFF  # offset value
                count = 0
                while count < (thisSensByte * 2):
                    mrGetData[0][index] = int((result[count + 11] << 8) +
                                              result[count + 10])  # fF/10
                    count = count + 2
                    index = index + 1

        print 'start to do get mutual diff'
        tt4PanelScan()
        tt4.delayMs(10)
        countByte = 0
        index = 0
        while countByte < totalByte:  # read mutual diff;
            tt4.i2cw(TT4Addr, mdGetRepCmd)
            tt4.delayMs(1.5)
            if GPIO.input(bInt) == 0:
                result = tt4.i2cr(TT4Addr, 2)
                print result
                packetLength = (result[1] << 8) + result[0]
                result = tt4.i2cr(TT4Addr, packetLength)
                thisSensByte = (result[8] << 8) + result[7]
                countByte = countByte + thisSensByte
                print 'countByte byte:{0}'.format(countByte)
                print 'This sense total byte:{0}'.format(packetLength)
                mdGetRepCmd[7] = countByte & 0x00FF  # offset value
                mdGetRepCmd[8] = (countByte >> 8) & 0xFF  # offset value
                count = 0
                while count < (thisSensByte * 2):
                    mdGetData[0][index] = int((result[count + 11] << 8) +
                                              result[count + 10])  # fF/10
                    if mdGetData[0][index] > 60000:
                        mdGetData[0][index] = mdGetData[0][index] - 65536
                    count = count + 2
                    index = index + 1

    except KeyboardInterrupt:
        GPIO.clearnup()

    return mrGetData, mdGetData
コード例 #9
0
ファイル: tt4D.py プロジェクト: goldber/tt4ScriptOpen
def tt4D():
    fprint = 0
    if len(sys.argv) < 2 or len(sys.argv) > 4:
        print 'no tx or rx number arguments or wrong arguments'
        GPIO.cleanup()
        sys.exit()

    elif len(sys.argv) == 3:
        print 'with save to file arguments'
        # txNum=int(sys.argv[2][2:])
        # rxNum=int(sys.argv[3][2:])
        filename = sys.argv[2][2:]
        print 'fileName:{0}'.format(filename)
        fo = open(filename, "w")
        fprint = 1

    tt4.TT4Init()
    tt4.delayMs(10)
    tt4ResumeScan()
    tt4.delayMs(10)
    tt4SusScan()
    tt4.delayMs(10)
    [txNum, rxNum] = tt4GetSysInf()
    totalByte = txNum * rxNum
    mrData = np.zeros((1, totalByte))
    mdData = np.zeros((1, totalByte))

    while True:
        print 'Initial get:%s' % time.time()

        try:
            if fprint == 1:
                fo.write('\n')
                fo.write('mutual raw page start \n')

            mrData, mdData = tt4GetMutual(txNum, rxNum)
            index = 0
            while index < (totalByte):
                print '{0},'.format(mrData[0][index]),
                if fprint == 1:
                    fo.write('{0},'.format(mrData[0][index]))
                index = index + 1
                if index % txNum == 0:
                    print ''
                    if fprint == 1:
                        fo.write('\n')
            print ''

            if fprint == 1:
                fo.write('\n')
                fo.write('mutual diff page start \n')
            index = 0
            while index < (totalByte):
                print '{0},'.format(mdData[0][index]),
                if fprint == 1:
                    fo.write('{0},'.format(mdData[0][index]))
                index = index + 1
                if index % txNum == 0:
                    print ''
                    if fprint == 1:
                        fo.write('\n')
            print ''

        except KeyboardInterrupt:
            print 'exit :%s' % time.time()
            GPIO.cleanup()
            if fprint == 1:
                fo.close()
            break
コード例 #10
0
ファイル: tt4P.py プロジェクト: hwtseng1976/tt4ScriptOpen
def tt4P(): 
    if len(sys.argv)<2 or len(sys.argv)>3:
        print 'wrong argument'
        sys.exit()
    elif len(sys.argv)==3 and sys.argv[2].startswith('--'):
        filename=sys.argv[2][2:] 
        print filename
        fo = open(filename, "w")
        fprint=1
    elif len(sys.argv)==2 and sys.argv[2].startswith('--'):
        fprint=0
    else:
        print 'wrong argument inputed'
        
        
    tt4.TT4Init()
    count=0
    tPre=time.time()
    try:
        while True:    
            tt4.delayMs(0.02)
            #print 'before Falling'
            if GPIO.input(bInt)==0:
                #print 'time:%s INT Low'%time.time()
                count=count+1
                tNow=time.time()
                diff=(tNow-tPre)*1000
                tPre=tNow
                data1=tt4.readFgData(TT4Addr,3,10)
                a,b=tt4.TT4resolve(data1)
                count1=0
                #print a[0][4],a[0][3]
                if a[0][4]==0:
                    if a[0][3]==1:
                        print 'LO:{0}, large Object Detected' .format(a[0][3])
                        if fprint==1:
                            fo.write('RID:{0},TDF:{1},LO:{2},NE:{3},largeObject`\n'\
                            .format(a[0][1],diff,a[0][3],a[0][6]))
                    else:
                         print 'RID:{0}, liftoff' .format(a[0][1])
                         if fprint==1:
                            fo.write('RID:{0},TDF:{1},LO:{2},NE:{3},liftoff\n'\
                            .format(a[0][1],diff,a[0][3],a[0][6]))                                           
                else:
                    while count1<a[0][4]:
                        print 'RID:{0},TDF:{1},LO:{2},NE:{3},TIP:{4},EID:{5},TID:{6},{7},{8},{9},{10},{11},{12},'\
                        .format(a[0][1],diff,a[0][3],a[0][6],b[count1][1],\
                        b[count1][2],b[count1][3],b[count1][4],b[count1][5],\
                        b[count1][6],b[count1][7],b[count1][8],b[count1][9]) 
                        if fprint==1:
                            if count1==0:
                                fo.write('RID:{0},TDF:{1},LO:{2},NE:{3},'\
                                .format(a[0][1],diff,a[0][3],a[0][6]))
                                fo.write('Type:{0},TIP:{1},EID:{2},TID:{3},{4},{5},{6},{7},{8},{9},'\
                                .format(b[count1][0],b[count1][1],b[count1][2],b[count1][3],\
                                b[count1][4],b[count1][5],b[count1][6],b[count1][7],\
                                b[count1][8],b[count1][9])) 
                            else:
                                fo.write('Type:{0},TIP:{1},EID:{2},TID:{3},{4},{5},{6},{7},{8},{9},'\
                                .format(b[count1][0],b[count1][1],b[count1][2],b[count1][3],\
                                b[count1][4],b[count1][5],b[count1][6],b[count1][7],\
                                b[count1][8],b[count1][9])) 
            
                        count1=count1+1                   
                    if fprint==1:                
                        fo.write('\n')
                    tt4.delayMs(0.5)
            else:
                tt4.delayMs(1)
    except KeyboardInterrupt:
        print 'exit check :%s' %time.time()
        tt4.ldoPowerOff()               
        GPIO.cleanup()
        if fprint==1:
            fo.close()
コード例 #11
0
ファイル: tt4PrintRep.py プロジェクト: goldber/tt4ScriptOpen
def tt4PrintRep():
    if len(sys.argv) < 3:
        print 'no print to file argument'
        fprint = 0
    elif sys.argv[2].startswith('--'):
        filename = sys.argv[2][2:]
        print filename
        fo = open(filename, "w")
        fprint = 1

    tt4.TT4Init()
    count = 0
    while True:
        try:
            tt4.delayMs(0.02)
            #print 'before Falling'
            if GPIO.input(bInt) == 0:
                print 'time:%s INT Low' % time.time()
                count = count + 1
                data1 = tt4.readFgData(TT4Addr, 3, 10)
                a, b = tt4.TT4resolve(data1)
                count1 = 0
                #print a[0][4],a[0][3]
                if a[0][4] == 0:
                    if a[0][3] == 1:
                        print 'LO:{0}, large Object Detected'.format(a[0][3])
                    else:
                        print 'RID:{0}, liftoff'.format(a[0][1])
                else:
                    while count1 < a[0][4]:
                        print 'RID:{0},T:{1},LO:{2},NE:{3},TIP:{4},EID:{5},TID:{6},{7},{8},{9},{10},{11},{12},'\
                        .format(a[0][1],a[0][2],a[0][3],a[0][6],b[count1][1],\
                        b[count1][2],b[count1][3],b[count1][4],b[count1][5],\
                        b[count1][6],b[count1][7],b[count1][8],b[count1][9])
                        if fprint == 1:
                            if count1 == 0:
                                fo.write('RID:{0},T:{1},LO:{2},NE:{3},'\
                                .format(a[0][1],a[0][2],a[0][3],a[0][6]))
                                fo.write('Type:{0},TIP:{1},EID:{2},TID:{3},{4},{5},{6},{7},{8},{9},'\
                                .format(b[count1][0],b[count1][1],b[count1][2],b[count1][3],\
                                b[count1][4],b[count1][5],b[count1][6],b[count1][7],\
                                b[count1][8],b[count1][9]))
                            else:
                                fo.write('Type:{0},TIP:{1},EID:{2},TID:{3},{4},{5},{6},{7},{8},{9},'\
                                .format(b[count1][0],b[count1][1],b[count1][2],b[count1][3],\
                                b[count1][4],b[count1][5],b[count1][6],b[count1][7],\
                                b[count1][8],b[count1][9]))

                        count1 = count1 + 1

                if fprint == 1:
                    fo.write('\n')
                tt4.delayMs(0.5)
            else:
                tt4.delayMs(1)
        except KeyboardInterrupt:
            print 'exit check :%s' % time.time()
            GPIO.cleanup()
            if fprint == 1:
                fo.close()
            break