GNU Radio's CYBERRADIO Package
snapshot_vector_source_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2017 <+YOU OR YOUR COMPANY+>.
4  *
5  * This is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3, or (at your option)
8  * any later version.
9  *
10  * This software is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this software; see the file COPYING. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef INCLUDED_CYBERRADIO_SNAPSHOT_VECTOR_SOURCE_IMPL_H
22 #define INCLUDED_CYBERRADIO_SNAPSHOT_VECTOR_SOURCE_IMPL_H
23 
25 
27 #include <arpa/inet.h>
28 #include <errno.h>
29 #include <fcntl.h>
30 #include <inttypes.h>
31 #include <linux/if_ether.h>
32 #include <linux/if_packet.h>
33 #include <net/ethernet.h>
34 #include <net/if.h>
35 #include <netdb.h>
36 #include <netinet/in.h>
37 #include <netinet/ip.h>
38 #include <netinet/udp.h>
39 #include <poll.h>
40 #include <signal.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <string.h>
44 #include <sys/mman.h>
45 #include <sys/socket.h>
46 #include <sys/stat.h>
47 #include <sys/types.h>
48 #include <sys/un.h>
49 #include <unistd.h>
50 
51 #include <iostream>
52 #include <poll.h>
53 #include <vector>
54 #include <volk/volk.h>
55 
56 #include "packet_types.h"
57 
58 namespace gr {
59 namespace CyberRadio {
60 
62 private:
63  std::string d_radio_type;
64  std::string d_ip;
65  unsigned int d_port;
66  unsigned int d_block_rate;
67  unsigned int d_block_size;
68  bool d_tag_frame;
69 
70  std::string ip;
71  unsigned int port;
72  unsigned int block_rate;
73  unsigned int block_size;
74  unsigned int packets_per_block;
75 
76  bool d_byteSwap, d_iqSwap;
77  bool d_bswap32, d_bswap16;
78  int d_samples_per_frame;
79  bool initializing, running;
80 
81  int stream_counter, sample_counter;
82  bool program_starting;
83  int sock_fd;
84  std::vector<gr_complex> sampleVector;
85  struct iovec rxVec[3];
86  int expectedRxSize;
87  struct pollfd pfd;
88 
89  int32_t thisCount, lastCount, countDiff;
90  bool d_iq_swap, d_byte_swap;
91 
92  void (*_parseHeader)(char *, int);
93 
94  void set_bswap_flags(void);
95  void set_byteSwap(bool byteSwap);
96  void set_iqSwap(bool iqSwap);
97 
98  static void _parseHeaderNull(char *hdr, int hdr_len) {
99  std::cout << "_parseHeaderNull" << std::endl;
100  };
101  static void _parseHeaderNdr308(char *hdr, int hdr_len) {
102  std::cout << "_parseHeaderNdr308" << std::endl;
103  };
104  static void _parseHeaderNdr551(char *hdr, int hdr_len) {
105  std::cout << "_parseHeaderNdr551" << std::endl;
106  };
107 
108  void rxControlMsg(pmt::pmt_t msg);
109  void txStatusMsg(void);
110 
111 public:
112  snapshot_vector_source_impl(const std::string radio_type,
113  const std::string &ip, unsigned int port,
114  unsigned int block_size, unsigned int block_rate);
116  int initSocket(const std::string ip, unsigned short port);
117  void pause();
118 
119  bool start(void);
120  bool stop(void);
121 
122  // Where all the action really happens
123  int work(int noutput_items, gr_vector_const_void_star &input_items,
124  gr_vector_void_star &output_items);
125 };
126 
127 } // namespace CyberRadio
128 } // namespace gr
129 
130 #endif /* INCLUDED_CYBERRADIO_SNAPSHOT_VECTOR_SOURCE_IMPL_H */
Definition: snapshot_vector_source_impl.h:61
<+description of block+>
Definition: snapshot_vector_source.h:36
snapshot_vector_source_impl(const std::string radio_type, const std::string &ip, unsigned int port, unsigned int block_size, unsigned int block_rate)
Provides GNU Radio blocks.
Definition: NDR651_duc_sink_mk2.h:21
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
int initSocket(const std::string ip, unsigned short port)