how to use serial port under linux?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

how to use serial port under linux?

1,524 次查看
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 回复

408 次查看
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 项奖励
回复