UART4 read in pthread not working

I tried the transmit and read in one thread, ie main(), the problem I notices is that after my transmit bytes (3 bytes), the read is able to read in the echo from the uart device attached to Beaglebone, then the process terminated where the terminal seemingly waiting for input uart message. Noted that, the uart device echo each byte received.

As I use command: ps ax | grep readComm in another terminal, and it only shows

2179 pts/1 S+ 0:00 grep readComm

where I know the process readComm has terminated.

I’m wondering, can uart in beaglebone support full duplex? Because if the device does not echo byte, the uart read is normal.

I’m wondering, can uart in beaglebone support full duplex? Because if the device does not echo byte, the uart read is normal.

I think that realistically. Nothing in linux is full duplex - period. You can only be doing one thing at one point in time. However, why don’t you show us your code. Maybe someone can spot something you do not realize is happening.

I have this same sort of problem with UART4. A Skywire cellular cape lite(from Nimbelink) uses UART4 to communicate with the beaglebone. I’m not able to receive ATmd responses. I know it is sending because when I minicom to UART4 I see the AT cmd echoed on minicom and the OK response as well. However I dont see the OK response in the application. Here’s my init, transmit, receive (all in one C++ class) and main =>

UART_devices::UART_devices(unsigned int bus) {
this->file = -1;
this->bus = bus;
//this->recvAvailable = false;
this->openUart();
}

int UART_devices::openUart(void) {
std::string name;
struct termios newOpts, oldOpts;

if (this->bus == 5)
name = BBG_UART_5;
else if (this->bus == 4)
name = BBG_UART_4;

if ((this->file = open(name.c_str(), O_RDWR | O_NOCTTY | O_NDELAY)) < 0) {
perror("\r\nUART: Failed to open the file");
return -1;
}

tcgetattr(this->file, &oldOpts); //save current port settings
bzero(&newOpts, sizeof(newOpts)); //clr struct for new port settings

// Set up the communications options:
// 115200 baud, 8-bit, enable receiver, no modem control lines

newOpts.c_cflag = B115200 | CS8 | CREAD | CLOCAL;
newOpts.c_iflag = IGNPAR | ICRNL; //ignore partity errors
newOpts.c_oflag = 0; //raw output
newOpts.c_lflag = 0; //non-canonical input

newOpts.c_cflag = (newOpts.c_cflag & ~CSIZE) | CS8; // 8-bit chars
// disable IGNBRK for mismatched speed tests; otherwise receive break
// as \000 chars
newOpts.c_iflag &= ~IGNBRK; // disable break processing
newOpts.c_lflag = 0; // no signaling chars, no echo,
// no canonical processing
newOpts.c_oflag = 0; // no remapping, no delays
newOpts.c_cc[VMIN] = 0; // read doesn’t block
newOpts.c_cc[VTIME] = 5; // 0.5 seconds read timeout

newOpts.c_iflag &= ~(IXON | IXOFF | IXANY); // shut off xon/xoff ctrl

newOpts.c_cflag |= (CLOCAL | CREAD);// ignore modem controls,
// enable reading
newOpts.c_cflag &= ~(PARENB | PARODD); // shut off parity
//newOpts.c_cflag |= parity;
newOpts.c_cflag &= ~CSTOPB;
newOpts.c_cflag &= ~CRTSCTS;

//init ctrl xters
newOpts.c_cc[VINTR] = 0; //ctrl c
newOpts.c_cc[VQUIT] = 0; //‘ctrl-’
newOpts.c_cc[VERASE] = 0; //del
newOpts.c_cc[VKILL] = 0; //@
newOpts.c_cc[VEOF] = 4; //ctrl d
newOpts.c_cc[VTIME] = 0; //inter-xter timer unused - 0
newOpts.c_cc[VMIN] = 1; //blocking read until 1 xter arrives - 1
newOpts.c_cc[VSWTC] = 0; //’\0’
newOpts.c_cc[VSTART] = 0; //ctrl q
newOpts.c_cc[VSTOP] = 0; //ctrl s
newOpts.c_cc[VSUSP] = 0; //ctrl z
newOpts.c_cc[VEOL] = 0; //’\0’
newOpts.c_cc[VREPRINT] = 0; //ctrl r
newOpts.c_cc[VDISCARD] = 0; //ctrl u
newOpts.c_cc[VWERASE] = 0; //ctrl w
newOpts.c_cc[VLNEXT] = 0; //ctrl v
newOpts.c_cc[VEOL2] = 0; //’\0’

tcflush(this->file, TCIFLUSH); //discard file information not transmitted
tcsetattr(this->file, TCSANOW, &newOpts); //changes occur immmediately

return 0;
}

int UART_devices::transmitData(void)
{
int count;

if ((count = write(this->file, &this->tranData, this->tranSize)) < 0)
{
perror("\r\nFailed to write to the output");
return -1;
}

return 0;
}

int UART_devices::receiveData(void)
{
int count = 0;

count = read(this->file, (void*)this->recvData, 100);
this->recvData[100] = 0;
this->recvSize = count;

return 0;

}