Threads are within one process, so I guess you mean separate process that runs in the background (like a deamon process)?
Anyway, adding '&' at the end of the command will make it detach from the terminal and run as background process. This works for everything, executable and script.
Depending on the format you want it stored (the uart data), you probably can find a script/executable or just a unix command utility that will do it for you.
If the data is pure ASCII:
cat /dev/[your serial device]
should already work, add a redirection and the & you'll get:
cat /dev/[your serial device] > /tmp/uart-output.txt &
If you need to setup your serial port first, you can use the command stty for this purpose.
Please, check the stty man page for a truckload of parameters and options.
If you don't want to use cat or you need to convert/format the data (to hex for example because it is not ASCII only) this perl script will give you a good start, although using cat and a couple of other utils, you should be able to get similar results:
#!/usr/bin/perl
#
#
# Author: Bruce S. Garlock
# Date: 2002-09-11
# Requirements: Device::SerialPort 0.12 (from cpan)
#
# Version: 0.1
#
#
# Description: This perl script is for logging of data from a serial
# port, to a specified logfile. The logfile can then be parsed with
# other programs for reporting purposes.
#
# This program was written for specifically logging Multitech's
# MTASR2-203 T1 Router. The router outputs text to the command
# port with 57.6k, 8-1-N, and No flow control.
#
#
use Device::SerialPort 0.12;
$LOGDIR = "/var/log"; # path to data file
$LOGFILE = "router.log"; # file name to output to
$PORT = "/dev/ttyD015"; # port to watch
#
#
# Serial Settings
#
#
$ob = Device::SerialPort->new ($PORT) || die "Can't Open $PORT: $!";
$ob->baudrate(57600) || die "failed setting baudrate";
$ob->parity("none") || die "failed setting parity";
$ob->databits(8) || die "failed setting databits";
$ob->handshake("none") || die "failed setting handshake";
$ob->write_settings || die "no settings";
#
# Send a string to the port
#
#
$pass=$ob->write("AT");
sleep 1;
#
# open the logfile, and Port
#
open(LOG,">>${LOGDIR}/${LOGFILE}") ||die "can't open smdr file $LOGDIR/$LOGFILE for append: $SUB $!\n";
open(DEV, "<$PORT") || die "Cannot open $PORT: $_";
select(LOG), $| = 1; # set nonbufferd mode
#
# Loop forver, logging data to the log file
#
while($_ = <DEV>){ # print input device to file
print LOG $_;
}
undef $ob;
If I messed up the conversion to html, here is the link logger.pl
If you saved this script as logger.pl the command:
logger.pl &
should make it detach and run as background process, or
perl logger.pl &
in the case you don't make it executable.