I am experimenting with writing data to a serial port device file and reading it inside my application.
The application checks if some bytes of data are present in the device file by calling ioctl.
I noticed that only when I write data inside square brackets does ioctl() return bytes are stored.
Next I tried to also read the file contents from the terminal and see if anything was stored, and I find that again I am only able to read data from the device file when it is included in brackets.
See my experiment below
Is this expected behavior? If so, where is it coming from? Can I turn this off?
terminal 1 over ssh:
root@fx30:~# echo “[12345]” > /dev/ttyHSL1 #1
root@fx30:~# echo “12345” > /dev/ttyHSL1 #2
root@fx30:~# echo “[12345]” > /dev/ttyHSL1 #3
root@fx30:~# echo “[12345]” > /dev/ttyHSL1 #4
root@fx30:~# echo “abcd[12345]” > /dev/ttyHSL1 #5
root@fx30:~# echo “[12345]abcd” > /dev/ttyHSL1 #6
root@fx30:~# echo “[12345abcd” > /dev/ttyHSL1 #7
root@fx30:~# echo “[12345abcd]” > /dev/ttyHSL1 #8
terminal 2 over ssh, monitoring same device file
root@fx30:~# tail -f /dev/ttyHSL1
[12345] # from 1
[12345] # from 3
[12345] # from 4
[12345] # from 5
[12345] # from 6
[12345abcd] # from 8