[nanomsg] Re: nanomsg in embedded environments

  • From: George Lambert <marchon@xxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Wed, 25 Feb 2015 11:09:35 -0500

I have not taken a look at your code yet, but

1) Have you taken into account that the naming convention for NanoMsg
is not the same is the socket platform itself?



On Wed, Feb 25, 2015 at 9:45 AM, John Carneiro <johncarneiro@xxxxxxxxxxx> wrote:
> Hello,
>
> I've been for a while trying to port the nanomsg code to work in our
> embedded environment.
>
> I have it compiling and running, and sending packets of data via tcp
> (verified with wireshark).
> It however fails to completely send the data using the simple pipeline.c
> example code found on the nanomsg website. In the code example node0
> (receive) is on the PC and
> node1 (sender) is on the embedded device. Straight tcp code works fine, so I
> know the connection is good.
>
> I've successfully got it working in any linux environment (ubuntu, debian,
> and beaglebone device).
>
> However our embedded device uses slightly non standard posix tcp
> implementation and I needed to change some of the nanomsg code to comply
> with it. Also, we have no pthread or
> socketpair support. We do however have MicroC/OS-2 Tasks.
> I was able to code around these to use or create equivalents in our
> environment.
>
> I was hoping someone might be able to help diagnose the issue I am having as
> I feel nanomsg would be the best fit in our environment and allow more
> flexibility than just tcp.
> It may also allow discussion to make nanomsg even more generic out of the
> box.
>
> Thanks for you time in advance and regards.
>
> The ported code as it stands now is zipped up here.
> https://www.dropbox.com/s/i8xgu5hu3lpf888/NanoMsgEmbed.zip?dl=0
>
> The zip contains these files:
>
> NanoMsg.zip - ported NanoMsg (based on 0.3) that runs the Embedded device
> (note the added sys directory to use or create equivalents in our
> environment)
> pipeline.c - example send/receive code used in testing
> pipeline-build.txt - example build and command line scripts
> traces - folder containing debug printf tracing comparing linux environment
> function calls made to our embedded environment
> (there are differences which I hope will catch the issue)
>  - good - sender.txt - PC/PC connection - node1 (PC sender)
>  - good - receive.txt - PC/PC connection - node0 (PC receiver)
>  - bad - sender.txt - Embedded/PC connection - node1 (Embedded sender -
> hangs)
>  - bad - receive.txt - Embedded/PC connection - node0 (PC receiver)
>
> -
>
> Here is the example code:
>
> #define NODE0 "node0"
> #define NODE1 "node1"
>
> int node0 (const char *url)
> {
> int sock = nn_socket (AF_SP, NN_PULL);
> assert (sock >= 0);
> assert (nn_bind (sock, url) >= 0);
> while (1)
>   {
>  char *buf = NULL;
>  int bytes = nn_recv (sock, &buf, NN_MSG, 0);
>  assert (bytes >= 0);
>  printf ("NODE0: RECEIVED \"%s\"\n", buf);
>  nn_freemsg (buf);
>   }
> }
>
> int node1 (const char *url, const char *msg)
> {
> int sz_msg = strlen (msg) + 1; // '\0' too
> int sock = nn_socket (AF_SP, NN_PUSH);
> assert (sock >= 0);
> assert (nn_connect (sock, url) >= 0);
> printf ("NODE1: SENDING \"%s\"\n", msg);
> int bytes = nn_send (sock, msg, sz_msg, 0);
> assert (bytes == sz_msg);
> return nn_shutdown (sock, 0);
> }
>
> int main (const int argc, const char **argv)
> {
> if (strncmp (NODE0, argv[1], strlen (NODE0)) == 0 && argc > 1)
>   return node0 (argv[2]);
> else if (strncmp (NODE1, argv[1], strlen (NODE1)) == 0 && argc > 2)
>   return node1 (argv[2], argv[3]);
> else
>   {
>  fprintf (stderr, "Usage: pipeline %s|%s <URL> <ARG> ...'\n",
>     NODE0, NODE1);
>  return 1;
>   }
> }
>
>



-- 
P THINK BEFORE PRINTING: is it really necessary?

This e-mail and its attachments are confidential and solely for the
intended addressee(s). Do not share or use them without approval. If
received in error, contact the sender
and delete them.

Other related posts: