Beispiel #1
0
def read_stest_count():
    if (get_ser().isOpen() == False):
        get_log_cm().error("serial not available")
        return -1

    # send UART request
    input = '/opt/maxim-ic/basic/examples/ucl_example'
    get_ser().write(input.encode('ascii') + '\n')
    time.sleep(1)

    out = get_ser().readlines()
    #generator: creates "matches list" only if parsed TMP info present.
    #print "Out is %s" % out
    valid = [v for v in out if "DES" in v]
    passed = [x for x in out if "PASSED" in x]
    fails = [z for z in out if "FAILED" in z]
    #if not matches:
    if not valid:
        get_log_cm().error("\t\t\t(read_stest_count)Possible reset")
        return -1
    elif not fails:
        #Passes
        count = 0
    else:
        count = 0
        #Count each Failure detected
        for y in fails:
            count += 1
    return count
Beispiel #2
0
def read_secdiag_val_old():
    if (get_ser().isOpen() == False):
        get_log_cm().info("\t\t\t(read_secdiag_val)serial not available")
        return -1

    print "read_secdiag_val Here"
    input = '/opt/maxim-ic/hcr4/apps/secmon /dev/secmon0 5 ffe0200c'
    get_ser().write(input.encode('ascii') + '\n')
    time.sleep(1)
    out = get_ser().readlines()

    print out
    count = -1
    if not out:
        get_log_cm().error("\t\t\t(read_secdiag_val)Possible reset")
    elif len(out) < 15:
        get_log_cm().error("\t\t\t(read_secdiag_val)Possible reset, too short")
    elif 'Error reading' in out:
        get_log_cm().error("\t\t\t(read_secdiag_val)secdiag read error")
    elif 'fee0200c =' in out[15]:
        # Brute force index values
        print out[15][11:]
        count = int(out[15][11:], 16)
    else:
        get_log_cm().error("Tamper secdiag return not found.")
    return count
Beispiel #3
0
def read_stest_count():
	if (get_ser().isOpen()==False):
		get_log_cm().error("serial not available")
		return -1

	# send UART request
	input = '/opt/maxim-ic/basic/examples/ucl_example'
	get_ser().write(input.encode('ascii')+'\n')
	time.sleep(1)

	out = get_ser().readlines()
	#generator: creates "matches list" only if parsed TMP info present.
	#print "Out is %s" % out
	valid = [v for v in out if "DES" in v]
	passed = [x for x in out if "PASSED" in x]
	fails = [z for z in out if "FAILED" in z]
	#if not matches:
	if not valid:
		get_log_cm().error("\t\t\t(read_stest_count)Possible reset")
		return -1
	elif not fails:	
		#Passes
		count = 0
	else:
		count = 0
		#Count each Failure detected
		for y in fails:
			count += 1
	return count
Beispiel #4
0
def read_rtc_count():
    if (get_ser().isOpen() == False):
        get_log_cm().error("serial not available")
        return -1

    # send UART request
    input = '/opt/maxim-ic/hcr4/apps/secmon /dev/secmon0 3'
    get_ser().write(input.encode('ascii') + '\n')
    time.sleep(1)

    out = (get_ser().readlines())
    #generator: creates "matches list" only if parsed TMP info present.
    lRtc = [x for x in out if "RTC:" in x]
    #s_index = 5 #smatch.find('RTC:\\t\\t')+8
    #print("lRtc is %s\n" % lRtc)
    #print("lRtc[s_index:] is %s\n" % lRtc[0][5:])
    count = -1

    try:
        if not lRtc:
            get_log_cm().error("\t\t\t(read_rtc_count)Possible reset")
        else:
            count = int(lRtc[0][5:])
    except ValueError:
        get_log_cm().error("\t\t\t(read_rtc_count)Possible reset error")
    return count
Beispiel #5
0
def find_ip_addr (node):
	input = 'ifconfig'
	get_ser().write(input.encode('ascii')+'\n')
	time.sleep(2)
	out = str(get_ser().readlines())
	if node in out:
		s_index = out.find('inet addr:')+10
		e_index = out.find(r"Bcast", s_index)
		#print "e-index %d" % e_index
		return out[s_index:e_index]
	else:
		return -1
def latch_config(num):
    ser = get_ser()
    input = './solenoid /dev/sol0 '
    index = input.find('sol0 ')
    input2 = input[:index + 5] + str(num)
    ser.write(input2.encode('ascii') + '\n')
    out = ser.readlines()
    return True
def latch_config (num):
	ser = get_ser()
	input = './solenoid /dev/sol0 '
	index = input.find('sol0 ')
	input2 = input[:index+5] + str(num)
	ser.write(input2.encode('ascii')+'\n')
	out = ser.readlines()
	return True
Beispiel #8
0
def find_dev_secmon_name():
    if (get_ser().isOpen() == False):
        get_log_cm().info("\t\t\tserial not available")
        return -1
    input = 'ls /dev/secm*'
    get_ser().write(input.encode('ascii') + '\n')
    time.sleep(2)
    out = get_ser().readlines()

    if not out:
        get_log_cm().error("\t\t\t(find_dev_secmon_name)Possible Reset")
    elif "ls" is out:
        get_log_cm().error("\t\t\t/dev/secmon not found")
    else:
        print out
        s_index = out[1].find('dev') + 4
        e_index = out[1].find(r"\x1b", s_index)
        print out[1][s_index:e_index]
Beispiel #9
0
def find_cdc_rsp_data():
    input = '/opt/maxim-ic/hcr4/apps/cdc_host_test'
    get_ser().write(input.encode('ascii') + '\n')
    time.sleep(2)
    out = str(get_ser().readlines())
    if out:
        #print out
        s_index = out.find("errno = 0")
        if s_index != -1:
            s_index = s_index + 16
        else:
            return -1
        e_index = out.find(r"#", s_index) - 8
        #print "s-index %d" % s_index
        #print "e-index %d" % e_index
        #print out[s_index:e_index]
        #print e_index - s_index
        return out[s_index:e_index]
    else:
        return -1
Beispiel #10
0
def read_secdiag_val_obsolete():
    if (get_ser().isOpen() == False):
        get_log_cm().info("\t\t\t(read_secdiag_val)serial not available")
        return -1

    input = '/opt/maxim-ic/hcr4/apps/secmon /dev/secmon0 5 ffe0200c'
    get_ser().write(input.encode('ascii') + '\n')
    time.sleep(1)
    out = get_ser().readlines()

    #Filter all out for ifstatement
    matches = [x for x in out if "fee0200c" in x]

    if not matches:  #out:
        get_log_cm().error("\t\t\t(read_secdiag_val)Possible reset")
        val = -1
    else:
        conv = matches[0][12:]
        val = int(conv, 16)
    return val
Beispiel #11
0
def set_tamper_trigger(num):
    input = 'secmon /dev/secmon0 4 ' + str(num)
    if (get_ser().isOpen() == False):
        get_log_cm().info("\t\t\tserial not available")
        return
    #get_ser().write(input.encode('ascii')+'\n')
    #time.sleep(1)
    #out = get_ser().readlines()
    out = Hcr4SendCMD(input)
    if 'Error Getting SEC_GET_STATUS' in out:
        get_log_cm().info("\t\t\tsecmon read error")
def find_cdc_rsp_data ():
	input = '/opt/maxim-ic/hcr4/apps/cdc_host_test'
	get_ser().write(input.encode('ascii')+'\n')
	time.sleep(2)
	out = str(get_ser().readlines())
	if out:
		#print out
		s_index = out.find("errno = 0")
		if s_index != -1:
			s_index = s_index + 16
		else:
			return -1
		e_index = out.find(r"#", s_index) - 8
		#print "s-index %d" % s_index
		#print "e-index %d" % e_index
		#print out[s_index:e_index]
		#print e_index - s_index
		return out[s_index:e_index]
	else:
		return -1
Beispiel #13
0
def read_tamper_count():
    if (get_ser().isOpen() == False):
        get_log_cm().error("serial not available")
        return -1

    # send UART request
    input = '/opt/maxim-ic/hcr4/apps/secmon /dev/secmon0 3'
    get_ser().write(input.encode('ascii') + '\n')
    time.sleep(1)

    out = get_ser().readlines()
    #generator: creates "matches list" only if parsed TMP info present.
    matches = [x for x in out if "TMP" in x]
    if not matches:
        get_log_cm().error("\t\t\t(read_tamper_count)Possible reset")
        return -1
    else:
        count = 0
        for y in matches:
            count += int(y[7:])
    return count
def setCardFacilitator ():
	#This statys running until completes
	ser = get_ser()
	input = '/opt/maxim-ic/basic/examples/card_facilitator'
	ser.write(input.encode('ascii')+'\n')
	#Wait 2 seconds for Sam card
	get_log_cm().info("Pull out MSR read within 10 seconds")
	out = str(ser.readlines())
	get_log_cm().info(out) 
	time.sleep(10)
	#Control-C
	input = '\x03'
	ser.write(input.encode('ascii')) #+'\n')
	get_log_cm().info("DONE")
Beispiel #15
0
def setCardFacilitator():
    #This statys running until completes
    ser = get_ser()
    input = '/opt/maxim-ic/basic/examples/card_facilitator'
    ser.write(input.encode('ascii') + '\n')
    #Wait 2 seconds for Sam card
    get_log_cm().info("Pull out MSR read within 10 seconds")
    out = str(ser.readlines())
    get_log_cm().info(out)
    time.sleep(10)
    #Control-C
    input = '\x03'
    ser.write(input.encode('ascii'))  #+'\n')
    get_log_cm().info("DONE")
def getEnvData (num):
	#load num into sc* cmd line
	ser = get_ser()
	input = '/opt/maxim-ic/hcr4/apps/sci /dev/sc 10'
	index = input.find(' 10')
	input2 = input[:index] + str(num) + input[index:]
	ser.write(input2.encode('ascii')+'\n')
	#Wait 2 seconds for Sam card
	if num == 0: time.sleep(2)
	#Parse Output
	out = str(ser.readlines())
	if 'Card mute' not in out:
		s_index = out.find('ATR[')+10
		e_index = out.find(r"\r\n", s_index)
		return out[s_index:e_index]
	elif 'Card mute' in out:
		return "No EMV Support"
Beispiel #17
0
def getEnvData(num):
    #load num into sc* cmd line
    ser = get_ser()
    input = '/opt/maxim-ic/hcr4/apps/sci /dev/sc 10'
    index = input.find(' 10')
    input2 = input[:index] + str(num) + input[index:]
    ser.write(input2.encode('ascii') + '\n')
    #Wait 2 seconds for Sam card
    if num == 0: time.sleep(2)
    #Parse Output
    out = str(ser.readlines())
    if 'Card mute' not in out:
        s_index = out.find('ATR[') + 10
        e_index = out.find(r"\r\n", s_index)
        return out[s_index:e_index]
    elif 'Card mute' in out:
        return "No EMV Support"
def isCardPresent (num):
	# check list for NOK or OK
	ser = get_ser()
	input = '/opt/maxim-ic/hcr4/apps/sci /dev/sc 3'
	index = input.find(' 3')
	input2 = input[:index] + str(num) + input[index:]

	ser.write(input2.encode('ascii')+'\n')
	out = ser.readlines()
	if "NOK" in str(out):
		get_log_cm().error("Card Missing")
		return False
	elif " OK" in str(out):
		get_log_cm().debug("Card Present")
		return True
	else:
		get_log_cm().error("Failed to read")
		return -1
Beispiel #19
0
def isCardPresent(num):
    # check list for NOK or OK
    ser = get_ser()
    input = '/opt/maxim-ic/hcr4/apps/sci /dev/sc 3'
    index = input.find(' 3')
    input2 = input[:index] + str(num) + input[index:]

    ser.write(input2.encode('ascii') + '\n')
    out = ser.readlines()
    if "NOK" in str(out):
        get_log_cm().error("Card Missing")
        return False
    elif " OK" in str(out):
        get_log_cm().debug("Card Present")
        return True
    else:
        get_log_cm().error("Failed to read")
        return -1
Beispiel #20
0
		
		log = ser_Init(my_path, my_name)
		#log = set_log_info(my_path, my_name)
		card_bay_init()
		

		while run:
			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 ("Reading stopped, Reboot suspected")
						get_ser().close()
						run = 0
						break
				else:	
					#Get Transition Change
					count = 0
					if isCardP[i] != x:
						isCardP[i] = x
						ts = time.time()
						st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
						if isCardP[i] == True:
							if i == 1:
								card_bay_locked() #plunger is pulled
								print "%s Card %d Present & Locked" % (st, i)
								get_log_cm().info("%s Card %d Present & Locked" % (st, i))
							else:
Beispiel #21
0
        isCardP = [-1, -1]
        run = 1
        count = 0
        ser_Init()
        #card_bay_init()

        while run:
            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("Reading stopped, Reboot suspected")
                        get_ser().close()
                        run = 0
                        break
                else:
                    #Get Transition Change
                    count = 0
                    if isCardP[i] != x:
                        isCardP[i] = x
                        ts = time.time()
                        st = datetime.datetime.fromtimestamp(ts).strftime(
                            '%Y-%m-%d %H:%M:%S')
                        if isCardP[i] == True:
                            if i == 1:
                                card_bay_locked()  #plunger is pulled
                                print "%s Card %d Present & Locked" % (st, i)
                                get_log_cm().info(