I'm configuring the /dev/ttyO1 of the AM3359 with the function below. Irrespective the value put in cfsetospeed and cfsetispeed the baud rate is always 9600. Has someone seen this issue?
bool InitPortSettings(int pValidDescriptor)
{
if (m_currentSerialState != SERIAL_READY)
{
printf ("Error: Cannot initialize port settings. Invalid state.");
return false;
}
tcgetattr(pValidDescriptor,&m_oldPortSettings);
bzero(&m_newPortSettings, sizeof(m_newPortSettings));
/* Initial baudrate is 9600... If needed, change it through SetSerialSpeed() function */
if (cfsetispeed(&m_oldPortSettings, B115200) == 0)
{
__android_log_print(ANDROID_LOG_INFO,LOG_TAG,"Velocidade de entrada configurada!");
}
if (cfsetospeed(&m_oldPortSettings, B115200) == 0)
{
__android_log_print(ANDROID_LOG_INFO,LOG_TAG,"Velocidade de saída configurada!");
}
// Consultar aqui para detalhes http://www.easysw.com/~mike/serial/serial.html
m_oldPortSettings.c_cflag = CS8 | PARENB | CREAD | CLOCAL ;
m_oldPortSettings.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
m_oldPortSettings.c_cc[VTIME] = 2; //inter-char timer
m_oldPortSettings.c_cc[VMIN] = 0; //block until 8 chars received
m_oldPortSettings.c_oflag &= ~OPOST;
m_oldPortSettings.c_iflag |= (INPCK | ISTRIP);
if (tcflush(pValidDescriptor, TCIOFLUSH) != 0)
{
printf("Warning: Problem when flushing serial port");
}
tcsetattr(pValidDescriptor, TCSANOW, &m_oldPortSettings);
m_currentSerialState = SERIAL_INITIALIZED;
__android_log_print(ANDROID_LOG_INFO,LOG_TAG,"Porta serial configurada");
return true;
}