2

I want to receive data from RS232 Serial port to my terminal and with a directive to a file. It should be pretty straight forward.

cat /dev/ttyS0
cat /dev/ttyS0 > file.txt

Before that I've configured the parameters to match that of the device's(Biochemistry Analyzer).

sudo stty -F /dev/ttyS0 9600 -parity cs8 cstopb

i.e

  1. Baud Rate - 9600
  2. Parity - None
  3. Bits - 8 bit
  4. Stop Bits - 2

But I don't receive anything on the terminal.It's just blank. What is the problem?

1 Answer 1

6

Try Minicom first and see what your serial port returns. Install it with sudo apt-get install minicom

You start it as follows (for ttyS0):

sudo minicom -D /dev/ttyS0

You can set the communication parameters from within Minicom (using ctrl-A P), so you're sure that they are correct.

If your device uses a specific protocol, it might need a command to start its communication. So have a look at the user manual.

Maybe your device is set up to use hardware handshaking. If possible, turn it off (at least to start with).

If you can't turn it off, then you will have to set that up as well on your side. In Minicom this is under ctrl-A O and then serial port setup.

I've used Minicom often to debug serial communications and I find it works best.

I've received some more information from the OP:

The laboratory instrument(Cobas C311) uses ASTM protocol. There in the interface , we just need to click "Send to Host" and it sends a bunch of ASTM records. I just need to receive them in a file. Is there any other setting? What is the command to start acquiring data?...and how to save the data in a file?

Chosen the right paramters. Minicom is showing 9600 8N2. Hope it's alright. But receiving nothing - not a single bit. The analyser says, "The instrument transmitted ENQ as a send request,but the Host did not return ACK or NAK within 15 seconds.(Link Timeout)"

The device uses the ASTM Protocol. The device sends the <ENQ> character as a signal that it is ready to start sending data.
This is not something you will be able to receive using minicom or any other terminal program. You will need proper application software that supports this protocol.

You definitely have to read your user manual and check the installation disk (if any) and the manufacturer's website for an application that supports this protocol.
I would be surprised if they don't have application support for this device. If they offer something it is likely to be a Windows application or some example code plus a library.

It is possible to write something yourself, but it won't be easy. There is some Python support for ASTM and there is a Perl script that you could try.

SO also has a post with some information about ASTM..

6
  • Thank you! The laboratory instrument(Cobas C311) uses ASTM protocol. There in the interface , we just need to click "Send to Host" and it sends a bunch of ASTM records. I just need to receive them in a file. Is there any other setting? What is the command to start acquiring data?...and how to save the data in a file? Dec 7, 2015 at 5:12
  • Chosen the right paramters. Minicom is showing 9600 8N2. Hope it's alright. But receiving nothing - not a single bit. The analyser says, "The instrument transmitted <ENQ> as a send request,but the Host did not return <ACK> or <NAK> within 15 seconds.(Link Timeout)" Dec 7, 2015 at 6:18
  • 1
    That sounds like your device is actually expecting the computer to understand the data and send a reply – it wants an ENQ / ACK exchange, perhaps to make sure the computer is listening. Try sending an ACK byte by pressing Ctrl+F. Dec 7, 2015 at 6:44
  • 1
    The device indeed waits for an ENQ/ACK exchange and doesn't transmit any message until it receives one. We were succesful in receiving messages through nrComm Lib, which NZD has suggested. But it did not serve the purpose, as we need the messages automatically stored in a file. Ctr+F has not worked too, as @grawity has suggested. Need to figure out different ways.On a sidenote, could you please suggest ways to check if the RS232 cable works properly(though I'm quite sure it does), and which pins are shorted, so that one can make sure it's ok. Dec 8, 2015 at 5:09
  • 2
    @Br.Moksha If you really want, you can test the cable by shorting TxD and RxD (pins 2 and 3 on a 9-pin sub-D connector (DE9)). Make sure to turn off hardware flow-control (ctrl-A O, serial port setup in minicom). Every character you type in minicom will then be looped back. If you also want to test hardware flow-control, you have to short RTS and CTS (pins 8 and 9 on a 9-pin Sub-D). Also see Wikipedia: RS-232 and Serial port and this tutorial from National Instruments
    – NZD
    Dec 8, 2015 at 20:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .