View topic - reading from uart causes transmit

reading from uart causes transmit

anything that doesn't fit to other groups.

reading from uart causes transmit

Postby davy » Mon Apr 12, 2010 10:25 am

QNX 6.4.1 on BeagleBoard

I'm trying to read from UART2 using the code below but every time it reads it transmit a character :?. Am I reading incorrectly?
Code: Select all
int main(int argc, char *argv[]) {
   unsigned char readbuffer[80];

   fd = open ( "/dev/ser2", O_RDWR );

   while (1) {
           read(fd, readbuffer, sizeof(readbuffer));
      printf("%s\n", readbuffer);
      sleep(3);
   }

   close (fd);
   return EXIT_SUCCESS;
}
davy
New Member
 
Posts: 5
Joined: Sun Mar 28, 2010 11:12 am

RE: reading from uart causes transmit

Postby mario » Mon Apr 12, 2010 1:14 pm

what you are doing is basically correct, although the printf is dangerous because if the string does not end with a null or if no string is receveid at all the printf may go crasy.

I don't see anything in there that I could use to explain why something would get transmitted.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

RE: reading from uart causes transmit

Postby davy » Mon Apr 12, 2010 6:55 pm

It is strange...

qtalk -m /dev/ser2 "reads" fine without transmitting anything.

Here is what I'm using in the build file for the drivers:

devc-seromap -e -F -b115200 -c48000000/16 0x49020000^2,74
devc-seromap -u2 -e -F -b57600 -c48000000/16 0x4806C000^2,73
davy
New Member
 
Posts: 5
Joined: Sun Mar 28, 2010 11:12 am

RE: reading from uart causes transmit

Postby mario » Mon Apr 12, 2010 7:48 pm

Use the debugger, go step by step and figure out which instruction cause transmission. Maybe that will give us a clue.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

RE: reading from uart causes transmit

Postby davy » Tue Apr 13, 2010 4:34 am

I tried using the debugger but it stops at a certain branch instruction. It's definitely the driver that's causing the transmissions.

The transmissions stop if I use raw mode instead.

bad:
devc-seromap -u2 -e -F -b57600 -c48000000/16 0x4806C000^2,73

good:
devc-seromap -u2 -F -b57600 -c48000000/16 0x4806C000^2,73 (default raw mode)

Thanks again mario.
davy
New Member
 
Posts: 5
Joined: Sun Mar 28, 2010 11:12 am

RE: reading from uart causes transmit

Postby maschoen » Tue Apr 13, 2010 5:25 am

What are the stty options before you put the line into raw mode?
maschoen
QNX Master
 
Posts: 2715
Joined: Wed Jun 25, 2003 5:18 pm


Return to General Programming

Who is online

Users browsing this forum: No registered users and 4 guests