This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fcflush issue


Hi, I have found a problem with the tcflush function
within ecos. I may be missing something in my
understanding but:

The tcflush function should clear out any unread
messages from a serial termos input, however it does
no manage to get as far as that. I have looked through
the mailing list and cannot find any known
problems/fixes.

Looking at tcflash in
io/serial/current/src/common/termios.c

        // fallthrough
    case TCIFLUSH:
        ret = fp->f_ops->fo_getinfo( fp,
                                    
CYG_IO_GET_CONFIG_SERIAL_INPUT_FLUSH,
                                     NULL, 0 );

The following code is from
io/fileio/current/src/devfs.cpp

static int dev_fo_getinfo   (struct CYG_FILE_TAG *fp,
int key, void *buf, int len )
{
    Cyg_ErrNo err = 0;
    cyg_uint32 ll = len;
    
    err = cyg_io_get_config(
(cyg_io_handle_t)fp->f_data, key, buf, &ll );
    
    return -err;
}

And in io/common/current/src/iosys.c:

Cyg_ErrNo
cyg_io_get_config(cyg_io_handle_t handle, cyg_uint32
key, void *buf, cyg_uint32 *len)
{
    cyg_devtab_entry_t *t = (cyg_devtab_entry_t
*)handle;
    // Validate request
    if (!t->handlers->get_config) {
        return -EDEVNOSUPP;
    }
    // Special check.  If length is zero, this just
verifies that the
    // 'get_config' method exists for the given
device.
    if (NULL != len && 0 == *len) {
        return ENOERR;
    }
    return t->handlers->get_config(handle, key, buf,
len);
}

The cyg_io_get_config function in iosys.c is checking
if len is null, if is not null it checks the value
pointed to by len, if this is zero it returns.

The dev_fo_getinfo function passes a pointer to "ll"
even if len is 0. This means that when tcflash runs,
dev_fo_getinfo calls cyg_io_get_config with a non-null
len but with a length of 0. The cyg_io_get_config
function returns with a ENOERR error, and the serial
buffer is not cleared.

Having a quick look through, the solution I can see is
to rewrite dev_fo_getinfo:

static int dev_fo_getinfo   (struct CYG_FILE_TAG *fp,
int key, void *buf, int len )
{
    Cyg_ErrNo err = 0;
    cyg_uint32 ll = len;
    cyg_uint32 *pll = null;
    
    if (len != 0)
        pll = ≪

    err = cyg_io_get_config(
(cyg_io_handle_t)fp->f_data, key, buf, pll );
    
    return -err;
}

Does this look like a solution, or am I doing
something wrong? If it looks ok, I will create a
patch?
 


      ___________________________________________________________
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/ 


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]