GNU Radio's CYBERRADIO Package
snapshot_vector_source_mk2_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2019 gr-CyberRadio author.
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_MK2_IMPL_H
22 #define INCLUDED_CYBERRADIO_SNAPSHOT_VECTOR_SOURCE_MK2_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  bool d_demod;
70 
71  std::string ip;
72  unsigned int port;
73  unsigned int block_rate;
74  unsigned int block_size;
75  unsigned int packets_per_block;
76 
77  bool d_byteSwap, d_iqSwap;
78  bool d_bswap32, d_bswap16;
79  int d_samples_per_frame;
80  bool initializing, running;
81 
82  int stream_counter;
83  bool program_starting;
84  int sock_fd;
85  std::vector<float> sampleVector;
86  struct iovec rxVec[3];
87  int expectedRxSize;
88  struct pollfd pfd;
89 
90  int32_t thisCount, lastCount, countDiff;
91  bool d_iq_swap, d_byte_swap;
92 
93  void (*_parseHeader)(char *, int);
94 
95  void set_bswap_flags(void);
96  void set_byteSwap(bool byteSwap);
97  void set_iqSwap(bool iqSwap);
98 
99  static void _parseHeaderNull(char *hdr, int hdr_len) {
100  std::cout << "_parseHeaderNull" << std::endl;
101  };
102  static void _parseHeaderNdr308(char *hdr, int hdr_len) {
103  std::cout << "_parseHeaderNdr308" << std::endl;
104  };
105  static void _parseHeaderNdr551(char *hdr, int hdr_len) {
106  std::cout << "_parseHeaderNdr551" << std::endl;
107  };
108 
109  void rxControlMsg(pmt::pmt_t msg);
110  void txStatusMsg(void);
111 
112 public:
113  snapshot_vector_source_mk2_impl(const std::string radio_type,
114  const std::string &ip, unsigned int port,
115  unsigned int block_size,
116  unsigned int block_rate, bool demod);
118  int initSocket(const std::string ip, unsigned short port);
119  void pause();
120 
121  bool start(void);
122  bool stop(void);
123 
124  // Where all the action really happens
125  int work(int noutput_items, gr_vector_const_void_star &input_items,
126  gr_vector_void_star &output_items);
127 };
128 
129 } // namespace CyberRadio
130 } // namespace gr
131 
132 #endif /* INCLUDED_CYBERRADIO_SNAPSHOT_VECTOR_SOURCE_MK2_IMPL_H */
<+description of block+>
Definition: snapshot_vector_source_mk2.h:36
snapshot_vector_source_mk2_impl(const std::string radio_type, const std::string &ip, unsigned int port, unsigned int block_size, unsigned int block_rate, bool demod)
int initSocket(const std::string ip, unsigned short port)
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)
Definition: snapshot_vector_source_mk2_impl.h:61