我有一個非常基本的鸚鵡腳本用Python編寫,只需提示用戶輸入並在無限循環內打印回來。 Raspberry Pi有一個USB條形碼掃描器,用於輸入。Python上Raspberry Pi用戶輸入內部無限循環錯過輸入時,許多命中
while True:
barcode = raw_input("Scan barcode: ")
print "Barcode scanned: " + barcode
當您掃描它可以可靠地工作一個「正常」的速度和命令的輸出看起來是這樣的:
Scan barcode: 9780465031467
Barcode scanned: 9780465031467
Scan barcode: 9780007505142
Barcode scanned: 9780007505142
但是當你真的有緊密相繼許多掃描捶它有可能讓它錯過輸入和命令的輸出看起來是這樣的:
Scan barcode: 9780141049113
Barcode scanned: 9780141049113
Scan barcode: 9780465031467
Barcode scanned: 9780465031467
Scan barcode: 9780007505142
9780571273188
Barcode scanned: 9780571273188
通知9780007505142
怎麼輸入,但從來沒有印刷回來。這讓混亂中的丟失了。
看到我的測試的視頻演示:https://youtu.be/kdsfdKFhC1M
我的問題:這是使用像丕低功率設備的必然性?用條碼掃描器的用戶是否能夠保證硬件能夠跟上運行的能力?
Java你試過另一種語言嗎?看看我在那裏做了什麼? – Jay
@Jay No.你認爲如果我用Java運行測試是不可能超出它的嗎? –
我會說爲了測試目的而嘗試它。也許它是一個緩慢的圖書館,也許是一個緩慢的語言,也許是CPU不能保持聯繫。我會說,如果你使用c/C++/java,你肯定會有更好的性能。 c/C++的問題在於它很難設置,而且您可能找不到要查找的庫。 Java更簡單,設置更簡單,性能得到保證。 – Jay