how to use serial port under linux?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to use serial port under linux?

1,373 Views
rong
Contributor I
Hello all:
 
I have two questions.
1. how to use serial port under linux development?
2. how to use serial port under CodFire BSP?
 
Thanks
 
Rong
Labels (1)
0 Kudos
1 Reply

257 Views
jpa
Contributor IV
Rong,

You may get better answers if your questions are more specific.  Do you mean that you wish to read/write to the serial ports from within your program running under Linux?  What programming language are you using?

Can you explain how your two questions are different?

In C and Linux, one method is basically to do something like:

int filedes;
char output_string[] = "Hello, World";

filedes = open("/dev/ttyS1", O_RDWR | O_NOCTTY | O_NDELAY);  //your text within the quotes may vary
write(filedes, output_string, strlen(output_string));
sleep(5);
close(filedes);

But I've left out all the error checking and terminal configuration.

You might try the book "Beginning Linux Programming" by Stones and Matthew.
Or Google "Serial Programming Guide for POSIX Operating Systems".

John
0 Kudos