5566影音先锋,无码国内精品人妻少妇蜜桃视频,东北老妇爽大叫受不了,精品无线一线二线三线

DONSEE東信智能 - 身份證社??ㄗx卡智能終端應用服務商

eastcoms@qq.com
400-6722-705
首頁 > 服務支持專區 > 產品支持 > 常見問題

Python調用東信QR-M20二維碼掃碼模組示例

來源:www.tengrise.com   標簽:Python 掃碼 二維碼 模組   發布時間: 2024-9-18 8:59:20

Python語言開發采用東信QR-M20二維碼模塊,USB接口進行開發,調用了libdonseeQR.so 這個掃碼的接口庫。


import ctypes

from ctypes import *

import sys


# Define callback function types

tx_scanner_decode_data_cb_fun = CFUNCTYPE(c_int, c_ubyte, POINTER(c_ubyte), c_int)

tx_scanner_comm_state_cb_fun = CFUNCTYPE(None, c_ubyte)


# Load the DLL

tx_windows_hidpos = ctypes.CDLL("./tx_windows_hidpos.dll")


# Define function prototypes

tx_scanner_init = tx_windows_hidpos.tx_scanner_init

tx_scanner_init.restype = c_int


tx_scanner_get_version = tx_windows_hidpos.tx_scanner_get_version

tx_scanner_get_version.argtypes = [POINTER(c_ubyte), c_ubyte]

tx_scanner_get_version.restype = c_int


tx_scanner_decode_data_fun_register = tx_windows_hidpos.tx_scanner_decode_data_fun_register

tx_scanner_decode_data_fun_register.argtypes = [tx_scanner_decode_data_cb_fun]

tx_scanner_decode_data_fun_register.restype = c_int


tx_scanner_comm_state_fun_register = tx_windows_hidpos.tx_scanner_comm_state_fun_register

tx_scanner_comm_state_fun_register.argtypes = [tx_scanner_comm_state_cb_fun]

tx_scanner_comm_state_fun_register.restype = c_int


s_uiDecodeCnt = 0


@tx_scanner_decode_data_cb_fun

def tx_scanner_sdk_decode_data_cb(ucCodeType, pBuf, uiBufLen):

    global s_uiDecodeCnt

    return 0


@tx_scanner_comm_state_cb_fun

def tx_scanner_sdk_comm_state_cb_fun(ucState):

    print(f"scanner usb hidpos state:{ucState}")


def tx_scanner_sdk_show_menu():

    print("***************************東信QR-M20二維模組Test***************************")

    print("q:quit")

    print("******************************************************")


def main():

    ucVer = (c_ubyte * 128)()

    iRet = tx_scanner_get_version(ucVer, len(ucVer))

    if iRet > 0:

        strTemp = bytes(ucVer[:iRet]).decode('utf-8')

    print(f"DONSEE QR-M20 Linux python usb hidpos demo ver:{strTemp}")


    # Register decode data callback function

    tx_scanner_decode_data_fun_register(tx_scanner_sdk_decode_data_cb)


    # Register device connection state callback function

    tx_scanner_comm_state_fun_register(tx_scanner_sdk_comm_state_cb_fun)


    # Initialize

    iRet = tx_scanner_init()

    print(f"tx_scanner_init:{iRet}")

    print("q:quit")

    print("***********************東信QR-M20二維模組Test******************************")


    while True:

        cInput = input().lower()

        if cInput == 'q':

            print("quit")

            return


if __name__ == "__main__":

    main()


 

 
QQ在線咨詢
主站蜘蛛池模板: 江川县| 芜湖市| 洛南县| 蓬安县| 吴旗县| 道孚县| 临猗县| 瓦房店市| 广元市| 喀什市| 沈阳市| 松原市| 怀柔区| 梅州市| 光山县| 曲周县| 成都市| 合水县| 长治县| 九台市| 浮山县| 巴南区| 龙里县| 中牟县| 彰化县| 海伦市| 达孜县| 栖霞市| 杨浦区| 朝阳县| 五原县| 永城市| 泌阳县| 铜陵市| 吐鲁番市| 枞阳县| 石泉县| 永济市| 卢氏县| 绍兴县| 冷水江市|