--客户端死循环读取串口数据  add by: liang  2019-11-15
function run_read_com()
    local sv = CTNString();
    local sDlgUI = CTNString();
    local sDlgName = CTNString();
    while true do
    while true do
        if ui:allThreadStop() then return end
        if ui:getActiveDialog(sDlgUI, sDlgName) == false then--如果当前窗口不是活跃窗口,不处理,该判断根据实际业务需求取舍
            break;
        end

        sv:set('');
        if ui:readCom('read_qr_code', sv, 1000) <= 0 then--第一个参数为提前配置好的串口业务功能码
            cutil:sleep(1000);
        end
        if string.len(sv:get()) <= 0 then
            break;
        end
        sTmp = sv:get();
        sTmp = string.gsub(sTmp, '\r', '');
        sTmp = string.gsub(sTmp, '\n', '');
        print('read barcode:'..sTmp)
    end
    cutil:sleep(500);
    end
end

ui:run('run_read_com()', '');
Copyright © TouchNet 2015 all right reserved,powered by Gitbook最后修订时间: 2022-06-21 09:21:04

results matching ""

    No results matching ""