The VisAO Camera
framegrabber39.h
Go to the documentation of this file.
1 /************************************************************
2 * framegrabber39.h
3 *
4 * Author: Jared R. Males (jrmales@email.arizona.edu)
5 *
6 * Declarations for a class to capture frames from the BCU39, using the ebtables ulog.
7 *
8 * Developed as part of the Magellan Adaptive Optics system.
9 ************************************************************/
10 
11 /** \file framegrabber39.h
12  * \author Jared R. Males
13  * \brief Declarations for a class to capture frames from the BCU39, using the ebtables ulog.
14  *
15  *
16 */
17 
18 #ifndef __framegrabber39_h__
19 #define __framegrabber39_h__
20 
21 #include "framegrabber.h"
22 
23 #include <asm/types.h>
24 #include <sys/socket.h>
25 #include <sys/time.h>
26 #include <time.h>
27 #include <linux/netlink.h>
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <unistd.h>
31 #include <netdb.h>
32 #include <errno.h>
33 #include <netinet/if_ether.h>
34 #include <netinet/ether.h>
35 #include <netinet/ip.h>
36 #include <netinet/ip_icmp.h>
37 
38 #include "BcuLib/Commons.h"
39 #include "bcu_diag.h"
40 
41 
42 extern "C"
43 {
44  #include "ebtables_u.h"
45  #include "ethernetdb.h"
46 
47 }
48 #include <linux/netfilter_bridge/ebt_ulog.h>
49 
50 #include <algorithm>
51 
52 #define DEBUG_QUEUE 0
53 #define BUFLEN 65536
54 
55 
56 /*struct DiagnosticUdpHeader
57 {
58  uint32 tot_len;
59  uint32 saddr;
60  uint16 packetId; // Restarts from zero for each frameId
61  uint16 frameId;
62 };*/
63 
64 namespace VisAO
65 {
66 
67 ///The framegrabber specialization for the CCD39.
68 /** This class uses the bcu ethernet bridge to transparently grab BCU39 frames, and writes them a sharedim_stack.
69  * Does not interface with the BCU 39 in anyway.
70  *
71  * See \ref framegrabber for a list of config file options.
72  *
73  * See \ref VisAOApp_standalone for command line arguments. There are no additional command line arguments for
74  * a basic framegrabber, though derived clases may add them.
75  *
76  * See \ref framegrabber for the commands accepted by this class.
77  *
78  */
79 class framegrabber39 : public framegrabber<unsigned char>
80 {
81  public:
82  framegrabber39(int argc, char **argv) throw (AOException);
83  framegrabber39(std::string name, const std::string &conffile) throw (AOException);
84 
85  protected:
86  void init_framegrabber39();
87 
88  int frameSizeDw;
89  int _frameSizeBytes;
90  static const int _FRAME_HEADER_SIZE_DW = 4;
91  int _packetsPerFrame; // Number of packet for each frame: computed from frameSize
92 
93  size_t curr_len;
94 
95  double t0; ///<Starting time of framegrabber loop.
96 
97  int pktcnt;
98 
99  int rcvbufsize;
100 
101  char buf[BUFLEN];
102 
103  int sfd;
104 
105  ebt_ulog_packet_msg_t *msg;
106 
107  struct ethhdr *ehdr;
108 
109  struct ethertypeent *etype;
110 
111  struct protoent *prototype;
112 
113  struct iphdr *iph;
114 
115  ebt_ulog_packet_msg_t *ulog_get_packet();
116 
117  std::vector<int> bcuLUT;
118  public:
119  virtual int start_framegrabber();
120  virtual int stop_framegrabber();
121 
122 
123  /// Update the status board.
124  /** Overridden from VisAOApp_base
125  * \retval 0 on success
126  * \retval -1 on failure
127  */
128  virtual int update_statusboard();
129 
130 };
131 
132 } //namespace VisAO
133 
134 
135 #endif //__framegrabber47_h__
virtual int update_statusboard()
Update the status board.
double t0
Starting time of framegrabber loop.
virtual int stop_framegrabber()
Override this: framegrabber clean up.
Declarations and definitions for a template class to manage a generic framegrabber.
The framegrabber specialization for the CCD39.
The basic VisAO framegrabber.
Definition: framegrabber.h:78
virtual int start_framegrabber()
Override this: it is where your framegrabber should do all its work. Check for !STOP_FRAMEGRABBER and...
The namespace of VisAO software.