LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Question about serial port card (https://www.linuxquestions.org/questions/linux-hardware-18/question-about-serial-port-card-899378/)

MTK358 08-25-2011 08:05 AM

Question about serial port card
 
I have a serial port card (http://www.newegg.com/Product/Produc...004&Tpk=rc-301) in my desktop, I got it mostly to be able to easily communitate with microcontroller projects. Wen I pipe data into it like this:

Code:

echo "test" > /dev/ttyS0
, it comes out at 9600 baud. What I wonder is if it's possible to change the baud rate, and is it safe to rely on the fact that it will be 9600 when you just pipe data into it like in the above example?

gammahermit 08-25-2011 12:40 PM

There is a program called setserial that lets you modify serial port settings. Check the man page for the right option.

MTK358 08-25-2011 02:36 PM

I guess that is what I'm looking for, but there's something strange I noticed:

Code:

$ setserial -a /dev/ttyS0
/dev/ttyS0, Line 0, UART: 16550A, Port: 0xec00, IRQ: 16
        Baud_base: 115200, close_delay: 50, divisor: 0
        closing_wait: 3000
        Flags: spd_normal skip_test

Howcome it says tha the baud rate is 115200, when it's actually 9600? I know for sure since I have a device connected to that serial port right now that's sending data at 9600 baud, and it's working.

salasi 08-25-2011 02:41 PM

It actually says that baud_base is 115200. I think that's upstream of whatever dividers are set locally, and there are dividers set.

MTK358 08-26-2011 09:17 AM

Quote:

Originally Posted by salasi (Post 4453402)
It actually says that baud_base is 115200. I think that's upstream of whatever dividers are set locally, and there are dividers set.

I don't really understand, and how do I configure those?

Anyway, I have another problem: I have a microcontroller project that accepts commands and prints output through the serial port. The problem is that when I run:

Code:

cat /dev/ttyS0
to see the output, it automatically echoes it back to the microcontroller, which interprets it as commands. How do I stop this, and why doesn't it echo when I don't run the above "cat" command?


All times are GMT -5. The time now is 10:32 PM.