[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Couldn't activate software flow control ?




Hello,

I have a problem to activate the software flow control on the devboard 
lx,  my function works fine on the Debian host but not in the 
board...Data continue to send by the bord when receiving XOFF ...
Thank you for any suggestion.
Nabil


I use this to open the serial port  (CRTSCTS  seem to be not defined in 
the devboard environment.?)

*************************************************************************
         #include    <stdlib.h>
        #include    <stdio.h>
        #include    <time.h>
        #include    <sys/times.h>
        #include    <sys/types.h>
        #include    <sys/select.h>
        #include    <sys/socket.h>
        #include    <errno.h>
        #include    <arpa/inet.h>
        #include    <netinet/in.h>
        #include    <unistd.h>
        #include    <pthread.h>
        #include    <termios.h>
        #include    <fcntl.h>


int CCSP_FSerialOpen ( WORD port, HANDLE *phd )
{
    int     error;
    char    buffer[ 64 ];
    int     handle;
    struct termios option;


    error    = CCS_Ok;
    *phd    = 0;
    memset( buffer, 0, sizeof(buffer));
    strncpy( buffer, "/dev/ttyS0", sizeof(buffer)-1);

    handle = open( buffer, O_RDWR | O_NOCTTY | O_NDELAY);
    if (handle == -1)
    {
        return( -1 );
    }

    // Positionner vitesse port
    error = tcgetattr( handle, &option);
    if( error == -1)
    {
        close(handle);
        return( -1 );
    }

    cfsetispeed( &option, B38400);
    cfsetospeed( &option, B38400);

    // mode non canonic & suppression echo
    option.c_lflag    &= ~(ICANON | ECHO | ECHOE | ISIG | ECHOK | ECHONL 
| NOFLSH | IEXTEN | TOSTOP);

    option.c_cflag    |= (CLOCAL | CREAD );
    option.c_cflag    &= ~PARENB;
    option.c_cflag    &= ~CSTOPB;
    option.c_cflag    &= ~CSIZE;
    option.c_cflag    |= CS8;


//    option.c_cflag    &= ~( CRTSCTS );
    option.c_iflag    &= ~( IXANY );
    option.c_iflag    |= (IXON | IXOFF);

    option.c_oflag    &= ~(OPOST);


    option.c_cc[ VSTART ]    = 17;
    option.c_cc[ VSTOP ]    = 19;
    option.c_cc[ VMIN ]    = 0;
    option.c_cc[ VTIME ]    = 0;

    // sauvegarder parametres
    error = tcsetattr( handle, TCSANOW, &option );
    if( error == -1)
    {
        close(handle);
        return( -1 );
    }

    // flush les buffers
    error = tcflush( handle, TCIOFLUSH );
    if( error == -1)
    {
        close(handle);
        return( -1 );
    }

    // initialiser le handler liaison
    *phd    = handle;
    return (error);
}

***************************************************************************************

Nabil DAHER wrote:

> Hi
>
> I  try  to activate software controle flox (XON/XOFF) on the serial 
> port (dev/ttyS0) but data continue out when the devborad_lx receive XOFF..
> I do this activation with termios ( I get options with tcgetattr (fd, 
> options), and then set options.iflag |=  IXON | IXOFF | IXANY  and 
> then tcsetattr (fd, TCSANOW, &options )
>
> Any suggestion ? or sample code to do this.
>
> Thanks
> Nabil
>
>>  
>>
>