Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm working in a project in which I will have to deal with serial communications. For testing, I want make to 2 computers speak to each other (with my interaction) via RS232.

Will the next thing work?

in computer A:

# cat /dev/ttyS0

in computer B:

# echo <something> >> /dev/ttyS0

Will computer A, receive data from B, or not?

If I'm wrong, what would be the easiest way to send something to the other computer?

Ideas are welcome!

share|improve this question
    
This is probably a question better asked at stack overflow –  Falmarri Oct 16 '10 at 8:43
    
@falmarri: this isn't a programming question, so why? –  delete Oct 18 '10 at 10:24
    
@falmarri: Toadette is right, and my question is related only to unix enviroments. –  Tomas Oct 18 '10 at 21:59

2 Answers 2

up vote 1 down vote accepted

Well, if you want to communicate via the serial port you have to setup the right parameters (baud, stop bit, parity,handshake etc.).

I used minicom in the past for stuff like using a computer as a serial console terminal to another.

The cu command is an alternative.

share|improve this answer
    
I tried that way yesterday, but it didn't work... Could it be the cable? Don't know if it had crossed TX and RX, because I borrowed it. –  Tomas Oct 16 '10 at 19:47
    
Well, I am no fortune teller ... Sure, the cable could always be the problem. But serial cables are easy to check via a continuity tester (usually available in every voltmeter). Just buy a new cable, they are really cheap ... –  maxschlepzig Oct 16 '10 at 20:48

An easier way, if you know how to program in python, might be for you to use an API available for python called PYSERIAL so that you don't have to worry about doing any of the dirty work of setting up flags or passing parameters to the driver that handles the serial port on your computer. Pyserial takes care of all this for you in the background.

You would have to specify the baud rate at most, and leave the rest as default for a working serial connection between the 2 computers.

The entire code for enabling such a connection could be at the most a few lines or half a page long.

share|improve this answer
    
This is why I suggested this might be better on stackoverflow =P –  Falmarri Oct 18 '10 at 22:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.