Modify

Opened 10 years ago

Closed 9 years ago

#3810 closed defect (duplicate)

AR7 serial port does not receive properly

Reported by: petr.stetina@… Owned by: florian
Priority: normal Milestone:
Component: packages Version:
Keywords: Cc:

Description

Trunk, D-Link DSL-362T.

I wrote simple application which should communicate with MCU connected to serial port. While it does not work, I tried to debug outgoing and incomming messages and discover that MCU responses are invalid. On PC everything works fine so I short Tx and Rx pins on D-Link and did more investigation and found strange behavior of its serial port:

As Tx and Rx pins are shorted response should be the same as request but in fact response differs from request. For example when app. send $14D601A3 it receives $D601A3A3. Please note missing character at beginning and double $A3 at end of response! Another example: sent $F2D1E242FE6E9E received $D1E2E2FE6E9E9E.

Here is snippet of my code:

port = open(n,O_RDWR|O_NOCTTY|O_NDELAY); // O_NDELAY|O_NOCTTY|

if(port<0) return(1);
memset(&pconf,0,sizeof(pconf));
cfmakeraw(&pconf);
pconf.c_cflag=B9600|CS8|CLOCAL|CREAD;
pconf.c_iflag=IGNBRK;
pconf.c_cc[VMIN]=1; /* nonblocking read */
pconf.c_cc[VTIME]=0; /* inter-character timer */
tcflush(port,TCIOFLUSH); // discard received data
if(tcsetattr(port,TCSANOW,&pconf)==-1) error("Can't set port attributes.\n");
...
size_t w=write(port,tx,len);
tcdrain(port);
usleep(10000);
size_t r=read(port,rx,len);

for(j=0;j<len && !err;j++) {
  if(tx[j]!=rx[j]) {
    printf("Error:");
    showHex(tx,len); // show buffer content
    showHex(rx,len);
    return(1);
  }
}
...

dmesg lines related to serial port:

...
Serial: 8250/16550 driver $Revision: 1.90 $ 2 ports, IRQ sharing disabled
serial8250: ttyS0 at MMIO 0x8610e00 (irq = 15) is a TI-AR7
...

The exact same binary on Edimax BR-6104KP works as expected. But it has different serial port driver:

...
Serial: AMBA driver $Revision: 1.41 $
APB:UART0: ttyS0 at MMIO 0x12600000 (irq = 9) is a AMBA
...

Attachments (0)

Change History (2)

comment:1 Changed 9 years ago by florian

  • Owner changed from developers to florian
  • Status changed from new to assigned

comment:2 Changed 9 years ago by florian

  • Resolution set to duplicate
  • Status changed from assigned to closed

Duplicate of #3123.

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.