General TC > General TC Talk
Serial Port
Rich:
Hi MTCAT
--- Quote from: MTCAT on February 12, 2026, 10:57:27 AM --- ... I think method number one would be the easiest way of getting the temperature readings into the acquisition GUI (because we would be loading temp values from a file that always has the same name) but method number 2 would seem to be the most organized way of storing them for the future, if I wanted to look at the temp readings after the fact for example. ...
--- End quote ---
I have a fix for that too.
You don't say what that file name is, so I'll assume it's called Temps.log:
--- Code: ---ln -sf $(date +"%y%m%d%H%M%S").log Temps.log; sudo microcom -s 9600 /dev/ttyACM0 > Temps.log
--- End code ---
This creates a link to a file with a YYMMDDHHMMSS.log date code name.
The file does not exist yet.
The second something gets written to Temp.log , it gets created.
Plus, when you read from Temp.log , you'll be reading from the current log.
Rich:
Hi MTCAT
--- Quote from: Rich on February 12, 2026, 05:30:56 PM --- ... The file does not exist yet.
The second something gets written to Temp.log , it gets created. ...
--- End quote ---
If nothing gets written to Temp.log (i.e. minicom failed for some reason) and
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: ---ln -sf $(date +"%y%m%d%H%M%S").log Temps.log && touch Temps.log; sudo microcom -s 9600 /dev/ttyACM0 > Temps.log
--- End code ---
Without the touch command, you get a link to a file that doesn't exist:
--- Code: ---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.log
--- End code ---
With the touch command, you get a link to an empty file that does exist:
--- Code: ---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.log
--- End code ---
If you want to see what the current file is:
--- Code: ---tc@E310:~$ readlink Temps.log
260213094817.log
--- End code ---
If you need to test if the current file is empty:
--- Code: ---tc@E310:~$ [ ! -s Temps.log ] && echo "$(readlink Temps.log) is empty"
260213094817.log is empty
--- End code ---
or:
--- Code: ---tc@E310:~$ [ -s Temps.log ] || echo "$(readlink Temps.log) is empty"
260213094817.log is empty
--- End code ---
MTCAT:
Hi Rich,
Sorry for the slow reply, I was away for a bit and then have spent the last few days putting together the first receiver, which thankfully still works fine!, including the new virtual com port temp sensor. For some reason just measuring the BIOS voltage battery seems to have caused a reset though, as though I unplugged the BIOS battery, ???, so that was weird, but other than that, receiver number one (BASE) is back up and running, and with the virtual com port temp sensor too!
Oh wow, thanks for the amazing bash commands!, super helpful and super handy!, am I correct to say that the commands below create both a log file with the date and time as the title AND a "working" file (for the GUI), in this called "Temps.log"?
I think the "working file" as I'm calling it (Temps.log) would also always start out fresh in the sense that when the re-direct command from microcom is executed on power up (as contained in a script in ~/X.d lets say), it would overwrite the previous "Temps.log" and starts "fresh" with new readings?
--- Code: ---ln -sf $(date +"%y%m%d%H%M%S").log Temps.log; sudo microcom -s 9600 /dev/ttyACM0 > Temps.log
--- End code ---
Ah, okay, and then adding the touch command basically creates an empty file ahead of time?
I can't recall if the big C code acquisition program checks for file existence before trying to load anything or not, will have to check.
Thanks a lot,
David
Rich:
Hi MTCAT
--- Quote from: MTCAT on February 24, 2026, 03:27:53 PM --- ... am I correct to say that the commands below create both a log file with the date and time as the title AND a "working" file (for the GUI), in this called "Temps.log"? ...
--- End quote ---
Temps.log is a "link" to the current YYMMDDHHMMSS.log file. Either name
can access it, but when the command gets run again, a file with a new
YYMMDDHHMMSS timestamp will be created and Temps.log will be pointing
at that instead.
--- Quote --- ... I think the "working file" as I'm calling it (Temps.log) would also always start out fresh in the sense that when the re-direct command from microcom is executed on power up (as contained in a script in ~/X.d lets say), it would overwrite the previous "Temps.log" and starts "fresh" with new readings? ...
--- End quote ---
Yes, and a new YYMMDDHHMMSS.log file.
--- Quote --- ... Ah, okay, and then adding the touch command basically creates an empty file ahead of time? ...
--- End quote ---
It's a good idea to include that. It makes it easy to spot a string of failures since
those files will show a size of zero bytes in a directory listing. The file names
will tell you when those failures occurred. If you copy them, their timestamp in
a directory listing may change, but the filename will still reflect when it was created.
MTCAT:
Hi Rich,
Oh, okay, thanks for the explanation, when I get the system finalized I'll give those commands a try!
Thanks a lot,
David
Navigation
[0] Message Index
[*] Previous page
Go to full version