You are not logged in.

#1 2014-04-23 03:49:03

weltio
Member
From: Germany
Registered: 2009-04-05
Posts: 90

pipe to and read from ttyS1

Hello,

we have the following problem:

Our piece of hardware is connected via RS232. We want to send data continously to the hardware and read the answer which will be sent to the same port.
Since there are two different lines (RX, TX) it should be possible, should it not?

E.g. this doesnt work:

processWithOutput > /dev/ttyS1
Ctrl + Z
bg
cat /dev/ttyS1
Permission denied
sad

So what could we do?
I think the problem is the contious pipe, right?

Offline

#2 2014-04-23 06:41:05

mpan
Member
Registered: 2012-08-01
Posts: 1,675
Website

Re: pipe to and read from ttyS1

You'll probably run into problems related to setting proper baud rate and possibly other options, but for now your problem is much more trivial: you don't read messages. What you have posted contains explaination why the solution doesn't work. Why are you ignoring it?

It's quite unprobable that as a normal user you'll be able to read from and write into a serial tty belonging to the root or other user. Use:

processWithOutput | sudo tee /dev/ttyS1 >/dev/null

for writing and

sudo cat /dev/ttyS1

for reading.

Offline

#3 2014-04-23 10:47:38

weltio
Member
From: Germany
Registered: 2009-04-05
Posts: 90

Re: pipe to and read from ttyS1

Actually its only a cygwin on windows and so "sudo" is more a workaround.
Nevertheless, the read and write access is granted (otherwise I would get the error when wrinting, not when reading)
The problem is not the writing access but reading from the device which is used continously.

Why should the baudrate be a problem? Source and sink are using the same.

Offline

#4 2014-04-23 11:17:23

mpan
Member
Registered: 2012-08-01
Posts: 1,675
Website

Re: pipe to and read from ttyS1

Well.. I've naïvely assumed that on Arch forum we're talking about Arch. I can tell nothing about how /dev/ttySs works on Windows or why it doesn't work.

If cat exits too early, reading continously can be done in an infinite while loop by reading either with cat or, if this doesn't work for some reason, with head -c 1 (however cat should do - at least for Arch).

Baud rate is not a problem. Baud rate [and possibly other] options might be. First: you have to set them. Second: some tools are quite discriminating on what they accept, because they hardcode some operations to be done on an open file which make no sense for a given case. They will bark at you when you'll try to connect them to something they don't like - and with serial TTYs, pipes and tools related to them this happens to be a common issue.

Last edited by mpan (2014-04-23 11:17:43)

Offline

#5 2014-04-23 13:14:54

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: pipe to and read from ttyS1

I fail to see how this is Arch related. Since the problem is not Arch related I doubt you will find people that can help you here.

You should ask for help in a forum dedicated to cygwin or in one of cygwin's mailing lists, also don't forget google. Dealing with serial ports should be well documented and you should be able to find many examples of how to do what you want.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

Board footer

Powered by FluxBB