WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Serial Port  (Read 213 times)

Offline MTCAT

  • Sr. Member
  • ****
  • Posts: 412
Serial Port
« on: February 10, 2026, 12:01:07 PM »
Hi everyone,

I bought a temperature sensor which when setup ahead of time on another machine, under the application of the next power up, acts as a virtual com port and simply outputs temperature readings in an ascii character string at 9600 bps.

It seems to work on my old TC 3.8.4 (kernel 2.6.33) except as soon as I try to look at the output of the port with;

Code: [Select]
cat /dev/ttyACM0

or with;
Code: [Select]
microcom -s 9600 /dev/ttyACM0

Everything seems okay, but when i Ctrl-C (in case of cat) or Ctrl-X (in case of microcom) my system returns in a very strange state; I do get the command prompt back but typing

Code: [Select]
ls

Returns nothing but an "Input/Output" error, and it seems that my filesystem is completely gone!!??

I am able to

Code: [Select]
sudo poweroff

And turn off gracefully (I hope) but I wonder if anyone has encountered this before and knows a possible solution? I also tried to install a python program "grabserial" but after installation of pyserial library, the program "grabserial" is not working at all, error codes of various types.

And strangely, after exiting "cat" or "microcom"  typing  "dmesg" doesn't show anything telling regarding this.

I did test the sensor on an even older distribution (2.6.21) on as ASUS EEE laptop and it seems to fully work in the sense that I can "cat /dev/ttyACM0" and I see the output strings just fine, and hitting "Ctrl-C" to exit "cat" the system is back to normal, no "lost" filesystem.

Any ideas as to what's going on with my TC 3.8.4 setup regarding this?

Thanks,

David

Offline MTCAT

  • Sr. Member
  • ****
  • Posts: 412
Re: Serial Port
« Reply #1 on: February 10, 2026, 02:18:30 PM »
Hi everyone,

Sorry for all my posting lately, but I think I (FINALLY) got this problem fixed!

After all the problems I've been having lately with the 4GB boot-stick and the temp sensors I guess I got impatient and changed a few things at once, so now I'm not sure which was the culprit but at least it's working now, I think anyway.

In the BIOS, firstly I disabled "ECHI handoff", this actually didn't do anything that I could tell, and then I;

1) In the BIOS, changed "Plug and Play OS" from No to Yes.
2) In the BIOS, under USB Device Management changed "Emulation" from "Auto" to "HDD".
3) I plugged the temperature sensor into a different port (probably irrelevant).
4) Ran the commands as su.

So now, typing

Code: [Select]
sudo microcom -s 9600 /dev/ttyACM0 > test.log

Works!, and even better, hitting Ctrl-X to exit, everything seems stable and normal afterwards! So must have been one of the BIOS settings that was causing me grief?

Now I'm trying to figure out how to add a time stamp to the log file, I tried;

Code: [Select]
sudo microcom -s 9600 /dev/ttyACM0 | date > test.log
And that didn't work at all, I might be able to get by w/o a time stamp there but would be nice to have.

Thanks for listening, and if anyone knows how to append a time onto the microcom output above, that would be great!

Thanks,

David

    [Edit]: Fixed code tag.  Rich
« Last Edit: February 10, 2026, 04:50:00 PM by Rich »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12570
Re: Serial Port
« Reply #2 on: February 10, 2026, 05:13:55 PM »
Hi MTCAT
Try this:
Code: [Select]
date > test.log; sudo microcom -s 9600 /dev/ttyACM0 >> test.log
This should work too:
Code: [Select]
sudo microcom -s 9600 /dev/ttyACM0 > $(date +"%y%m%d%H%M%S").logThat should create a log file whose name is the date code that looks like:
Code: [Select]
YYMMDDHHMMSS.logThis creates a unique file every time it's run. In a directory listing they
would all be grouped together and sorted from oldest to newest.

Offline MTCAT

  • Sr. Member
  • ****
  • Posts: 412
Re: Serial Port
« Reply #3 on: February 11, 2026, 11:05:51 AM »
Hi Rich,

Thanks a lot for the help getting a timestamp into the log file, I'll give your suggestions a try next time I have the system up and running!

Thanks,

David

Offline MTCAT

  • Sr. Member
  • ****
  • Posts: 412
Re: Serial Port
« Reply #4 on: February 12, 2026, 10:57:27 AM »
Hi Rich,

Thanks for the help, I tried out your commands and they worked!, the first one adds the date and time at the very top of the logfile, and then the strings containing the temperature values roll in after that at once every predetermined interval, right now set to 5 seconds. The second way also worked with a nice title to the log file indicating the year/month/day and time as the name.

Not sure yet which would be best, 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.

Good to have options though, thanks a lot!

I actually got the acquisition program running on the second receiver now!, what a milestone!, but I'm having write permission problems to the CF-card, I'll make a separate post for that.

Thanks again,

David

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12570
Re: Serial Port
« Reply #5 on: February 12, 2026, 05:30:56 PM »
Hi MTCAT
... 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. ...
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: [Select]
ln -sf  $(date +"%y%m%d%H%M%S").log Temps.log; sudo microcom -s 9600 /dev/ttyACM0 > Temps.logThis 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.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12570
Re: Serial Port
« Reply #6 on: February 13, 2026, 10:05:58 AM »
Hi MTCAT
... The file does not exist yet.
The second something gets written to  Temp.log , it gets created. ...
If nothing gets written to  Temp.log  (i.e. minicom failed for some reason) and
to 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.log
Without 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.log

With 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.log

If you want to see what the current file is:
Code: [Select]
tc@E310:~$ readlink Temps.log
260213094817.log

If 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 empty
or:
Code: [Select]
tc@E310:~$ [ -s Temps.log ] || echo "$(readlink Temps.log) is empty"
260213094817.log is empty