CARMA C++
PmacFake.h
Go to the documentation of this file.
1 #ifndef PMACFAKE_H
2 #define PMACFAKE_H
3 
11 #include <sys/select.h> // select()
12 #include <sys/types.h> // recv()
13 #include <sys/socket.h>
14 
15 #include "carma/szaarrayutils/tcpip.h"
16 
19 
20 namespace sza {
21  namespace antenna {
22  namespace control {
23 
24 
25  class PmacFake {
26  public:
27 
28  inline void connect()
29  {
30  fd_ = udp_server_sock(PMAC_HOST_PORT, 1);
31  }
32 
33  inline void serviceMsgQ()
34  {
35  fd_set read_fds;
36 
37  FD_ZERO(&read_fds);
38  FD_SET(fd_, &read_fds);
39 
40  while(select(fd_+1, &read_fds, NULL, NULL, NULL) > 0) {
41  processEthCmd();
42  }
43  }
44 
45  inline void processEthCmd()
46  {
47  recv(fd_, (void*) &cmd_, sizeof(PmacCommand::EthCmd)+PMAC_DATA_MAX_LEN, 0);
48  cout << "Got a message: ";
49  fprintf(stdout, "%x\n", cmd_.info_.request_);
50  }
51 
52  private:
53 
54  int fd_;
55 
56  PmacCommand::EthCmd cmd_;
57 
58  }; // End class PmacFake
59 
60  }; // End namespace control
61  }; // End namespace antenna
62 }; // End namespace sza
63 
64 #endif // End #ifndef
Tagged: Thu Nov 13 16:53:43 UTC 2003.
Tagged: Thu Nov 13 16:53:44 UTC 2003.