GNU Radio's CYBERRADIO Package
snapshot_fft_vector_source_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2019 G3.
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_FFT_VECTOR_SOURCE_IMPL_H
22 #define INCLUDED_CYBERRADIO_SNAPSHOT_FFT_VECTOR_SOURCE_IMPL_H
23 
25 
26 #include <arpa/inet.h>
27 #include <errno.h>
28 #include <fcntl.h>
29 #include <inttypes.h>
30 #include <linux/if_ether.h>
31 #include <linux/if_packet.h>
32 #include <net/ethernet.h>
33 #include <net/if.h>
34 #include <netdb.h>
35 #include <netinet/in.h>
36 #include <netinet/ip.h>
37 #include <netinet/udp.h>
38 #include <poll.h>
39 #include <signal.h>
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <string.h>
43 #include <sys/mman.h>
44 #include <sys/socket.h>
45 #include <sys/stat.h>
46 #include <sys/types.h>
47 #include <sys/un.h>
48 #include <unistd.h>
49 
50 #include <iostream>
51 #include <poll.h>
52 #include <vector>
53 #include <volk/volk.h>
54 
55 #include "packet_types.h"
56 
57 namespace gr {
58 namespace CyberRadio {
59 
61 private:
62  std::string d_radio_type;
63  std::string d_ip;
64  unsigned int d_port;
65  unsigned int d_block_rate;
66  unsigned int d_block_size;
67  bool d_tag_frame;
68 
69  std::string ip;
70  unsigned int port;
71  unsigned int block_rate;
72  unsigned int block_size;
73  unsigned int packets_per_block;
74 
75  bool d_byteSwap, d_iqSwap;
76  bool d_bswap32, d_bswap16;
77  int d_samples_per_frame;
78  bool initializing, running;
79 
80  int stream_counter, sample_counter;
81  bool program_starting;
82  int sock_fd;
83  std::vector<int8_t> sampleVector;
84  struct iovec rxVec[3];
85  int expectedRxSize;
86  struct pollfd pfd;
87 
88  int32_t thisCount, lastCount, countDiff;
89  bool d_iq_swap, d_byte_swap;
90 
91  void (*_parseHeader)(char *, int);
92  static void _parseHeaderNull(char *hdr, int hdr_len) {
93  std::cout << "_parseHeaderNull" << std::endl;
94  };
95 
96 public:
97  snapshot_fft_vector_source_impl(const std::string radio_type,
98  const std::string &ip, unsigned int port,
99  unsigned int block_size,
100  unsigned int block_rate);
102  int initSocket(const std::string ip, unsigned short port);
103  void pause();
104 
105  bool start(void);
106  bool stop(void);
107  // Where all the action really happens
108  int work(int noutput_items, gr_vector_const_void_star &input_items,
109  gr_vector_void_star &output_items);
110 };
111 
112 } // namespace CyberRadio
113 } // namespace gr
114 
115 #endif /* INCLUDED_CYBERRADIO_SNAPSHOT_FFT_VECTOR_SOURCE_IMPL_H */
Definition: snapshot_fft_vector_source_impl.h:60
Provides GNU Radio blocks.
Definition: NDR651_duc_sink_mk2.h:21
snapshot_fft_vector_source_impl(const std::string radio_type, const std::string &ip, unsigned int port, unsigned int block_size, unsigned int block_rate)
<+description of block+>
Definition: snapshot_fft_vector_source.h:36
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)