三仙
以馬內利

|
分享:
▲
▼
下面是引用a910937於2008-10-28 21:05發表的 RS232 for ARM (C 程式請教): 各位大大好~ 小妹最近再碰ARM的硬體 我有兩個ARM板,想透過RS-232來互相傳輸 ...我的TX端的程式是這樣的 : int main() { int fd; char buffer[]="0123456789"; int Length=255; int nByte; fd=open("/dev/ttyS1",O_RDWR | O_NONBLOCK); while(fd!=0) { nByte = write(fd,buffer,Length); printf(" buffer is= %s nByte=%d",buffer,nByte); } close(fd); } RX端: int main() { int fd; int nByte=0; char buf[255]; fd=open("/dev/ttyS1",O_RDWR ); if (fd==NULL) printf("open error\n"); while (nByte !=NULL) { nByte = read(fd,buf,255); printf("nByte=%d\n",nByte); printf("buffer is: %s nByte=%d", buf , nByte); } close(fd); } 可是不知道為什麼接收端的ARM板,好像收不到TX端要傳的字串,都顯示不出來不知道有沒有大大們用過ARM板,我是用C語言去寫code,我已經確認rs232事可以互相傳輸的,不過不知道為甚麼使用迴圈會發生錯誤,是接收端buffer問題嗎~? 希望有經驗的大大解答^^謝謝~~~~~ 建議妳 將以上的文章重新編排 讓想幫妳的人 更容易看得懂 或許,有善心人士會肯回答的
|
|
x0
[1 樓]
From:臺灣臺北市亞太線上公司 | Posted:2008-10-28 22:08 |
|
|
|