LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Serial port reading (https://www.linuxquestions.org/questions/linux-newbie-8/serial-port-reading-726679/)

jayadhanesh 05-18-2009 12:11 AM

Serial port reading
 
Hi,

I have to write and read from a serial port. Iam able to write
to the port /dev/ttyS1 but not able to read from the same port.
What configuration should I set to enable reading from the port?

Thanks,
Dhanesh.

theNbomr 05-18-2009 12:45 AM

How have you tried reading from the serial port? What have you done to verify that serial data is being sent to the port? What do you know about the incoming serial data (baud, parity, data format, etc)? When you say 'not able to read from the same port', what exactly are you doing to try to read the data? Have you made a loopback connection on the port? Are you using some serial communications software such as minicom, or are you writing your own code? If the latter, posting some sample code (use [code] tags to preserve formatting, please) would be helpful.
More information is required.
--- rod.

jayadhanesh 05-19-2009 12:43 AM

Hi,
I used to minicom and it worked fine. Iam using the same baud rate.
I tried to do a echo $val > /dev/ttyS1. I was able to recive the same back on read.

Thanks,
Dhanesh.

Jerre Cope 05-19-2009 06:54 PM

From perl perspective, something like this:

my $tty_cmd = "stty 9600 cs8 ignpar -echo -echok -icrnl -ixon -ixoff ixany -icanon -opost -onlcr time 12 min 0 <";


open( TTY,"+<",$serial_line ) || die( "open serial line error: $serial_line $?")

Adopt the stty command in linux/unix to suit.


All times are GMT -5. The time now is 01:13 PM.