Problem with UART2 (or at least - SOMETHING is wrong ;-) )

Hello,

I am facing the following problem: I have shortened the connections of P9.21 and P9.22. I want to sent something on the one channel, and receive on the other. (sending in lower case, receiving in upper case, but this is not the problem)

My problem is, that I get the following output back:

root@beaglebone:~/Desktop# ./up
bytes send: 12
send: hello uart!
bytes read: -1

received:
Modified received string:

`

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>

void toUpper(char *text, char *nText);

int main(int argc,char** argv)
{
struct termios tio;
int tty_fd;

unsigned char tx_buffer[] = “hello uart!”;
unsigned char modBuffer[256];
unsigned char rx_buffer[256];

// open UART4
tty_fd=open("/dev/tty2", O_RDWR | O_NONBLOCK);

// configure UART
memset(&tio,0,sizeof(tio));
tio.c_iflag=0;
tio.c_oflag=0;
tio.c_cflag=CS8|CREAD|CLOCAL;
tio.c_lflag=0;
tio.c_cc[VMIN]=1;
tio.c_cc[VTIME]=5;
tcsetattr(tty_fd,TCSANOW,&tio);
cfsetospeed(&tio,B115200); // 115200 baud
cfsetispeed(&tio,B115200); // 115200 baud

// send via serial interface
int bytes_written = write(tty_fd, &tx_buffer, sizeof(tx_buffer));
printf(“bytes send: %d\n”, bytes_written);
printf(“send: %s\n”, tx_buffer);

sleep(1); // wait one second, that everything is properly received

// receive via serial interface
int chars_read = read(tty_fd, &rx_buffer, 255);
printf(“bytes read: %d\n”, chars_read);
printf(“received: %s\n”, rx_buffer);

// modify received string to UPPERCASE
toUpper(rx_buffer, modBuffer);
printf(“Modified received string: %s\n”, modBuffer);

close(tty_fd);

return EXIT_SUCCESS;
}

// function to convert string to UPPERCASE
void toUpper(char *text, char *nText){
int i;

for(i=0; i<=strlen(text); i++){
if( (text[i] > 96 ) && (text[i] < 123) ) // is the char lower case
nText[i] = text[i] - ‘a’ + ‘A’; //make upper
else
nText[i] = text[i]; //do nothing
}
}

`

Can someone help me, where the mistake is?

Thank you
Greg