how to use serial port under linux?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

how to use serial port under linux?

1,494件の閲覧回数
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
ラベル(1)
0 件の賞賛
返信
1 返信

378件の閲覧回数
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 件の賞賛
返信