This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM365 UART1 spurious data transmitted on receive

Hello,

I've found what I think is a problem of the DM365 uart 1 driver. I have a DM365 connected to an external device through UART1. When I send a command to the device, it replies back. This part works. What's strange is that I've noticed that its replies triggers another transmission from DM365 that is not in my code. This happens only if the serial port is not closed immediately after sending the data.

This is the source code of the (very simple) serialsend.c code I use. Transmission is checked on a scope connected to TX and RX line.

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc, char *argv[])
{
  char buf[] = { 0xA0, 0x0E, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x36, 0x32, 0xA5 };
  int fd;


  fd = open("/dev/ttyS1", O_RDWR);
  write(fd, buf, sizeof(buf));
  sleep(10);
  close(fd);
}

How I proceed:
# stty -F /dev/ttyS1 38400 raw
# ./serialsend
This writes once 14 bytes on the serial. The external device decodes the command and replies with 7 bytes. But on the serial line, I see some spurious bytes transmitted from DM365. Notice that if I remove the sleep and close the file descriptor, this does not happen. The problem is that if I have to transmit a long sequence of commands, the spurious data causes problems.
This is the screenshot of the scope. Above TX, below RX. As you can see, the first bytes are sent (I've checked them, all correct), then the device replies. After about 190ms, other data is sent.

If with the same setup I disconnect the RX line, then the DM365 does not receive anything, and it does not send the spurious data. It seems that the transmission is caused by the received data.

Can anyone explain this?

Thanks!

 

  • Hello,

    More info on the problem. Even with a simple "echo" command redirected to the serial port, I see the data repeating on the serial. This is what I've tried:

    1) Open 2 shell via telnet on the same board

    2) Connected TX to RX on uart 1, so I have loopback

    3) On a shell, I type "cat /dev/ttyS1"

    4) On the second shell, I type "echo test > /dev/ttyS1"

    The output of the cat command is a repeating "test" string. This is what happens:

    1) "test" is output from the serial TX

    2) Due to the loop, "test" is received on the RX line and printed from the "cat" command

    But then, and I don't understand why, another "test" is output by the serial. Due to the loopback, this causes an infinite loop.

  • Ok, found the cause and solved. This is just a very newbie question... It seems that local echo was left on from default serial settings. This caused the received data to be bounced back.