Yapay zekâ tarafından English dilinden çevrildi ·
Sorun terminal programında değil, Pi tarafında. SSH’nin bedavaya sağladığı iki şey seri girişte eksik.Terminal türü: SSH, TERM değerinizi iletir (PuTTY’den xterm-256color). Seri getty ise TERM’i vt220 olarak ayarlar; bunda renk yoktur, bu yüzden TERM’e bakan programlar geri döner ya da ham kodlar basar. echo $TERM ile kontrol edin.Pencere boyutu: Seri hat, Pi’ye pencerenizin boyutunu bildirmenin bir yolunu sunmaz; bu yüzden 80×24 varsayar ve hiç değişmez.Konsola bağlandığım her makinede bunu ~/.bashrc dosyasına koydum:
case "$(tty)" in
/dev/ttyS0|/dev/ttyAMA0|/dev/serial0)
export TERM=xterm-256color
stty rows 50 cols 160 # match your PuTTY window
;;
esac
xterm paketini kurarsanız boyutu sabit kodlamak yerine resize yazabilirsiniz; terminale sorar ve ayarlar.Betiğinizin renkleri, günlük kütüphanesi TERM’i kontrol ediyorsa çalışacaktır.
It’s the Pi side, not the terminal program. Two things are missing on a serial login that SSH gives you for free.
The terminal type: SSH passes your TERM along (xterm-256color from PuTTY). The serial getty sets TERM to vt220, which has no colour, so programs that check TERM fall back or print raw codes. Check with echo $TERM.
The window size: there’s no way for the serial line to tell the Pi how big your window is, so it assumes 80×24 and never changes.
I put this in ~/.bashrc on every box I console into:
case "$(tty)" in
/dev/ttyS0|/dev/ttyAMA0|/dev/serial0)
export TERM=xterm-256color
stty rows 50 cols 160 # match your PuTTY window
;;
esac
If you install the xterm package you can type resize instead of hardcoding the size, it asks the terminal and sets it.
Your script’s colours will then work, assuming the logging library checks TERM.

