Changeset 9905 for fact/tools
- Timestamp:
- 08/30/10 11:27:07 (14 years ago)
- Location:
- fact/tools/FAD/simple_daq
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/FAD/simple_daq/cmd_send.cpp
r261 r9905 2 2 3 3 // Send commands to socket 4 void cmd_send (c har* Buffer, int Socket)4 void cmd_send (const char* Buffer, int Socket) 5 5 { 6 6 int i; … … 38 38 } 39 39 40 else if (strncmp (Buffer, "de\n", 2) == 0)40 else if (strncmp (Buffer, "de\n", 3) == 0) 41 41 { 42 42 CMD_Buffer[0] = htons (CMD_DENABLE); … … 45 45 } 46 46 47 else if (strncmp (Buffer, "dd\n", 2) == 0) 47 else if (strncmp (Buffer, "psup\n", 5) == 0) 48 { 49 CMD_Buffer[0] = htons (CMD_PS_DIRINC); 50 printf ("# increasing phase shift ->\n"); 51 printf ("# 0x%.4X\n", ntohs (CMD_Buffer[0])); 52 } 53 54 else if (strncmp (Buffer, "psdn\n", 5) == 0) 55 { 56 CMD_Buffer[0] = htons (CMD_PS_DIRDEC); 57 printf ("# decreasing phase shift ->\n"); 58 printf ("# 0x%.4X\n", ntohs (CMD_Buffer[0])); 59 } 60 61 else if (strncmp (Buffer, "psreset\n", 8) == 0) 62 { 63 CMD_Buffer[0] = htons (CMD_PS_RESET); 64 printf ("# resetting phase shift ->\n"); 65 printf ("# 0x%.4X\n", ntohs (CMD_Buffer[0])); 66 } 67 68 else if (strncmp (Buffer, "ps\n", 3) == 0) 69 { 70 CMD_Buffer[0] = htons (CMD_PS_DO); 71 printf ("# phase shifting once! ->\n"); 72 printf ("# 0x%.4X\n", ntohs (CMD_Buffer[0])); 73 } 74 75 76 77 else if (strncmp (Buffer, "dd\n", 3) == 0) 48 78 { 49 79 CMD_Buffer[0] = htons (CMD_DDISABLE); … … 52 82 } 53 83 54 else if (strncmp (Buffer, "dr\n", 2) == 0)84 else if (strncmp (Buffer, "dr\n", 3) == 0) 55 85 { 56 86 CMD_Buffer[0] = htons (CMD_DWRITE_RUN); … … 59 89 } 60 90 61 else if (strncmp (Buffer, "ds\n", 2) == 0)91 else if (strncmp (Buffer, "ds\n", 3) == 0) 62 92 { 63 93 CMD_Buffer[0] = htons (CMD_DWRITE_STOP); … … 65 95 printf ("# 0x%.4X\n", ntohs (CMD_Buffer[0])); 66 96 } 67 68 else if (strncmp (Buffer, "sclkon\n", 6) == 0) 97 98 else if (strncmp (Buffer, "srclkon\n", 8) == 0) 99 { 100 CMD_Buffer[0] = htons (CMD_SRCLK_ON); 101 printf ("# DRS readoutclock SRCLK ENABLED ->\n"); 102 printf ("# 0x%.4X\n", ntohs (CMD_Buffer[0])); 103 } 104 else if (strncmp (Buffer, "srclkoff\n", 9) == 0) 105 { 106 CMD_Buffer[0] = htons (CMD_SRCLK_OFF); 107 printf ("# DRS readoutclock SRCLK DISABLED ->\n"); 108 printf ("# 0x%.4X\n", ntohs (CMD_Buffer[0])); 109 } 110 else if (strncmp (Buffer, "sclkon\n", 7) == 0) 69 111 { 70 112 CMD_Buffer[0] = htons (CMD_SCLK_ON); … … 72 114 printf ("# 0x%.4X\n", ntohs (CMD_Buffer[0])); 73 115 } 74 else if (strncmp (Buffer, "sclkoff\n", 7) == 0)116 else if (strncmp (Buffer, "sclkoff\n", 8) == 0) 75 117 { 76 118 CMD_Buffer[0] = htons (CMD_SCLK_OFF); … … 243 285 { 244 286 printf ("Commands:\n"); 245 printf (" r: Start Run -- TODO\n");246 printf (" s: Stop Run -- TODO\n");247 287 printf (" t: Single Trigger\n\n"); 288 printf (" tc: Continuous Trigger\n"); 289 printf (" ts: Stop Trigger\n"); 290 291 printf ("\n"); 292 printf (" sclkon: Switch SPI SLCK on\n"); 293 printf (" sclkoff: Switch SPI SLCK off\n"); 294 295 printf ("\n"); 296 printf (" srclkon: Switch DRS SRLCK on\n"); 297 printf (" srclkoff: Switch DRS SRLCK off\n"); 298 299 printf ("\n"); 300 printf (" ps: Phase shift ADCCLK against SRCLK - one step\n"); 301 printf (" psup: 'increse' phase shift - default\n"); 302 printf (" psdn: 'decrease' phase shift\n"); 303 printf (" psres: reset phase shift\n"); 304 305 306 printf ("\n"); 248 307 printf (" de: DENABLE HIGH\n"); 249 308 printf (" dd: DENABLE LOW\n"); 250 309 printf (" dr: DWRITE HIGH\n"); 251 310 printf (" ds: DWRITE LOW\n"); 252 printf (" sclkon: Switch SPI SLCK on\n"); 253 printf (" sclkoff: Switch SPI SLCK off\n"); 254 printf (" tc: Continuous Trigger\n"); 255 printf (" ts: Stop Trigger\n"); 311 312 printf ("\n"); 256 313 printf (" sr NUM VAL: Set ROI NUM (0-35) to VAL (0-1024)\n"); 257 314 printf (" sra VAL: Set all ROIs to VAL (0-1024)\n"); … … 264 321 printf (" sz: Send 0x0000\n"); 265 322 printf ("\n"); 323 printf (" r: Start Run -- TODO\n"); 324 printf (" s: Stop Run -- TODO\n"); 266 325 267 326 CMD_Num = 0; -
fact/tools/FAD/simple_daq/simple_daq.cpp
r261 r9905 20 20 #include "../SocketFunctions/SocketFunctions.h" 21 21 22 22 #include "iostream" 23 24 int init_fad(); 23 25 int *SocketDescriptor; 26 using namespace std; 24 27 25 28 int main(int argc, char *argv[]) … … 72 75 } 73 76 } 77 init_fad(); 74 78 75 79 … … 77 81 signal (SIGINT, int_handler); // Cleanup after SIGINT (CTRL-C) 78 82 83 // init_fad(); 84 // fflush (stdin); 79 85 // Main loop 80 86 while (true) … … 97 103 98 104 memset (Buffer, 0, sizeof (Buffer)); 105 106 107 // init board -- should be switchable 108 // with a commandline switch, but ... 109 // TODO 110 99 111 100 112 // Data from STDIN … … 146 158 } 147 159 printf (" done\n"); 160 161 148 162 149 163 exit (exit_status); … … 178 192 return conf; 179 193 } 194 195 int init_fad(){ 196 197 cmd_send ("sra 10\n", SocketDescriptor[0]); 198 cmd_send ("sa 44 29\n", SocketDescriptor[0]); 199 cmd_send ("t\n", SocketDescriptor[0]); 200 cmd_send ("sa 44 30\n", SocketDescriptor[0]); 201 cmd_send ("t\n", SocketDescriptor[0]); 202 cmd_send ("sa 44 0\n", SocketDescriptor[0]); 203 cmd_send ("t\n", SocketDescriptor[0]); 204 cmd_send ("sclkoff\n", SocketDescriptor[0]); 205 cmd_send ("de\n", SocketDescriptor[0]); 206 cmd_send ("dr\n", SocketDescriptor[0]); 207 cmd_send ("sra 1024\n", SocketDescriptor[0]); 208 EmptySockets(SocketDescriptor, 8, 750000L); 209 210 printf ( "\n\n FAD initialised. \n " 211 "ROI is 1024. \n" 212 "DRS shift registers are initialised.\n" 213 "DRS is up and running.\n"); 214 215 return 0; 216 } 217 -
fact/tools/FAD/simple_daq/simple_daq.h
r261 r9905 29 29 #define CMD_SCLK_OFF 0x1100 30 30 31 #define CMD_PS_DIRINC 0x1200 32 #define CMD_PS_DIRDEC 0x1300 33 #define CMD_PS_DO 0x1400 34 #define CMD_PS_RESET 0x1700 35 36 37 #define CMD_SRCLK_ON 0x1500 38 #define CMD_SRCLK_OFF 0x1600 39 31 40 #define CMD_Trigger_C 0xB000 // continous trigger 32 41 #define CMD_Trigger_S 0x2000 // stop continous trigger … … 56 65 }; 57 66 58 void cmd_send (c har* Buffer, int Socket); // Send commands to socket67 void cmd_send (const char* Buffer, int Socket); // Send commands to socket 59 68 void int_handler (int sig); // Handle signal SIGINT (CTRL-C) 60 69 void exit_program (int exit_status); // Cleanup and exit
Note:
See TracChangeset
for help on using the changeset viewer.