def task():
    while True:
        isCardP = [-1, -1]
        run = 1
        count = 0

        InitShowText("Insert Card Please")
        ser_Init()

        while run:
            time.sleep(1)
            ts = time.time()

            for i in range(0, 2):
                x = isCardPresent(i)
                # if -1, then it failed to read (maybe reset).
                if (x < 0):
                    count += 1
                    #if 5 failed reads in a row, the system may have reset.
                    if count > 5:
                        print("Wait 60 seconds, maybe rebooted")
                        time.sleep(60)
                        run = 0
                else:
                    #Get Transition Change
                    count = 0
                    if isCardP[i] != x:
                        isCardP[i] = x
                        st = datetime.datetime.fromtimestamp(ts).strftime(
                            '%Y-%m-%d %H:%M:%S')
                        if isCardP[i] == True:
                            print "%s Card %d Present" % (st, i)
                            log.info("%s Card %d Present" % (st, i))
                            emv_data = getEnvData(i)
                            print emv_data
                            log.info(emv_data)
                        else:
                            print "%s Card %d Removed" % (st, i)
                            log.info("%s Card %d Removed" % (st, i))

                root.after(2000, task)
                root.mainloop()
def task():	
	while True:
		isCardP=[-1, -1]
		run = 1
		count = 0
		
		InitShowText("Insert Card Please")
		ser_Init()
		

		while run:
			time.sleep(1)
			ts = time.time()
	
			for i in range(0,2):
				x = isCardPresent(i)
				# if -1, then it failed to read (maybe reset).
				if(x < 0):
					count+=1
					#if 5 failed reads in a row, the system may have reset.
					if count > 5:
						print ("Wait 60 seconds, maybe rebooted")
						time.sleep(60)
						run = 0
				else:	
					#Get Transition Change
					count = 0
					if isCardP[i] != x:
						isCardP[i] = x
						st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
						if isCardP[i] == True:
							print "%s Card %d Present" % (st, i)
							log.info("%s Card %d Present" % (st, i))
							emv_data = getEnvData(i)
							print emv_data
							log.info(emv_data)
						else:
							print "%s Card %d Removed" % (st, i)
							log.info("%s Card %d Removed" % (st, i))
		
				root.after(2000, task)
				root.mainloop()
Example #3
0
        while run:
            time.sleep(1)
            ts = time.time()

            for i in range(0, 2):
                x = isCardPresent(i)
                # if -1, then it failed to read (maybe reset).
                if (x < 0):
                    count += 1
                    #if 5 failed reads in a row, the system may have reset.
                    if count > 5:
                        print("Wait 60 seconds, maybe rebooted")
                        time.sleep(60)
                        run = 0
                else:
                    #Get Transition Change
                    count = 0
                    if isCardP[i] != x:
                        isCardP[i] = x
                        st = datetime.datetime.fromtimestamp(ts).strftime(
                            '%Y-%m-%d %H:%M:%S')
                        if isCardP[i] == True:
                            print "%s Card %d Present" % (st, i)
                            log.info("%s Card %d Present" % (st, i))
                            emv_data = getEnvData(i)
                            print emv_data
                            log.info(emv_data)
                        else:
                            print "%s Card %d Removed" % (st, i)
                            log.info("%s Card %d Removed" % (st, i))
Example #4
0
						get_log_cm().error("\t\t\tReading stopped, Reboot restarting script.\n\n\n")
						serial_close()
						
						run = 0
						break
				elif x == 0:
					get_log_cm().error("\t\t\tcard %d is Missing" % (i))
				elif x == 1:
					#Get ATR
					count = 0
					if x > 0:
						isCardP[i] = x
						ts = time.time()
						st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
						if isCardP[i] == True:
							emv_data = getEnvData(i)
							get_log_cm().debug("Card %d ATR %s" % (i, emv_data))
							if "No EMV Support" not in str(emv_data):
								characters = emv_data.replace(' ', '')
								get_log_cm().debug("Card %d ATR string %s" % (i, characters.decode('hex')))
								# check each card ATR
								c_present+=1
								#when both cards pass
								if c_present == 2:
									smart_card_count += 1
						else:
							log.warn( "%s Card %d Removed" % (st, i))
				else:
					get_log_cm().error("x is %d UNKNOWN") % (x)
			get_log_cm().info( "SmartCard Count = \t\t%d of %d", smart_card_count, total_count)
			#SMARTCARD Test end:#######################################################