commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10988 - gnuradio/branches/developers/eb/vrt/vrt/apps


From: eb
Subject: [Commit-gnuradio] r10988 - gnuradio/branches/developers/eb/vrt/vrt/apps
Date: Thu, 7 May 2009 09:59:45 -0600 (MDT)

Author: eb
Date: 2009-05-07 09:59:44 -0600 (Thu, 07 May 2009)
New Revision: 10988

Added:
   gnuradio/branches/developers/eb/vrt/vrt/apps/simple_rx_samples.cc
Modified:
   gnuradio/branches/developers/eb/vrt/vrt/apps/
   gnuradio/branches/developers/eb/vrt/vrt/apps/Makefile.am
Log:
checkpoint


Property changes on: gnuradio/branches/developers/eb/vrt/vrt/apps
___________________________________________________________________
Modified: svn:ignore
   - Makefile
Makefile.in
.deps
.libs
*.la
*.lo
rx_streaming_samples

   + Makefile
Makefile.in
.deps
.libs
*.la
*.lo
rx_streaming_samples
simple_rx_samples


Modified: gnuradio/branches/developers/eb/vrt/vrt/apps/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/apps/Makefile.am    2009-05-07 
09:25:15 UTC (rev 10987)
+++ gnuradio/branches/developers/eb/vrt/vrt/apps/Makefile.am    2009-05-07 
15:59:44 UTC (rev 10988)
@@ -28,7 +28,8 @@
 
 bin_PROGRAMS = 
 
-#noinst_PROGRAMS = \
-#      rx_streaming_samples
+noinst_PROGRAMS = \
+       simple_rx_samples
 
-#rx_streaming_samples_SOURCES = rx_streaming_samples.cc
+simple_rx_samples_SOURCES = simple_rx_samples.cc
+

Added: gnuradio/branches/developers/eb/vrt/vrt/apps/simple_rx_samples.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/apps/simple_rx_samples.cc           
                (rev 0)
+++ gnuradio/branches/developers/eb/vrt/vrt/apps/simple_rx_samples.cc   
2009-05-07 15:59:44 UTC (rev 10988)
@@ -0,0 +1,103 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <vrt/rx_udp.h>
+
+#define        MIN_IP_LOCAL_PORT       32768
+#define        MAX_IP_LOCAL_PORT       61000
+
+static void
+pdie(const char *msg)
+{
+  perror(msg);
+  exit(1);
+}
+
+
+int
+main(int argc, char **argv)
+{
+  const char *quad_radio_ip = "192.168.123.123";
+  int quad_radio_ctrl_port = 790;
+
+  int  data_fd;        // socket fd for data
+  int  data_port;      // our port number
+  int  ctrl_fd;        // socket for control
+
+  //
+  // create a udp socket to use to receive data
+  //
+
+  data_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+  if (data_fd == -1)
+    pdie("socket: data_fd");
+
+  // bind it to a local port (we don't care what the value is)
+
+  data_port = -1;
+  for (int port = MIN_IP_LOCAL_PORT; port <= MAX_IP_LOCAL_PORT; port++){
+    struct sockaddr_in si_me;
+    memset(&si_me, 0, sizeof(si_me));
+    si_me.sin_family = AF_INET;
+    si_me.sin_port = htons(port);
+    si_me.sin_addr.s_addr = htonl(INADDR_ANY);
+
+    if (bind(data_fd, (struct sockaddr *) &si_me, sizeof(si_me)) == 0){        
// found one!
+      data_port = port;
+      break;
+    }
+  }
+
+  if (data_port == -1){
+    fprintf(stderr, "failed to bind to a local port\n");
+    exit(1);
+  }
+
+  printf("data port = %d\n", data_port);
+
+  //
+  // create a udp socket and connect it to the quad radio control port
+  //
+
+  ctrl_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+  if (ctrl_fd == -1)
+    pdie("socket: ctrl_fd");
+
+  struct sockaddr_in si_other;
+  memset(&si_other, 0, sizeof(si_other));
+  si_other.sin_family = AF_INET;
+  si_other.sin_port = htons(quad_radio_ctrl_port);
+  if (inet_pton(AF_INET, quad_radio_ip, &si_other.sin_addr) <= 0)
+    pdie("inet_pton");
+
+  if (connect(ctrl_fd, (struct sockaddr *) &si_other, sizeof(si_other)) != 0)
+    pdie("connect");
+
+  return 0;
+}


Property changes on: 
gnuradio/branches/developers/eb/vrt/vrt/apps/simple_rx_samples.cc
___________________________________________________________________
Added: svn:eol-style
   + native





reply via email to

[Prev in Thread] Current Thread [Next in Thread]