When opening an FDTI USB UART based serial port plugged into the USB host of an ARM9 based embedded board, it spontaneously transmits data. It does this right upon opening, even before the bit rate has been set, or anything else has been done to the fd.
The data being sent is always more or less the same:
^@^@^@^@^@
In hexadecimal notation that is: 0x5e 0x40 0x5e 0x40 0x5e 0x40 0x5e 0x40 0x5e 0x40. The number of repetitions varies from a single pair, up to 256 pairs.
I have traced back this data and it origins from the tty Kernel workqueue. So it is not caused by a buggy driver with an improperly initialized transmit queue or anything along that line. Clearly the Kernel is purposely transmitting this data, upon the open syscall.
This problem only occurs when opening the tty port for the first time after reboot or after plugging in the FTDI USB UART. (A reboot power-cycles the USB device, so those two are basically the same.)
And yes, I do realize that ^@ means '\0'. And also that NULL can be used to implement delays. From the manual:
The delay bits specify how long transmission stops to allow for mechanical or other movement when certain characters are sent to the terminal. In all cases a value of 0 shall indicate no delay. If OFILL is set, fill characters shall be transmitted for delay instead of a timed delay. This is useful for high baud rate terminals which need only a minimal delay. If OFDEL is set, the fill character shall be DEL; otherwise, NUL.
However, my TTY settings don't indicate such a setting being active:
root@IVW78103 ~$ stty -F /dev/ttyUSB0 -a
speed 9600 baud;stty: /dev/ttyUSB0
line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke
Now the last - and most important - clue that I have is that the device on the serial port side of the FTDI outputs a lot of data when powering up (= USB plug-in). And when I isolate the FTDI RxD line, the problem doesn't occur. So obviously the Kernel, termios or tty takes offence in this data.
Now the question is: How do I prevent this ^@ data from being sent? Because the device on the serial port side of the FTDI doesn't respond well to it.
Edit: The output seems to be termios echoing input. The symptom vanishes if I lobotomise the Kernel by out-commenting this code in .../drivers/tty/n_tty.c:process_echoes:639
tty_put_char(tty, '^');
tty_put_char(tty, op ^ 0100);
It still puzzles me why it is echoing data received long before opening the tty port. I may be a side effect of USB UARTs not being able to truly flush all data.
^@
keystroke form, so the hex codes for this is irrelevant. "How do I prevent this ^@ data from being sent?" __ The NUL chars are probably due to your (unspecified) setup. I have ARM9 SBCs and FTDI USB-to-RS232 adapters, and have never seen extraneous null characters. – sawdust