DataLogic 工业串口扫码器Python读取说明
生活随笔
收集整理的這篇文章主要介紹了
DataLogic 工业串口扫码器Python读取说明
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1. DataLogic 設置,使用DLCode 軟件,連接掃碼器設置,
使用T 命令觸發掃碼,S 命令停止掃碼。
設置輸出數據格式 起始符@ ,結束符 #
2. 使用usb轉串口線連接設備到PC 或者 工控Linux 系統機器
python 使用代碼:
import serialclient = serial.Serial("/dev/ttyUSB2", 115200, timeout=0.5) #使用USB連接串行口import time start_cmd = "T" stop_cmd = "S"# 嘗試先讀空緩沖區 n = client.inWaiting() if n:client.read(n)# 開啟掃碼功能 client.write(bytes(start_cmd, encoding='utf-8'))result = bytes() while True:byte = client.read()# print("byte = ", byte)if byte == b'#':breakresult += byte result = result.decode() result = result.replace("@", "") # 目前不確定這個內容怎么回事,有可能是掃碼器問題 result = result.replace("\\000026", "") print(result)總結
以上是生活随笔為你收集整理的DataLogic 工业串口扫码器Python读取说明的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 浏览器BOM模型
- 下一篇: windows系统下oracle数据库r