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;
}