21
General TC Talk / Re: Serial Port
« Last post by Rich on February 13, 2026, 10:05:58 AM »Hi MTCAT
you try to read from Temp.log , you'll get a file not found error. If you do it like
this, you will only need to deal with an empty file for the same situation:
Without the touch command, you get a link to a file that doesn't exist:
With the touch command, you get a link to an empty file that does exist:
If you want to see what the current file is:
If you need to test if the current file is empty:
... The file does not exist yet.If nothing gets written to Temp.log (i.e. minicom failed for some reason) and
The second something gets written to Temp.log , it gets created. ...
you try to read from Temp.log , you'll get a file not found error. If you do it like
this, you will only need to deal with an empty file for the same situation:
Code: [Select]
ln -sf $(date +"%y%m%d%H%M%S").log Temps.log && touch Temps.log; sudo microcom -s 9600 /dev/ttyACM0 > Temps.logWithout the touch command, you get a link to a file that doesn't exist:
Code: [Select]
tc@E310:~$ ln -sf $(date +"%y%m%d%H%M%S").log Temps.log
tc@E310:~$ ls -l *.log
lrwxrwxrwx 1 tc staff 16 Feb 13 09:46 Temps.log -> 260213094621.logWith the touch command, you get a link to an empty file that does exist:
Code: [Select]
tc@E310:~$ ln -sf $(date +"%y%m%d%H%M%S").log Temps.log && touch Temps.log
tc@E310:~$ ls -l *.log
-rw-r--r-- 1 tc staff 0 Feb 13 09:48 260213094817.log
lrwxrwxrwx 1 tc staff 16 Feb 13 09:48 Temps.log -> 260213094817.logIf you want to see what the current file is:
Code: [Select]
tc@E310:~$ readlink Temps.log
260213094817.logIf you need to test if the current file is empty:
Code: [Select]
tc@E310:~$ [ ! -s Temps.log ] && echo "$(readlink Temps.log) is empty"
260213094817.log is emptyor:Code: [Select]
tc@E310:~$ [ -s Temps.log ] || echo "$(readlink Temps.log) is empty"
260213094817.log is empty
Recent Posts