Access is denied when trying to access the serial port a second time in Cygwin

I am trying to get data from a USB serial port that is connected to an Arduino. I use Cygwin and I write

cat /dev/ttyS4 

to output data in the shell.

When I stop the process, I am assigned

Access is denied

when I try to access it again. I have to close Cygwin, open it again and enter it to get output to the shell.

I noticed that I can read the serial port from only one program. For example, if I read data from a serial port in Arduino software, I cannot access it in Cygwin.

Is there a way to access the serial port data as many times as I want in Cygwin, without having to close the program, open it again and write it in the same command?

+4
source share
1 answer

It seems that the cat /dev/ttyS4 will echo the characters from the serial port until the end of the file is reached. Only by nature does the serial port never reach the end. Thus, you will need to configure the end input. One way would be for Arduino to put the end of the symbol file (control-D) in the output stream. Another way would be to use the so-called "heredoc", with which you tell it to look for a line that will be completed, as described in this question .

However, there are still a number of problems. One of them seems wrong that control-C does not block access to the serial port. Another, I tried this on my machine, and I can't get it to create the problem you asked for. So as far as I can offer.
0
source

All Articles