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

Re: [ns] Re: REPOST: Problems creating tcl object from within c++class



you'd better use gdb, set a breakpoint inside your c++ handler code and
see why it returns an error code back to otcl.

On Thu, 15 Feb 2001, Tulius Lima wrote:

> Hi,
> 
> 
>         I am still trying to call a tcl object from c++, but I still
> haven't got any success at it.
>         I tried to call tcl.eval(...) but the simulator crashed.
>         I guess that the tcl object was not properly initialized.
> 
> 
>         Any sugestions?
>         Tulius Lima
> 
> * error message -----
> ns: _o17 send-probe-pkts-to 14 3000 0 4000:
>     (_o17 cmd line 1)
>     invoked from within
> "_o17 cmd send-probe-pkts-to 14 3000 0 4000"
>     invoked from within
> "catch "$self cmd $args" ret"
>     (procedure "_o17" line 2)
>     (SplitObject unknown line 2)
>     invoked from within
> "_o17 send-probe-pkts-to 14 3000 0 4000"
> ----- error message *
> 
> 
> * c++ code ----------
> int MPLSAddressClassifier::sendProbePkts(int index)
> {
>   Tcl& tcl = Tcl::instance();
> 
>   for(int i = 1; i < no_probe_pkts_; i++)
>   {
>     char out[100];
> 
>     // get routing information
>     // informacao de IDA
>     int FEC    = RT_.Entry_[index].fec_;
>     int LSPid  = RT_.Entry_[index].LSPid_;
> 
>     // round-trip information
>     int vFEC   = RT_.Entry_[index].vfec_;
>     int vLSPid = RT_.Entry_[index].vLSPid_;
> 
> 
>     // Prepare the output to the Tcl interpreter. Calculate the round
>     // trip time
>     sprintf(out, "%s send-probe-pkts-to %d %d %d %d",
>      name(),
>      FEC,
>      LSPid,
>      vFEC,
>      vLSPid);
>     tcl.eval(out);
> 
>     char *result = tcl.result();
>     if (atoi(result) != 1)
>       printf("******* erro no tcl.eval(...)");
>   } // FOR
> } // end - sendProbePkts()
> ----------------- c++ code
> 
> * tcl initialization code ---------\
> MplsNode instproc te-attach-egress {egress} {
>     set ns [Simulator instance]
> 
>     $self instvar ping_
> 
>     set pong_ [$egress get-ping-agent]
> 
>     $ns connect $ping_ $pong_
> }
> 
> 
> 
> ----- tcl initialization code-----*
> 
> 
>