Critical Link MityCam SoC Firmware  1.0
Critical Link MityCam SoC Firmware
GigEInterface.h
Go to the documentation of this file.
1 
9 #ifndef GIGEINTERFACE_H
10 #define GIGEINTERFACE_H
11 
12 #include "CommandInterface.h"
13 #include "GigE.h"
14 #include "RegisterFile.h"
15 #include <sys/types.h>
16 #include <sys/socket.h>
17 #include <netinet/in.h>
18 #include <netdb.h>
19 #include <cstdint>
20 #include <time.h>
21 
22 #include "PayloadSetter.h"
23 
24 namespace SocCamera
25 {
27  {
28  public:
29  tcGigEInterface(tcIOChannel *apChannel, tcSensorBoard *apSensor);
30 
31  virtual ~tcGigEInterface();
32 
33  virtual void* run();
34 
55 
56  void getInput(std::string* /*apStringOutput*/) {}
57  std::string parseInput(std::string& /*arStringOutput*/) { return std::string(); }
58  void respond(std::string /*ahResponse*/) {}
59  void finish (std::string& /*arOriginalBuffer*/) {}
61 
62  tcRegisterFile* mpRegisterFile; //Registers are stored in network byte order
63 
64  static const char *getCommandName (uint16_t cmd);
65  static const char *getStatusName (GEV_STATUS status);
66 
67  virtual void update_payload_size(const uint32_t payload_size);
68 
69  private:
70  void pump_messages ();
71  int send_ack (const void *pbuf, int len, sockaddr_in *psockaddr);
72 
73  void sync_net(bool init_cfg_reg = false);
74  void sync_hdw();
75  void sync_xml();
76  void sync_user_name();
77 
78  private:
79  uint32_t* createDiscoveryAckPacket (int &len, GEV_STATUS status, uint16_t ackid);
80  uint32_t* createReadRegAckPacket (int &len, GEV_STATUS status, uint16_t ackid, uint32_t address, uint32_t nvalue);
81  uint32_t* createWriteRegAckPacket (int &len, GEV_STATUS status, uint16_t ackid);
82  uint32_t* createReadMemAckPacket (int &len, GEV_STATUS status, uint16_t ackid, uint32_t address, uint16_t numbytes, uint8_t* data);
83  uint32_t* createWriteMemAckPacket (int &len, GEV_STATUS status, uint16_t ackid);
84  uint32_t* createForceIpAckPacket (int &len, GEV_STATUS status, uint16_t ackid);
85 
86  GEV_STATUS execWriteRegCmd (uint32_t address, uint32_t nvalue);
87  GEV_STATUS execWriteMemCmd (uint32_t address, const uint8_t* data, uint32_t numbytes);
88  GEV_STATUS execForceIpCmd (uint32_t ipaddr, uint32_t snmask, uint32_t gwaddr);
89 
90  void releaseAccess ();
91 
92  bool is_access_client (const sockaddr_in &sa) { return (m_AccessControlled && sa.sin_addr.s_addr == mnAccessingClientIP && sa.sin_port == mnAccessingClientPort); }
93  bool is_access_controlled () { return m_AccessControlled; }
94  bool is_access_exclusive () { return m_AccessExclusive; }
95 
96  sockaddr_in si_me;
97  sockaddr_in si_other;
98  sockaddr_in si_broadcast;
99 
100  uint8_t maGVCPBuffer[GVCP_MAX_DATAGRAM_SIZE];
101  int mnSockfd;
102  uint16_t mnPreviousAckID;
103  GEV_STATUS mePreviousStatus;
104  int mnPacketLength;
105  struct timespec mnPreviousTime;
106  unsigned int mnHeartBeatTimer;
107  uint16_t mnWriteMemIndex;
108 
109  bool m_AccessControlled;
110  bool m_AccessExclusive ;
111  in_addr_t mnAccessingClientIP;
112  in_port_t mnAccessingClientPort;
113 
114  uint8_t m_macaddr[6];
115  };
116 
117 };
118 #endif // GIGEINTERFACE_H
GigE.h
SocCamera::tcGigEInterface::getCommandName
static const char * getCommandName(uint16_t cmd)
Definition: GigEInterface.cpp:1180
SocCamera::tcGigEInterface::mpRegisterFile
tcRegisterFile * mpRegisterFile
Definition: GigEInterface.h:62
SocCamera::tcGigEInterface::parseInput
std::string parseInput(std::string &)
Definition: GigEInterface.h:57
PayloadSetter.h
SocCamera::tcGigEInterface::respond
void respond(std::string)
Definition: GigEInterface.h:58
tcIOChannel
Camera Output IO channel management class.
Definition: IOChannel.h:34
tcPayloadSetter
Definition: PayloadSetter.h:11
SocCamera::tcGigEInterface
Definition: GigEInterface.h:26
SocCamera::tcGigEInterface::getInput
void getInput(std::string *)
Definition: GigEInterface.h:56
SocCamera::tcGigEInterface::update_payload_size
virtual void update_payload_size(const uint32_t payload_size)
Definition: GigEInterface.cpp:1149
CommandInterface.h
This file contains the tcCommandInterface class.
SocCamera
Definition: CameraTypes.h:7
SocCamera::tcGigEInterface::finish
void finish(std::string &)
Definition: GigEInterface.h:59
SocCamera::tcGigEInterface::~tcGigEInterface
virtual ~tcGigEInterface()
Definition: GigEInterface.cpp:79
SocCamera::tcGigEInterface::run
virtual void * run()
Main body of the run thread for the GigE interface.
Definition: GigEInterface.cpp:87
SocCamera::tcRegisterFile
Definition: RegisterFile.h:121
SocCamera::tcGigEInterface::getStatusName
static const char * getStatusName(GEV_STATUS status)
Definition: GigEInterface.cpp:1207
GEV_STATUS
uint16_t GEV_STATUS
Definition: GigE.h:24
SocCamera::tcGigEInterface::tcGigEInterface
tcGigEInterface(tcIOChannel *apChannel, tcSensorBoard *apSensor)
Definition: GigEInterface.cpp:47
SocCamera::tcSensorBoard
Definition: SensorBoard.h:40
SocCamera::tcCommandInterface
Definition: CommandInterface.h:25
GVCP_MAX_DATAGRAM_SIZE
#define GVCP_MAX_DATAGRAM_SIZE
Definition: GigE.h:17
RegisterFile.h