Exemplo n.º 1
0
def get_rfid():
    global correlation_id, truck_plate, daily_count, monthly_count
    if True:
        if True:
            card_key = 'bfb6d65577759577f900'
            print('card key : {}'.format(card_key))
            # 카드키값 전송
            with open('./logfile/cardlog.txt', 'a') as f:
                msg = time.strftime('%c', time.localtime(time.time()))
                msg = msg + ',' + card_key + '\n'
                f.write(msg)
            try:
                value = pc.post_cardkey(user_id, session_key, site_uuid,
                                        card_key)
                if value[0] == 'Y':  # 성공시
                    correlation_id = value[1]
                    truck_plate = value[2]
                    daily_count = value[3]
                    monthly_count = value[4]
                    return 'success'
                else:
                    return 'notcard'
            except:
                return 'network'
        else:
            return 'time'
Exemplo n.º 2
0
def get_rfid(ser):
    global coco
    ser.flushInput()
    start = time.time()
    str_ = ser.read(10)

    ser.flushInput()
    end = int(time.time() - start)
    if end > 10:
        print('10 seconds')
        return 'time', 'fail', 'fail', 'fail', 'fail'
    else:  #15초 내에 카드 태그 된경우

        #str_=str_[1:9]
        #print('raw data',end=' ')
        #print(str_)
        message = ''
        for i in range(10):
            a = hex(str_[i])
            c = str(a)[2:]
            if len(c) == 1:
                c = '0' + c
            message = message + c
            '''
        decimal_representation=int(message,2)
        card_key=hex(decimal_representation)
        card_key=card_key[2:]'''
        card_key = message
        print('card key : {}'.format(card_key))
        #카드키값 전송
        print(coco)
        value = pc.post_cardkey(user_id, session_key, str(coco), str(card_key))
        coco = coco + 1
        if value[0] == '0x0000':  #성공시
            print('success communicating to server:card')

            driver_name = value[1]
            truck_plate = value[2]
            driver_message = value[3]
            correlation_id = value[4]
            return_card_key = value[5]
            print(return_card_key)
            return driver_name, truck_plate, driver_message, correlation_id, return_card_key
            '''
            camera.capture(filename)
            val=pc.post_file(user_id,session_key,correlation_id,filename)
            if val=='0x0000':
                print('success communicating to server:photo')
                return driver_name,truck_plate,driver_message,correlation_id
            else:
                print('photo sending fail')
                return 'fail','fail','fail','fail'
                '''
        else:
            print('card api fail')
            return 'fail', 'fail', 'fail', 'fail', 'fail'
Exemplo n.º 3
0
def get_rfid(ser):

    ser.flushInput()
    start = time.time()
    str_ = ser.read(10)

    ser.flushInput()
    end = int(time.time() - start)
    if end > 10:
        print('10 seconds')
        return 'time', 'fail', 'fail', 'fail'
    else:  #15초 내에 카드 태그 된경우

        str_ = str_[1:9]
        print('raw data', end=' ')
        #print(str_)
        message = ''
        for i in range(8):
            a = format(str_[i], '#010b')
            a = a[2:]
            print(a)
            message = message + a
        decimal_representation = int(message, 2)
        card_key = hex(decimal_representation)
        card_key = card_key[2:]
        print('card key : {}'.format(card_key))
        #카드키값 전송
        value = pc.post_cardkey(user_id, session_key, site_uuid, str(card_key))
        if value[0] == '0x0000':  #성공시
            print('success communicating to server:card')

            driver_name = value[1]
            truck_plate = value[2]
            driver_message = value[3]
            correlation_id = value[4]
            return driver_name, truck_plate, driver_message, correlation_id
            '''
            camera.capture(filename)
            val=pc.post_file(user_id,session_key,correlation_id,filename)
            if val=='0x0000':
                print('success communicating to server:photo')
                return driver_name,truck_plate,driver_message,correlation_id
            else:
                print('photo sending fail')
                return 'fail','fail','fail','fail'
                '''
        else:
            print('card api fail')
            return 'fail', 'fail', 'fail', 'fail'
Exemplo n.º 4
0
def get_rfid(ser):
    global correlation_id, truck_plate, daily_count, monthly_count
    ser.flushInput()
    start = time.time()
    str_ = ser.read(10)
    ser.flushInput()
    end = int(time.time() - start)
    if end > 10:
        print('10 seconds')
        return 'time'
    else:  #15초 내에 카드 태그 된경우

        #str_=str_[1:9]
        message = ''
        for i in range(10):
            #a=format(str_[i],'#010b')
            #a=a[2:]
            a = hex(str_[i])
            c = str(a)[2:]
            if len(c) == 1:
                c = '0' + c
            message = message + c
        '''
        decimal_representation=int(message,2)
        card_key=hex(decimal_representation)
        card_key=card_key[2:]
        '''
        card_key = message
        print('card key : {}'.format(card_key))
        #카드키값 전송
        value = pc.post_cardkey(user_id, session_key, site_uuid, card_key)
        if value[0] == 'Y':  #성공시
            print('success communicating to server:card')
            correlation_id = value[1]
            truck_plate = value[2]
            daily_count = value[3]
            monthly_count = value[4]
            camera.capture(filename)
            val = pc.post_file(user_id, session_key, correlation_id, filename)
            if val == '0x0000':
                print('success communicating to server:photo')
                return 'success'
            else:
                print('photo sending fail')
                return 'photo'
        else:
            print('card api fail')
            return 'card'
Exemplo n.º 5
0
def get_rfid(ser):
    str_ = ser.read(10)
    str_ = str_[1:9]
    #print(str_)
    #print(type(str_))
    message = ''
    for i in range(8):
        a = format(str_[i], '#010b')
        a = a[2:]
        '''print(a)
        print(type(a))
        '''
        message = message + a
    decimal_representation = int(message, 2)
    card_key = hex(decimal_representation)
    card_key = card_key[2:]
    print(card_key)
    #카드키값 전송
    value = pc.post_cardkey(user_id, session_key, site_uuid, card_key)
    '''
    print(value[0]),    print(value[1]),    print(value[2]),    print(value[3])
    '''
    if value[0] == '0x0000':  #성공시
        #print('success communicating to server:card')
        driver_name = value[1]
        truck_plate = value[2]
        driver_message = value[3]
        correlation_id = value[4]
        ret, frame = cap.read()
        if ret:
            cv2.imwrite(filename, frame)
        cap.release()
        val = pc.post_file(user_id, session_key, correlation_id, filename)
        if val == '0x0000':
            #print('success communicating to server:photo')
            return driver_name, truck_plate, driver_message, correlation_id
        else:
            print('photo sending fail')
            return 'fail', 'fail', 'fail', 'fail'
    else:
        print('card api fail')
        return 'fail', 'fail', 'fail', 'fail'
Exemplo n.º 6
0
def get_rfid(ser):
    global correlation_id, truck_plate, daily_count, monthly_count
    ser.flushInput()
    # start=time.time()
    str_ = ser.read(10)
    ser.flushInput()
    # end=int(time.time()-start)
    if True:
        message = ''
        if (len(str_) > 7):
            for i in range(10):
                a = hex(str_[i])
                c = str(a)[2:]
                if len(c) == 1:
                    c = '0' + c
                message = message + c
            card_key = message
            print('card key : {}'.format(card_key))
            # 카드키값 전송
            with open('./logfile/cardlog.txt', 'a') as f:
                msg = time.strftime('%c', time.localtime(time.time()))
                msg = msg + ',' + card_key + '\n'
                f.write(msg)
            try:
                value = pc.post_cardkey(user_id, session_key, site_uuid,
                                        card_key)
                if value[0] == 'Y':  # 성공시
                    correlation_id = value[1]
                    truck_plate = value[2]
                    daily_count = value[3]
                    monthly_count = value[4]
                    return 'success'
                else:
                    return 'notcard'
            except:
                return 'network'
        else:
            return 'time'