為什麼在串行控制台登錄時看到一些垃圾字節?


3

當我使用screen /dev/ttyUSB0 115200登錄到串行控制台時,在輸出中看到一些垃圾:

��
Arch Linux 3.6.11-10-ARCH+ (ttyAMA0)

raspberry login: root
�Password: 
Login incorrect

raspberry login: root
Password: 

根據我根據屏幕日誌(screen -L)使用Ctrl + AHF8製作的硬拷貝,這些問號是FD字節(十六進制)。請注意,只有 Password 第一行帶有問號,隨後的密碼提示中沒有該字節。

如何阻止這些問號出現?我是否需要更改tty設置或指定其他screen參數?

由systemd啟動的getty進程具有以下命令:

/sbin/agetty --noclear ttyAMA0 115200 linux

我正在使用USB設備連接串行線:

067b:2303 Prolific Technology, Inc. PL2303 Serial Port

5

This is probably the well known bug of the spurious character when the serial port is opened. I don't remember the details, something to do with the TX line dropping for an instant so signalling a spurious start bit. From memory it is a bug in the Raspberry Pi Linux driver. I don't know why it hasn't been fixed, it has been commented on for several years.

As I say the character happens on port open, e.g.

fd = open("/dev/ttyAMA0", O_RDWR);

will cause the error.

The work around is to ignore the first byte and not to needlessly close/open the serial port.