g_io_channel too slow on linux
- From: Luis Ariel Lecca <ariel_xxii yahoo com ar>
- To: gtk-app-devel-list gnome org
- Subject: g_io_channel too slow on linux
- Date: Tue, 5 Aug 2008 07:33:00 -0700 (PDT)
Hello, please take a moment to read this. I will appreciate any help.
I have a gtk application that runs on linux and win32.
I writing on a serial display but on linux the com flushes too slow while on win32
seems ok.
I test it the display with the hyperterminal and didnt see any problem with it.
I test it with the application (under win32) and didnt see any problem on it neither.
I used setserial to configure my linux com properly, and I made an struct termios configuration too
like below, but I see how the serial com write the data very slowly.
When I quit from main loop, the application wait for com flushes the data, since the com is handle by the OS.
Have You any idea about how to solve this ?
Thank You
void ttyS_config( void )
{
struct termios oldtio;
struct termios newtio;
gint S32dev = 0;
guchar data[16];
S32dev = open( "/dev/ttyS2", O_RDWR | O_NOCTTY /*| O_NDELAY*/ | O_NONBLOCK );
if( S32dev >= 0 )
{
memset( &oldtio, 0x00, sizeof(oldtio) );
memset( &newtio, 0x00, sizeof(newtio) );
tcgetattr( S32dev,&oldtio );
fcntl( S32dev, F_SETFL, FNDELAY/*FASYNC*/ );
newtio.c_cflag = B9600 | CS8 | CLOCAL | CREAD;
newtio.c_cflag &= (~PARENB);
newtio.c_cflag &= (~CSTOPB);
newtio.c_cflag &= (~CRTSCTS);
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
newtio.c_lflag &= ~(ICANON|ECHO|ECHOE|ISIG);
newtio.c_cc[VMIN] = 0;
newtio.c_cc[VTIME] = 0;
tcflush( S32dev, TCIFLUSH );
tcsetattr( S32dev, TCSANOW, &newtio );
sprintf( data, "%s", "Starting..." );
write( S32dev, data, strlen(data) );
close(S32dev);
}
else
{
perror( "/dev/ttyS2" );
exit(-1);
}
return;
}
/*********************************************/
#ifdef G_OS_WIN32
gchar* C8pfile = "\\\\.\\COM2";
#else
gchar* C8pfile = "/dev/ttyS2";
#endif
GIOFlags giof_flags = G_IO_FLAG_NONBLOCK;
gint8 S8retval = -1;
#ifdef __PATCH_TEST_CHANGE_TERMIOS_CFG_FIRST__
ttyS_config();
#endif
gioch_file = g_io_channel_new_file ( C8pfile, "r+", NULL );
giof_flags |= g_io_channel_get_flags( gioch_file );
g_io_channel_set_flags( gioch_file, giof_flags, NULL );
g_io_channel_set_encoding( gioch_file, NULL, NULL );
g_io_channel_seek_position( gioch_file, 0, G_SEEK_SET, NULL );
/*********************************************/
____________________________________________________________________________________
¡Buscá desde tu celular!
Yahoo! oneSEARCH ahora está en Claro
http://ar.mobile.yahoo.com/onesearch
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]