CARMA C++
PmacCommand.h
Go to the documentation of this file.
1 #ifndef PMACCOMMAND_H
2 #define PMACCOMMAND_H
3 
11 #include <string>
12 
13 // Required C header files from the array control code
14 
15 #include "carma/szaarrayutils/regmap.h" // RegAddrMode
16 
17 // The hard limit -- pmac can't process more than this in a single
18 // message
19 
20 #define PMAC_DATA_MAX_LEN 1400
21 
22 namespace sza {
23  namespace antenna {
24  namespace control {
25 
26 
27  class PmacComms;
28 
29  class PmacCommand {
30  public:
31 
35  enum RequestType {
36  UPLOAD = 0xC0, // An input wrt the pmac
37  DOWNLOAD = 0x40 // An output command wrt to the pmac
38  };
39 
43  enum Request {
44  INVALID = 0x0, // Default which will be used to
45  // indicate that a command has not
46  // been initialized
47  CTRL_RESPONSE = 0xC4,
48  FWDOWNLOAD = 0xCB,
49  IPADDRESS = 0xE0,
50  PMAC_FLUSH = 0xB3,
51  PMAC_GETBUFFER = 0xC5,
52  PMAC_GETLINE = 0xB1,
53  PMAC_GETMEM = 0xB4,
54  PMAC_GETRESPONSE = 0xBF,
55  PMAC_PORT = 0xBE,
56  PMAC_READREADY = 0xC2,
57  PMAC_SENDLINE = 0xB0,
58  PMAC_SETMEM = 0xB5,
59  PMAC_SETBIT = 0xBA,
60  PMAC_SETBITS = 0xBB,
61  PMAC_WRITEBUFFER = 0xC6,
62  PMAC_WRITEERROR = 0xC7,
63  PMAC_IPADDRESS = 0xE0
64  };
65 
66  struct EthCmdInfo {
67  unsigned char requestType_;
68  unsigned char request_;
69  unsigned short wValue_;
70  unsigned short wIndex_;
71  unsigned short wLength_;
72  };
73 
74  struct EthCmd {
75  EthCmdInfo info_;
76  unsigned char sendData_[PMAC_DATA_MAX_LEN];
77  };
78 
82  PmacCommand();
83 
87  ~PmacCommand();
88 
92  void packCtrlResponseCmd();
93 
97  void packFwDownLoadCmd();
98 
102  void packPmacGetIpAddressCmd();
103 
107  void packPmacSetIpAddressCmd(unsigned int address);
108 
112  void packPmacIpAddressCmd(bool setIp=false, unsigned int address=0x0);
113 
117  void packPmacFlushCmd();
118 
123  void packPmacGetBufferCmd();
124 
128  void packPmacGetLineCmd();
129 
133  void packPmacGetMemCmd(unsigned short offset,
134  unsigned short length);
135 
140  void packPmacGetResponseCmd(std::string outString);
141 
145  void packPmacPortCmd(unsigned char port);
146 
150  void packPmacPortCmd();
151 
155  void packPmacReadReadyCmd();
156 
160  void packPmacSendCtrlCharCmd(char outch);
161 
165  void packPmacSendLineCmd(std::string line);
166 
170  void packPmacSetBitCmd(unsigned short bitNo, bool on);
171 
175  void packPmacSetBitsCmd(unsigned int mask);
176 
180  void packPmacSetMemCmd(unsigned short offset,
181  unsigned short length,
182  unsigned char* data);
183 
187  void packPmacWriteBufferCmd(unsigned int* data, unsigned int len);
188 
189  //------------------------------------------------------------
190  // Derived command types. These are built on top of the
191  // primitive command types supported by the pmac interface.
192  //------------------------------------------------------------
193 
197  void packWriteRegCmd(RegMapBlock* blk,
198  unsigned int first, unsigned int nreg,
199  unsigned int* value);
200 
204  void packReadRegCmd(RegMapBlock* blk,
205  unsigned int first, unsigned int nreg);
206 
207  //------------------------------------------------------------
208  // Methods to do with reading responses back from the pmac.
209  //------------------------------------------------------------
210 
215  void* readData();
216 
220  size_t responseLength();
221 
226  void readRegResponse(RegMapBlock *blk,
227  unsigned int first, unsigned int nreg,
228  unsigned int* response);
229 
234  unsigned int* readRegResponse(RegMapBlock *blk,
235  unsigned int first, unsigned int nreg);
236 
237  private:
238 
239  friend class PmacComms;
240 
241  EthCmd cmd_;
242 
247  unsigned short cmdSize_;
248 
252  bool expectsResponse_;
253 
258  unsigned short responseLength_;
259 
263  unsigned char readData_[PMAC_DATA_MAX_LEN];
264 
269  unsigned char tmpBuffer_[PMAC_DATA_MAX_LEN];
270 
271  //------------------------------------------------------------
272  // Methods for accessing private members.
273  //------------------------------------------------------------
274 
278  Request request();
279 
283  const void* cmd();
284 
288  size_t size();
289 
294  const void* sendData();
295 
296  }; // End class PmacCommand
297 
298  }; // End namespace control
299  }; // End namespace antenna
300 }; // End namespace sza
301 
302 #endif // End #ifndef