|
|
. Q3 z4 w% N. H# q
您好,使用OMAPL138-EVM开发板,按照《2-1开发板快速体验》,在内核编译时把"System Type -> TI DaVinci Implementations->Enable UART1 RS485 funcation"选项选上,并重新编译内核,然后使用编译后的内核启动系统。发现开发板485口能发数据,但是不能接收数据。
& V% R! h) Z% {0 K2 u, X( ]0 g5 A/ Y e! Y7 L
我的qt程序如下:) K& d9 L d9 M
struct termios setting;
; q5 r2 V# V* a. l fd = open("/dev/ttyS1", O_RDWR);! \( h! N9 L3 f' H+ q
if (fd == -1) {
' u$ P8 t$ @4 q9 P9 b- u" T3 d' O LOG_INFO("open /dev/ttyS failure ...");
5 y' P; ~: d3 f2 D* @4 e return ;
( W/ ^( a* u, V1 r& {- H6 p }; J( W7 b( ~( _+ X
LOG_INFO("open /dev/ttyS1 success ...");
5 Z% \& i! C! V/ x+ N, t$ N# k: z tcgetattr(fd, &setting);
+ f' j3 ^/ G. q6 c: j7 p speed_t speed;
+ P% u5 @" A5 B! y1 T- J8 I) y6 m* m speed = btr;# u; ~+ S0 B7 l7 b# w# A
^2 c g/ p9 G5 r, m4 Q# x6 u4 `
cfsetispeed(&setting, speed);+ X& C4 i( m6 S
cfsetospeed(&setting, speed);: [" J! t+ i/ V' P7 s' A
cfmakeraw(&setting);( |5 Z( q: ]6 ?( |7 w t# P6 K2 C
setting .c_cflag |= CS8;
: U' C- D X, i0 r( u6 t: ^ setting.c_cflag &= ~PARENB;' q W9 o$ ?; o( h( A
setting.c_iflag &= ~INPCK;
6 E0 t0 j; D" O setting.c_cflag &= ~CSTOPB;
$ n) e9 M+ G" F tcflush(fd, TCIFLUSH);
; R, n" F, O' x; g2 \; z setting.c_cc[VTIME] = 0;( B0 V3 G3 C- c* E
setting.c_cc[VMIN] = 0;
' s* x# r. v, J) ?+ S% U0 g tcsetattr(fd, TCSANOW, &setting);
- v1 [$ I! A4 S, y- O
3 e) a* B8 a' L int ret;
- l- @! V+ z2 N+ s3 E: w1 u char *buff = {"hello,485write ok"} ;3 w" L5 l7 |, E" Y
ret = write(fd, buff, 17);6 T, |2 r8 [1 R) Q0 _6 d% T
! z- K4 j5 N3 }+ i
char buff1[256] ;3 u* V1 i8 o+ M3 A3 B
while(1){2 a" z, K* A. h9 K: D3 }
! ?2 r* d, g8 J( S
ret = read(fd, buff1, 255);" o' N+ N+ c2 X, {
if(ret > 0){
* u& I- F1 q5 d8 m0 Z( X4 p% Z$ T( q. D! n" }4 j. P
write(fd, buff1, 5);9 W9 b( |" p" \ g$ E
# R! D$ w1 m3 D/ W7 i T+ f LOG_INFO("rs485 receiver ret = %d " , ret);0 t3 p, `/ k/ b) ^/ V k, L
5 c% I4 F/ s8 }$ W/ I }
! V( `& w) K, M/ J. P) J
% o5 r: L; t t7 g8 ] }
+ W3 l7 o/ m& s8 k( @: B% k* a$ r1 ?% I" |
我使用串口调试助手,开发板能发送数据,调试助手能收到”hello,485write ok“,但是调试助手发的数据开发板却没有收到。并且用示波器可以看到UART1_RXD管脚的数据。请问为什么?
4 P- W$ J; n; j9 b0 W5 h3 A) u( G5 E. g# {+ S8 r
( R: t8 e! ~4 Z0 `/ T/ O! {
* g( I# A: D) _
|
|