Yapay zekâ tarafından English dilinden çevrildi ·
DTR, eski modem kontrol hatlarından biridir. Uno’da bu hat 100 nF’lık bir kapasitörden geçerek reset pinine bağlanır; böylece IDE, yüklemeden önce kartı resetleyebilir. Portu açan her program DTR’yi değiştirir ve kart resetlenir. Geçen yıl işte bir satır sayacında aynı sorunla uğraştım.Yazılım tarafında iki şeyi birlikte yapın:
stty -F /dev/ttyUSB0 -hupcl # don't drop DTR when the port closes
ser = serial.Serial()
ser.port = '/dev/ttyUSB0'
ser.baudrate = 9600
ser.timeout = 2
ser.dtr = False
ser.open()
Şunu da bilin: Linux’ta sürücü, önyüklemeden sonraki ilk açılışta DTR’yi bir an için yine yükseltebilir; yani bu yöntem resetleri azaltır ama her zaman tamamen önlemez.Kesin çözüm donanımsal: Uno’da RESET ile GND arasına, eksi GND’ye gelecek şekilde 10 µF’lık bir kapasitör koyun. Bu, reset darbesini bastırır. Ancak yeni firmware yüklerken bunu çıkarmanız (veya doğru anda resete elle basmanız) gerekir.Toplam değerdeki kayıplar için: sayımı her birkaç dakikada bir EEPROM’a da kaydedin ya da Uno’nun önyüklemeden değil, firmware yüklendiği andan itibaren çalışan toplamı göndermesini sağlayın. Böylece bir reset, toplamın tamamını değil, yalnızca birkaç darbeyi kaybettirir.
DTR is one of the old modem control lines. On the Uno it goes through a 100 nF capacitor to the reset pin, so the IDE can reset the board before an upload. Any program that opens the port toggles DTR, so the board resets. I fought this on a line counter at work last year.
Software side, two things together:
stty -F /dev/ttyUSB0 -hupcl # don't drop DTR when the port closes
ser = serial.Serial()
ser.port = '/dev/ttyUSB0'
ser.baudrate = 9600
ser.timeout = 2
ser.dtr = False
ser.open()
Be warned that on Linux the driver may still raise DTR for a moment on the very first open after boot, so this reduces resets, it doesn’t always kill them.
The sure fix is hardware: a 10 µF capacitor between RESET and GND on the Uno, minus to GND. That swamps the reset pulse. You then have to pull it out (or press reset by hand at the right moment) when you upload new firmware.
And for the drops in your total: also keep the count in EEPROM every few minutes, or have the Uno send a running total since it was flashed instead of since boot. A reset then costs you a few pulses, not the whole total.

