Nigel,

So it is exactly as I surmised: the app.getport() is not happeneing before app.start(), and must happen before the app.start(). You can't start the application (and its workers) until the required connections are made. Unless the underlying worker's port is "optional", which this is not, a call to getport for that external port must be made before
app.start().

Note that getPort can be called more than once - after the first time it will return the same external port object. So you could still leave the getPort call in ProcessData, but it must first be called before app.start().

Jim





On 4/16/12 6:53 PM, Merritt, Nigel (Contractor) wrote:

*UNCLASSIFIED*

Hi James, apologies, I should have been more clear - the error occurs in the call to OA::Application start (not the worker start), therefore the call to getPort is not reached. The code is below, it does not get past the "app->start();".

OA::Application *app = foos.Setup(argc, argv); // XML string defined and applied here.

fprintf(stderr, "       ################# Application initialising...\n");
app->initialize();

fprintf(stderr, "Application established: containers, workers, connections all created\n");
fprintf(stderr, "Communication with the application established\n");

app->start();
fprintf(stderr, "       ################# Application started/running\n");

ProcessData(app);

app->wait();
fprintf(stderr, "       ################# Application finished\n");


void ProcessData(OA::Application *app)
{
  OA::ExternalPort &ep = app->getPort("finaldata");
  OA::ExternalBuffer *b = NULL;

  uint8_t *data;
  uint32_t length;
  uint8_t opcode;
  bool end;
  int counter = 1000;

  while (counter > 0)
  {
    if ((b = ep.getBuffer(data, length, opcode, end)))
    {
      printf("Got external buffer...\n");
      b->release();
    }

    counter--;
  }
}

   Nigel


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of [email protected]
Sent: Monday, 16 April 2012 10:09 PM
To: [email protected]
Subject: opencpi_dev Digest, Vol 24, Issue 7

Send opencpi_dev mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
http://lists.opencpi.org/listinfo.cgi/opencpi_dev-opencpi.org
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific than "Re: Contents of opencpi_dev digest..."


Today's Topics:

   1. External ports error [SEC=UNCLASSIFIED]
      (Merritt, Nigel (Contractor))
   2. Re: External ports error [SEC=UNCLASSIFIED] (James Kulp)


----------------------------------------------------------------------

Message: 1
Date: Mon, 16 Apr 2012 15:55:07 +0930
From: "Merritt, Nigel (Contractor)"
<[email protected]>
To: <[email protected]>
Subject: [opencpi_dev] External ports error [SEC=UNCLASSIFIED]
Message-ID:
<f92472a1995d1042bf9897ebfbe7221d0280e...@ednex513.dsto.defence.gov.au>

Content-Type: text/plain; charset="us-ascii"

UNCLASSIFIED

Gents,

I have set up our test system with an RCC worker (foo_generator) that continuously generates data to its output port ("dataout").

The system is set up to either:
a) Attach an external port to dataout, which is read by the application or b) Create a second worker (foo_receiver) that accepts the data through its input port ("datain").
       In this case, there is no external port.

I.e:

[foo_generator]   --(external port)--> <foo_application>
[foo_generator]   --(dataout)--> [foo_receiver]

The difference is simply a parameter to determine the string used.

I have included the relevent code below, but in summary, a) always generates a segmentation fault during the call to 'start', for the same reasons I outlined in my previous email, i.e. the PORT_NOT_CONNECTED error in OcpiRccWorker.cxx, while b) works fine.

No worker code is reached before the seg fault occurs, so I have not included the start or run code here.

====== foo_generator.xml ======
<RccImplementation controloperations="start">
<xi:include href="foo_generator_spec.xml"/> </RccImplementation>

====== foo_generator_spec.xml ======
<ComponentSpec Name="foo_generator">
<Properties>
<Property Name="numBuffers" type="ULong" Writable="true"/>
<Property Name="stopSending" type="Bool" Writable="true"/>
</Properties>
<DataInterfaceSpec Name="dataout" Producer="true">
<xi:include href="stream_protocol.xml"/>
</DataInterfaceSpec>
</ComponentSpec>


====== String used to create the system in OA::Application constructor - for a) ====== std::string fooapp("<application>");

fooapp.append("<instance worker='foo_generator'>"); fooapp.append(" <property name='stopSending' value='0'/>"); fooapp.append("</instance>");

fooapp.append("<connection>"
              " <external name='finaldata'/>"
              " <port instance='foo_generator' name='dataout'/>"
              "</connection>");

fooapp.append("</application>");


====== String used to create the system in OA::Application constructor - for b) ====== std::string fooapp("<application>");

fooapp.append("<instance worker='foo_generator'>"); fooapp.append(" <property name='stopSending' value='0'/>"); fooapp.append("</instance>"); fooapp.append("<instance worker='foo_receiver'
selection='model=="RCC"'/>");

fooapp.append("<connection>"
              " <port instance='foo_generator' name='dataout'/>"
                " <port instance='foo_receiver' name='datain'/>"
              "</connection>");

fooapp.append("</application>");

====== Text shown on error ======
Application established: containers, workers, connections all created Communication with the application established
<<=== start called here ===>>
terminate called after throwing an instance of 'OCPI::Util::EmbeddedException'
Aborted
make: *** [run] Error 134

   Nigel

IMPORTANT: This email remains the property of the Department of Defence and is subject to the jurisdiction of section 70 of the Crimes Act 1914. If you have received this email in error, you are requested to contact the sender and delete the email.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencpi.org/private.cgi/opencpi_dev-opencpi.org/attachments/20120416/3e0a68f8/attachment-0001.htm>

------------------------------

Message: 2
Date: Mon, 16 Apr 2012 08:39:17 -0400
From: James Kulp <[email protected]>
To: [email protected]
Subject: Re: [opencpi_dev] External ports error [SEC=UNCLASSIFIED]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"

Hi Nigel,

I am guessing that you have not connected the external port via the
app.getPort("finaldata") call before
issuing app.start(). Even though the xml defines the external port connection, it can't make that connection until the app actually retrieves the port using getPort, since getPort can have (optional) parameters that affect that connection.

I.e., you can't start a worker until its ports are truly ready to move data, and that can't happen until the external ports are fully "established", which means "connected to the application".

The cat_xml example is essentially what you are doing.

I made a note to clarify this in the doc, and perhaps catch/report the error at a higher level.

Let us know if this was it, or not.

Thanks,

Jim









On 4/16/12 2:25 AM, Merritt, Nigel (Contractor) wrote:
>
> *UNCLASSIFIED*
>
> Gents,
>
> I have set up our test system with an RCC worker  (foo_generator) that
> continuously generates data to its output port ("dataout").
>
> The system is set up to either:
>    a) Attach an external port to dataout, which is read by the
> application or
>    b) Create a second worker (foo_receiver) that accepts the data
> through its input port ("datain").
>        In this case, there is no external port.
>
> I.e:
>
> [foo_generator]   --(external port)--> <foo_application>
> [foo_generator]   --(dataout)--> [foo_receiver]
>
> The difference is simply a parameter to determine the string used.
>
> I have included the relevent code below, but in summary, a) always
> generates a segmentation fault during the call to 'start', for the
> same reasons I outlined in my previous email, i.e. the
> PORT_NOT_CONNECTED error in OcpiRccWorker.cxx, while b) works fine.
>
> No worker code is reached before the seg fault occurs, so I have not
> included the start or run code here.
>
> ====== foo_generator.xml ======
> <RccImplementation controloperations="start"> <xi:include
> href="foo_generator_spec.xml"/> </RccImplementation>
>
> ====== foo_generator_spec.xml ======
> <ComponentSpec Name="foo_generator">
> <Properties>
> <Property Name="numBuffers" type="ULong" Writable="true"/> <Property
> Name="stopSending" type="Bool" Writable="true"/> </Properties>
> <DataInterfaceSpec Name="dataout" Producer="true"> <xi:include
> href="stream_protocol.xml"/> </DataInterfaceSpec> </ComponentSpec>
>
>
> ====== String used to create the system in OA::Application constructor
> -*for a)*====== std::string fooapp("<application>");
>
> fooapp.append("<instance worker='foo_generator'>"); fooapp.append("
> <property name='stopSending' value='0'/>");
> fooapp.append("</instance>");
>
> fooapp.append("<connection>"
>               " <external name='finaldata'/>"
>               " <port instance='foo_generator' name='dataout'/>"
>               "</connection>");
>
> fooapp.append("</application>");
>
>
> ====== String used to create the system in OA::Application constructor
> -*for b)* ====== std::string fooapp("<application>");
>
> fooapp.append("<instance worker='foo_generator'>"); fooapp.append("
> <property name='stopSending' value='0'/>");
> fooapp.append("</instance>"); fooapp.append("<instance
> worker='foo_receiver'
> selection='model=="RCC"'/>");
>
> fooapp.append("<connection>"
>               " <port instance='foo_generator' name='dataout'/>"
>                 " <port instance='foo_receiver' name='datain'/>"
>               "</connection>");
>
> fooapp.append("</application>");
>
> ====== Text shown on error ======
> Application established: containers, workers, connections all created
> Communication with the application established <<=== start called here
> ===>> terminate called after throwing an instance of
> 'OCPI::Util::EmbeddedException'
> Aborted
> make: *** [run] Error 134
>
>    Nigel
>
> *IMPORTANT*: This email remains the property of the Department of
> Defence and is subject to the jurisdiction of section 70 of the Crimes
> Act 1914. If you have received this email in error, you are requested
> to contact the sender and delete the email.
>
>
>
> _______________________________________________
> opencpi_dev mailing list
> [email protected]
> http://lists.opencpi.org/listinfo.cgi/opencpi_dev-opencpi.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencpi.org/private.cgi/opencpi_dev-opencpi.org/attachments/20120416/396cdd2a/attachment.htm>

------------------------------

_______________________________________________
opencpi_dev mailing list
[email protected]
http://lists.opencpi.org/listinfo.cgi/opencpi_dev-opencpi.org


End of opencpi_dev Digest, Vol 24, Issue 7
******************************************

*IMPORTANT*: This email remains the property of the Department of Defence and is subject to the jurisdiction of section 70 of the Crimes Act 1914. If you have received this email in error, you are requested to contact the sender and delete the email.



_______________________________________________
opencpi_dev mailing list
[email protected]
http://lists.opencpi.org/listinfo.cgi/opencpi_dev-opencpi.org

_______________________________________________
opencpi_dev mailing list
[email protected]
http://lists.opencpi.org/listinfo.cgi/opencpi_dev-opencpi.org

Reply via email to