Answer the question
In order to leave comments, you need to log in
Is it possible to use name patterns in ProcessStartInfo in the Arguments method?
Good evening. I need to get the names of com ports through a c# program using the ls utility. Here is an example:
textBox.Clear();
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "/bin/ls";
psi.UseShellExecute = false;
psi.Arguments = "/dev/tt*";
// psi.Arguments = textBox1.Text;
psi.RedirectStandardOutput = true;
Process p = Process.Start(psi);
textBox.Text += (p.StandardOutput.ReadToEnd() + Environment.NewLine);
p.WaitForExit();
p.Close();
Answer the question
In order to leave comments, you need to log in
If there is a com port on the board (not via a usb adapter), then usually it will be / dev / ttyS *
Also in the dmesg log there will be lines when the OS starts, something like:
[ 0.860340] 00:02: ttyS0 at I / O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[ 0.880928] 00:03: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is a 16550A
[ 0.901518] 00:05: ttyS2 at I/O 0x3e8 (irq = 5, base_baud = 115200) is a 16550A
If USB adapter, then yes it should be /dev/ttyUSB*
and the corresponding entries in the dmesg log:
[ 6.968929] usb 3-3: FTDI USB Serial Device converter now attached to ttyUSB0
about ls and grep
commands " ls /dev/ttyUSB*" should be enough to get all ttyUSB
if there is no shell then try "ls /dev/|grep ttyUSB"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question