Assign a CDL value to TCL variable.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Assign a CDL value to TCL variable.

Ilija Kocho [Илија Кочо]
Hi colleagues

Is there a way to assign a value of CDL option/component to a TCL
variable. something equivalent to:

    cdl_option CYGFOO {
        flavor data
        calculated 5
    }

  set cygbar some_function(CYGFOO)
# Here cygbar == 5

Ilija


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

Reply | Threaded
Open this post in threaded view
|

Re: Assign a CDL value to TCL variable.

Sergei Gavrikov-4
On Sun, 8 Jul 2012, Ilija Kocho wrote:

> Hi colleagues
>
> Is there a way to assign a value of CDL option/component to a TCL
> variable. something equivalent to:
>
>     cdl_option CYGFOO {
>         flavor data
>         calculated 5
>     }
>
>   set cygbar some_function(CYGFOO)
> # Here cygbar == 5

Hi Ilija

Would not you use TCL's ``set'' command for that? E.g.

  cdl_package CYGPKG_FOO {
      cdl_option CYGGLO_FOOBAR {
          flavor data
          calculated [set ::foobar 5]
      }
  }

In such a case you'll find in pkgconf/foo.h

  #define CYGGLO_FOOBAR 5
  #define CYGGLO_FOOBAR_5

Sure that global TCL variable ``foobar'' will be set to 5 too.

HTH

Sergei


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

Reply | Threaded
Open this post in threaded view
|

Re: Assign a CDL value to TCL variable.

Ilija Kocho [Илија Кочо]
On 08.07.2012 22:56, Sergei Gavrikov wrote:

Thanks Sergei, but that's not what I need. I heed to assign some Tcl
variable with the value of some CDL option.

Ilija



> On Sun, 8 Jul 2012, Ilija Kocho wrote:
>
>> Hi colleagues
>>
>> Is there a way to assign a value of CDL option/component to a TCL
>> variable. something equivalent to:
>>
>>     cdl_option CYGFOO {
>>         flavor data
>>         calculated 5
>>     }
>>
>>   set cygbar some_function(CYGFOO)
>> # Here cygbar == 5
> Hi Ilija
>
> Would not you use TCL's ``set'' command for that? E.g.
>
>   cdl_package CYGPKG_FOO {
>       cdl_option CYGGLO_FOOBAR {
>           flavor data
>           calculated [set ::foobar 5]
>       }
>   }
>
> In such a case you'll find in pkgconf/foo.h
>
>   #define CYGGLO_FOOBAR 5
>   #define CYGGLO_FOOBAR_5
>
> Sure that global TCL variable ``foobar'' will be set to 5 too.
>
> HTH
>
> Sergei
>


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

Reply | Threaded
Open this post in threaded view
|

Re: Assign a CDL value to TCL variable.

Sergei Gavrikov-4
On Sun, 8 Jul 2012, Ilija Kocho wrote:

> On 08.07.2012 22:56, Sergei Gavrikov wrote:
>
> Thanks Sergei, but that's not what I need. I heed to assign some Tcl
> variable with the value of some CDL option.

AFAIK, eCos CDL library `libcdl' does not provide such an ability (it
does not provide a binding the CDL instances with the Tcl ones).  But,
if you looking for a read-only access to CYG* values via Tcl it can be
done in Tcl. I've got a few lines in Tcl to get something likes below

For CDL

  # foo.cdl --
  cdl_package CYGPKG_FOO {
     display "Foo package"

     cdl_option CYGDAT_BAR {
        display "Bar option"
        flavor boolean
        default_value 1
     }
  }

it provides an access via Tcl namespaces (not nested)

  % CYGPKG_FOO::display
  Foo package
  % puts [GYGDAT_BAR::flavor]
  boolean

YA access via Tcl global variables

  % set CYGDAT_BAR
  1

or that can be used as simple CDL cheker/dumper

  % source cdl_dump.tcl
  % source ecos.ecc
  % set CYG_HAL_STARTUP
  ROM

However, I have no idea how to use that for your needs.  If I understand
correctly the CDL files source itself only once by CT or ecosconfig, so
it looks like static RO access, I do not see any benefits for such a
post processor in Tcl inside CDL sources. But it is possible. If it can
be useful for you I can attach that code (if a fact that is just a demo
snippet, how you would process CDL options).

If you looking for a real binding for the CDL CYG* instances I afraid
that there is only one way to get it, that is to investigate in eCos CDL
library.

Sergei

> Ilija
>
>
>
> > On Sun, 8 Jul 2012, Ilija Kocho wrote:
> >
> >> Hi colleagues
> >>
> >> Is there a way to assign a value of CDL option/component to a TCL
> >> variable. something equivalent to:
> >>
> >>     cdl_option CYGFOO {
> >>         flavor data
> >>         calculated 5
> >>     }
> >>
> >>   set cygbar some_function(CYGFOO)
> >> # Here cygbar == 5
> > Hi Ilija
> >
> > Would not you use TCL's ``set'' command for that? E.g.
> >
> >   cdl_package CYGPKG_FOO {
> >       cdl_option CYGGLO_FOOBAR {
> >           flavor data
> >           calculated [set ::foobar 5]
> >       }
> >   }
> >
> > In such a case you'll find in pkgconf/foo.h
> >
> >   #define CYGGLO_FOOBAR 5
> >   #define CYGGLO_FOOBAR_5
> >
> > Sure that global TCL variable ``foobar'' will be set to 5 too.
> >
> > HTH
> >
> > Sergei
> >
>

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