public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] problem with termios: tcgetattr
@ 2001-06-11  8:10 Franck MAMALET FT-R&D DIH/OCF
  2001-06-11 13:05 ` Jonathan Larmour
  0 siblings, 1 reply; 8+ messages in thread
From: Franck MAMALET FT-R&D DIH/OCF @ 2001-06-11  8:10 UTC (permalink / raw)
  To: ecos-discuss

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1709 bytes --]

Hi,
I'm trying to port a Linux program,  on eCos and I have some trouble
with termios function:  tcgetattr.
This program is opening a serial driver with open('/dev/ser2",.....)
which seems to be OK.
To configure the terminal, it calls   tcgetattr(fd, &t),
but generates an error "tcgetattr wrong argument"
I had a look to functions called by tcgetattr :
tcgetattr (fildes=3, termios_p=0x4f738) at //e/ecos/REDHAT~1/eCos/packages/io/serial/current/src/common/termios.c:160
    calls
        ret = fp->f_ops->fo_getinfo(
fp, CYG_IO_GET_CONFIG_TERMIOS, termios_p,  len);
    which for a device is mapped to
        dev_fo_getinfo (fp=0x4d3e8,
key=1024, buf=0x4f738, len=40)
     and this function calls (devfs.cxx l452)
         err = cyg_io_get_config(
(cyg_io_handle_t)fp->f_data, key, buf, &ll );
     then this function calls   
(iosys.c l257)
        t->handlers->get_config(handle,
key, buf, len);
    which is mapped for a serial device to
        serial_get_config (handle=0x3f12c,
key=1024, xbuf=0x4f6fc, len=0x4f738)
It seems that the problem is about the "key", because serial_get_config
only tests CYG_IO_GET_CONFIG_SERIAL_xxx which differ from CYG_IO_GET_CONFIG_TERMIOS,
and so generates an error.
Could anyone help me in this regard.
Thanks in advance.
Regards
Franck.
PS: my configuration is eCos 1.3.1 on an EDB7212 platform.
 
 
 
 
 
 
-- 
& france telecom 
Mamalet Franck
FTR&D DIH/OCF
Tél  : 04 76 76 45 71   Fax : 04 76 90 34 43
franck.mamalet@rd.francetelecom.fr
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] problem with termios: tcgetattr
  2001-06-11  8:10 [ECOS] problem with termios: tcgetattr Franck MAMALET FT-R&D DIH/OCF
@ 2001-06-11 13:05 ` Jonathan Larmour
  2001-06-13  2:57   ` Franck MAMALET FT-R&D DIH/OCF
  2001-06-18  7:23   ` [ECOS] How to use cyg_io_select Franck MAMALET FT-R&D DIH/OCF
  0 siblings, 2 replies; 8+ messages in thread
From: Jonathan Larmour @ 2001-06-11 13:05 UTC (permalink / raw)
  To: Franck MAMALET FT-R&D DIH/OCF; +Cc: ecos-discuss

Franck MAMALET FT-R&D DIH/OCF wrote:
> 
> Hi,
> 
> I'm trying to port a Linux program,  on eCos and I have some trouble with
> termios function:  tcgetattr.
> This program is opening a serial driver with open('/dev/ser2",.....)
> which seems to be OK.
> To configure the terminal, it calls   tcgetattr(fd, &t), but generates an
> error "tcgetattr wrong argument"
> 
> I had a look to functions called by tcgetattr :
> tcgetattr (fildes=3, termios_p=0x4f738) at
> //e/ecos/REDHAT~1/eCos/packages/io/serial/current/src/common/termios.c:160
> 
>     calls
>         ret = fp->f_ops->fo_getinfo( fp, CYG_IO_GET_CONFIG_TERMIOS,
> termios_p,  len);
>     which for a device is mapped to
>         dev_fo_getinfo (fp=0x4d3e8, key=1024, buf=0x4f738, len=40)
>      and this function calls (devfs.cxx l452)
>          err = cyg_io_get_config( (cyg_io_handle_t)fp->f_data, key, buf,
> &ll );
>      then this function calls    (iosys.c l257)
>         t->handlers->get_config(handle, key, buf, len);
>     which is mapped for a serial device to
>         serial_get_config (handle=0x3f12c, key=1024, xbuf=0x4f6fc,
> len=0x4f738)
> 
> It seems that the problem is about the "key", because serial_get_config
> only tests CYG_IO_GET_CONFIG_SERIAL_xxx which differ from
> CYG_IO_GET_CONFIG_TERMIOS, and so generates an error.

It should have gone to termios_get_config in
io/serial/curent/src/common/termiostty.c

Did you enable CYGPKG_IO_SERIAL_TERMIOS_TERMIOS2 in your configuration?

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine
Come to the Red Hat TechWorld open source conference in Brussels!
Keynotes, techie talks and exhibitions    http://www.redhat-techworld.com/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] problem with termios: tcgetattr
  2001-06-11 13:05 ` Jonathan Larmour
@ 2001-06-13  2:57   ` Franck MAMALET FT-R&D DIH/OCF
  2001-06-13  5:31     ` Jonathan Larmour
  2001-06-18  7:23   ` [ECOS] How to use cyg_io_select Franck MAMALET FT-R&D DIH/OCF
  1 sibling, 1 reply; 8+ messages in thread
From: Franck MAMALET FT-R&D DIH/OCF @ 2001-06-13  2:57 UTC (permalink / raw)
  To: Jonathan Larmour; +Cc: ecos-discuss

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 714 bytes --]

Jonathan Larmour wrote:
 
It should have gone to termios_get_config in
io/serial/curent/src/common/termiostty.c
Did you enable CYGPKG_IO_SERIAL_TERMIOS_TERMIOS2 in your configuration?
 
 
I did now, and it still doesn't work when I try to open /dev/ser2, but
it does with /dev/termios2. What are the differences between them?
Besides, I read your discussion with Trenton D. Adams about " Simple
serial program" : Could you explain me why open(/dev/ser1,..)
doesn't fail when   this UART is used for GDB connection?
Thanks,
Franck.
 
-- 
& france telecom 
Mamalet Franck
FTR&D DIH/OCF
Tél  : 04 76 76 45 71   Fax : 04 76 90 34 43
franck.mamalet@rd.francetelecom.fr
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] problem with termios: tcgetattr
  2001-06-13  2:57   ` Franck MAMALET FT-R&D DIH/OCF
@ 2001-06-13  5:31     ` Jonathan Larmour
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Larmour @ 2001-06-13  5:31 UTC (permalink / raw)
  To: Franck MAMALET FT-R&D DIH/OCF; +Cc: ecos-discuss

Franck MAMALET FT-R&D DIH/OCF wrote:
> 
> Jonathan Larmour wrote:
> 
> >
> >
> > It should have gone to termios_get_config in
> > io/serial/curent/src/common/termiostty.c
> >
> > Did you enable CYGPKG_IO_SERIAL_TERMIOS_TERMIOS2 in your configuration?
> 
> I did now, and it still doesn't work when I try to open /dev/ser2, but it
> does with /dev/termios2. What are the differences between them?

Doh, for some reason I didn't notice that. and that was the most obvious
problem. The /dev/termios devices are layered on top of the /dev/ser
devices which are effectively the "raw" devices. Therefore for termios
support, use the /dev/termios devices.
 
> Besides, I read your discussion with Trenton D. Adams about " Simple
> serial program" : Could you explain me why open(/dev/ser1,..) doesn't
> fail when   this UART is used for GDB connection?

There is no locking. We expect you to do the right thing :-).

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine
Come to the Red Hat TechWorld open source conference in Brussels!
Keynotes, techie talks and exhibitions    http://www.redhat-techworld.com/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ECOS] How to use cyg_io_select
  2001-06-11 13:05 ` Jonathan Larmour
  2001-06-13  2:57   ` Franck MAMALET FT-R&D DIH/OCF
@ 2001-06-18  7:23   ` Franck MAMALET FT-R&D DIH/OCF
  2001-06-18 10:51     ` Jonathan Larmour
  1 sibling, 1 reply; 8+ messages in thread
From: Franck MAMALET FT-R&D DIH/OCF @ 2001-06-18  7:23 UTC (permalink / raw)
  To: egcs; +Cc: ecos-discuss

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 826 bytes --]

Hi,
I would like to use a non-blocking serial read with wake-up capabilities.
I have selected  CYGPKG_IO_SERIAL_SELECT_SUPPORT in my configuration.
The function cyg_selrecord() (called by serial_select called by cyg_io_select)
stores the thread number in a "sip" structure.
And serial_rcv_char calls cyg_selwakeup  tests the sip structure
when rx buffer going from empty to non-empty. However this function broadcast
a CYG_COND_VARIABLE called selwait .
I guess I don't use these functions in the right way, because my thread
is never linked to selwait and will never be woken-up.
Can anyone explain to me how it should work? and how to use it?
Thanks,
Franck.
 
-- 
& france telecom 
Mamalet Franck
FTR&D DIH/OCF
Tél  : 04 76 76 45 71   Fax : 04 76 90 34 43
franck.mamalet@rd.francetelecom.fr
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] How to use cyg_io_select
  2001-06-18  7:23   ` [ECOS] How to use cyg_io_select Franck MAMALET FT-R&D DIH/OCF
@ 2001-06-18 10:51     ` Jonathan Larmour
  2001-06-19  1:28       ` Franck MAMALET FT-R&D DIH/OCF
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Larmour @ 2001-06-18 10:51 UTC (permalink / raw)
  To: Franck MAMALET FT-R&D DIH/OCF; +Cc: ecos-discuss

Franck MAMALET FT-R&D DIH/OCF wrote:
> 
> Hi,
> I would like to use a non-blocking serial read with wake-up capabilities.
> 
> I have selected  CYGPKG_IO_SERIAL_SELECT_SUPPORT in my configuration.
> 
> The function cyg_selrecord() (called by serial_select called by
> cyg_io_select) stores the thread number in a "sip" structure.
> And serial_rcv_char calls cyg_selwakeup  tests the sip structure when rx
> buffer going from empty to non-empty. However this function broadcast a
> CYG_COND_VARIABLE called selwait.
> I guess I don't use these functions in the right way, because my thread
> is never linked to selwait and will never be woken-up.
> 
> Can anyone explain to me how it should work? and how to use it?

I'm not entirely clear on your problem but anyway. For the thread to wake
up, it must have been blocked waiting in select(). That means having opened
and used the serial devices using open/read/write, and not cyg_io.
cyg_io_select() is the select file operation, it isn't actually an
equivalent of select(). 

But since you say you want a non-blocking read, I don't know quite why
there would be anything that needed waking up!

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine
Come to the Red Hat TechWorld open source conference in Brussels!
Keynotes, techie talks and exhibitions    http://www.redhat-techworld.com/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] How to use cyg_io_select
  2001-06-18 10:51     ` Jonathan Larmour
@ 2001-06-19  1:28       ` Franck MAMALET FT-R&D DIH/OCF
  2001-06-19  3:38         ` Jonathan Larmour
  0 siblings, 1 reply; 8+ messages in thread
From: Franck MAMALET FT-R&D DIH/OCF @ 2001-06-19  1:28 UTC (permalink / raw)
  To: Jonathan Larmour; +Cc: ecos-discuss

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1084 bytes --]

 
I'm not entirely clear on your problem but anyway.
  But since you say you want a non-blocking
read, I don't know quite why
  there would be anything that needed waking up!

Sory it wasn't clear, hope this will be better:
     I want a blocking read when no data is available,
and a non-blocking read as regards to the number of byte to read (I want
to be woken up when I can read 1 or more byte, and I don't want to call
read once and get all bytes available).
For the thread to wake
up, it must have been blocked waiting in select(). That means having
opened
and used the serial devices using open/read/write, and not cyg_io.
cyg_io_select() is the select file operation, it isn't actually an
equivalent of select().
Does this mean I need Posix Package to be able to wake-up my thread (the
file package/io/fileio/current/test/select.c begins with "POSIX package
needed to run test")?
Thanks,
Franck.
 
-- 
& france telecom 
Mamalet Franck
FTR&D DIH/OCF
Tél  : 04 76 76 45 71   Fax : 04 76 90 34 43
franck.mamalet@rd.francetelecom.fr
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] How to use cyg_io_select
  2001-06-19  1:28       ` Franck MAMALET FT-R&D DIH/OCF
@ 2001-06-19  3:38         ` Jonathan Larmour
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Larmour @ 2001-06-19  3:38 UTC (permalink / raw)
  To: Franck MAMALET FT-R&D DIH/OCF; +Cc: ecos-discuss

Franck MAMALET FT-R&D DIH/OCF wrote:
> 
> >
> > I'm not entirely clear on your problem but anyway.
> >
> >>   But since you say you want a non-blocking read, I don't know quite
> >> why
> >>   there would be anything that needed waking up!
> >
> Sory it wasn't clear, hope this will be better:
>      I want a blocking read when no data is available, and a non-blocking
> read as regards to the number of byte to read (I want to be woken up when
> I can read 1 or more byte, and I don't want to call read once and get all
> bytes available).

Ah so you intend to use select to do the "blocking read". Fair enough. The
answer is then as I said to use open/read/write to access the devices,
rather than the cyg_io_* functions. That allows you to use select.
 
> > For the thread to wake
> > up, it must have been blocked waiting in select(). That means having
> > opened
> > and used the serial devices using open/read/write, and not cyg_io.
> > cyg_io_select() is the select file operation, it isn't actually an
> > equivalent of select().
> 
> Does this mean I need Posix Package to be able to wake-up my thread (the
> file package/io/fileio/current/test/select.c begins with "POSIX package
> needed to run test")?

As it says, you need the POSIX package to run the *test*.

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine
Come to the Red Hat TechWorld open source conference in Brussels!
Keynotes, techie talks and exhibitions    http://www.redhat-techworld.com/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-06-19  3:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-11  8:10 [ECOS] problem with termios: tcgetattr Franck MAMALET FT-R&D DIH/OCF
2001-06-11 13:05 ` Jonathan Larmour
2001-06-13  2:57   ` Franck MAMALET FT-R&D DIH/OCF
2001-06-13  5:31     ` Jonathan Larmour
2001-06-18  7:23   ` [ECOS] How to use cyg_io_select Franck MAMALET FT-R&D DIH/OCF
2001-06-18 10:51     ` Jonathan Larmour
2001-06-19  1:28       ` Franck MAMALET FT-R&D DIH/OCF
2001-06-19  3:38         ` Jonathan Larmour

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).