Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I am looking for a means to pipe one serial ports data (regardless of data type) to another serial port. In my case I am trying to take in data from one serial port and output it through a radio connected to another serial port in real time.
I already know what ports I am using and have looked up a program called socat, which should be able to handle it but there are no examples of how to do this and I have not been able to figure out how to do it.
Has anybody been able to use socat or a bash scipt/some other method to accomplish this in Linux??
I am running Ubuntu 14.04.
Assuming the serial port you are reading from is /dev/ttyS0, and the other you are writing to (where the radio is connected) is /dev/ttyS1 you shall simply do:
cat /dev/ttyS0 > /dev/ttyS1
or
dd if=/dev/ttyS0 of=/dev/ttyS1 bs=1
Of course before you should set all the serial ports' parameters using stty command.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I'm a beginner with bash/linux. I have a program that I have written using Visual Code Studio. I have been able to correctly compile the program and it return the output I was expecting. But I have forgotten the command to take that output and put it into a specific file.
Also, how would I find the pathway for that file, if it's not physically on my computer? I've ssh into a rasp pi on campus. So all the files are on the pi. Could it be as simple as copy paste?
I really think you should go over the basics of remote connection to a Linux machine, but to answer your question:
In order to redirect output from a command line utility (i.e. your program):
./[program_name] &> [output file]
using the &> operator will redirect both stdout and stderr to that file which I assume you want
In order to pull that file from remote:
scp [username]#[server_ip]:/[output file] ./
This assumes you actually have a user on that remote machine that you can ssh into
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I need to send data to a Linux terminal, in this manner that terminal could receive the data with scanf? there is any way to do that?
I tried to write my desired data to /proc/pid/fd/1 with below command, however, I can see the written data in the terminal but scanf couldn't catch that data and still wait for the user to enter data.
printf "85\n" > /proc/24737/fd/1
This is a very interesting question, and there is no easy way (that I know of) to write to a another terminal using the file descriptors.
see https://unix.stackexchange.com/questions/385771/writing-to-stdin-of-a-process
However, Unix and Linux, have many great ways for IPC (inter process communication). You might want to looking into pipes, named pipes, or Sockets.
Depending on what you are doing you might think about popen, or screen.
You probably don't want to write to the terminal, but the task that is running on the terminal? Can you change how the task is invoked (called)? Do you need to use standard in for other things?
If you explain your use case, we will try to direct you better.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I have two Arduinos now used by my program.
SInce I'm on Linux and new to Linux, the port isn't static, like "com3" and "com6", I think it's "ttyUSB0" for the first Arduino which is connected, and "ttyUSB1" for the second and so on. But since both are connected when the OS boots, can I be certain that the port names will remain the same? Or is there some other way to access ports by name?
use udev!
udevadm info -a -n /dev/ttyUSB1 | grep '{serial}' | head -n1
should give you the USB interfaces serial number.
then you can write udev rules:
example
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A6008isP", SYMLINK+="arduino"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A7004IXj", SYMLINK+="buspirate"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="FTDIF46B", SYMLINK+="cisco.serial"
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I have two USB devices which appear as /dev/ttyACMn (a barcode reader and a motor controller). For each of them, when I try to open them in the first 15 seconds after plugging in, I get a "device or resource busy" error. After more than 15 seconds, they open fine. Do you have any idea what's causing it?
I tried using lsof to check if a process is using the device, but it finds no such process (it finds my process after I manage to connect to the device).
I'm currently using Ubuntu 14.04, kernel 3.13.0 64-bit, but I have seen this behavior in earlier Ubuntu versions too.
Thank you very much,
Noam
I think the problem is ModemManager. It scans serial interfaces on startup to see, if they belong to a modem.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I have a USB-Dongle that can recive radio signals (868Mhz).
This dongle coud be controlled over a screen terminal session:
screen /dev/ttyACM0
In this Terminal all 120sec appear strings:
T350B00B64C19
How can I save this strings in a variable to work with them.
Any ideas?
Starting screen with the -L option creates a log in the current working directory. I guess that should serve your requirements.
$ screen --help
...
-L Turn on output logging.
...
From man 1 screen:
-L tells screen to turn on automatic output logging for the windows.
If I understand correctly, you don't actually need screen; you just need to read from the serial device. For example:
while read data; do
# Work with value in $data
done < /dev/ttyACM0
Each call to read should block until the dongle writes another string to the serial device.
If you need to send commands to the device, you can also simply write the appropriate string to the same file:
printf "my-command" > /dev/ttyACM0
read response < /dev/ttyACM0