Changeset 202 for tools/vchvtest
- Timestamp:
- 04/23/10 08:24:35 (15 years ago)
- Location:
- tools/vchvtest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/vchvtest/HV.cc
r200 r202 144 144 } 145 145 } 146 147 // if (ret == 3) {148 // printf(" *** Board %d *** Current: %d\n"149 // "Overcurrent bit: %s Wrap counter: %d Reset bit: %s Status: %s\n",150 // rbuf[2]&0xf, rbuf[1]+(rbuf[0]&15)*256,151 // rbuf[0]&128 ? "set":"clear", (rbuf[0]>>4)&7,152 // (rbuf[2]&128)==0 ? "clear": "set",153 // (rbuf[2]&0x70)==0x70 ? "No response": "OK");154 // }155 146 156 147 return 1; -
tools/vchvtest/vchvtest.cc
r201 r202 8 8 9 9 #include <stdio.h> 10 #include <termios.h> 11 #include <unistd.h> 12 10 13 #include <ctype.h> 11 14 #include <sys/time.h> … … 27 30 int LastCrate; 28 31 bool Repeat = false; 29 bool Verbose = true;32 bool Verbose; 30 33 31 34 // Function prototypes … … 73 76 74 77 char Prompt[MAX_COM_SIZE], *Command = NULL; 78 struct termios Termios, Termios_orig; 75 79 76 80 printf("\n*** vchvtest (built %s, %s; O. Grimm) ***\n\n",__DATE__,__TIME__); 77 if (argc == 1) printf("Note: Use FTDI serial numbers as arguments to connect\n"); 81 if (argc == 1) { 82 printf("Note: Use FTDI serial numbers as arguments to connect\n"); 83 } 84 78 85 79 86 // Initialize status variables … … 90 97 } 91 98 LastCrate = NumCrates-1; 99 100 // Set terminal to read single chars 101 if (tcgetattr (1, &Termios_orig) == -1) { 102 printf("Error with tcgetattr() (%s)\n", strerror(errno)); 103 exit(EXIT_FAILURE); 104 } 105 Termios = Termios_orig; 106 Termios.c_lflag &= ~(ICANON | ECHO); 92 107 93 108 // Command loop … … 109 124 else continue; 110 125 111 // Process command 126 // Set terminal to return single chars 127 if (tcsetattr (1, 0, &Termios) == -1) { 128 printf("Error with tcsetattr() (%s)\n", strerror(errno)); 129 exit(EXIT_FAILURE); 130 } 131 132 // Defualt is verbose response 133 Verbose = true; 134 135 // Process command 112 136 for(int i=0; i<MAX_NUM_TOKEN; i++) Param[i] = ""; // All pointers point initially to empty string 113 137 NParam = ParseInput(Command, Param); … … 115 139 bool Found=false; 116 140 int N; 117 for(unsigned int CmdNumber=0; CmdNumber<sizeof(CommandList)/sizeof(CL_Struct); CmdNumber++) 141 for(unsigned int CmdNumber=0; CmdNumber<sizeof(CommandList)/sizeof(CL_Struct); CmdNumber++) { 118 142 if (Match(Param[0], CommandList[CmdNumber].Name)) { 119 143 if(NParam-1 < CommandList[CmdNumber].MinNumParameter) { 120 144 printf("Usage: %s %s\n", CommandList[CmdNumber].Name, CommandList[CmdNumber].Parameters); 121 }122 123 (*CommandList[CmdNumber].CommandPointer)();124 ioctl(STDIN_FILENO, FIONREAD, &N);125 } while(CommandList[CmdNumber].Repeatable && Repeat && N==0);145 } 146 else do { 147 (*CommandList[CmdNumber].CommandPointer)(); 148 ioctl(STDIN_FILENO, FIONREAD, &N); 149 } while(CommandList[CmdNumber].Repeatable && Repeat && N==0); 126 150 Found = true; 127 break;151 break; 128 152 } 153 } // for() 154 129 155 if (!Found) printf("Unknown command '%s'\n",Param[0]); 130 } // while{} 156 157 // Set terminal back to line buffering 158 if (tcsetattr (1, 0, &Termios_orig) == -1) { 159 printf("Error with tcsetattr() (%s)\n", strerror(errno)); 160 exit(EXIT_FAILURE); 161 } 162 } // while() 131 163 } 132 164 … … 226 258 void cmd_test() { 227 259 228 for (int i=FirstCrate; i<=LastCrate; i++) { 229 printf("Testing board %d (Enter to continue, any key plus enter to stop)\n", fHVBoard[i]->BoardNumber); 260 Verbose = false; 261 262 // Loop over crates 263 for (int i=FirstCrate; i<=LastCrate; i++) { 264 printf("Testing board %d (q to stop, any other key to continue)\n", fHVBoard[i]->BoardNumber); 230 265 if (fHVBoard[i]->GlobalSet(0) != 1) { 231 266 printf("Error: Could not global set board to zero\n"); … … 234 269 235 270 for (int k=0; k<MAX_NUM_BOARDS; k++) for (int j=0; j<NUM_CHANNELS; j++) { 236 printf("\rBoard %d, channel %d", k, j); 237 fflush(stdout); 238 Verbose = false; 271 printf("Board %d, channel %d\n", k, j); 272 239 273 if (fHVBoard[i]->ChannelSet(k, j, atoi(Param[1])) != 1) { 240 printf(" Error setting voltage\n");274 printf(" Error setting voltage\n"); 241 275 return; 242 276 } 243 Verbose = true;244 if (getchar() != '\n') return;277 278 if (getchar() == 'q') return; 245 279 } 246 280 } … … 270 304 271 305 if (N < 1) return; 306 Verbose = false; 272 307 273 308 gettimeofday(&Start, NULL); 274 Verbose = false;275 309 for (int i=0; i<=N; i++) fHVBoard[0]->ReadChannel(0, 0); 276 Verbose = true;277 310 gettimeofday(&End, NULL); 278 311 … … 286 319 if (Match(Param[1],"on")) Repeat = true; 287 320 else Repeat = false; 288 printf("Auto command repeat is %s\n", Repeat ? "on ( CTRL-c to switch off)" : "off");321 printf("Auto command repeat is %s\n", Repeat ? "on (Hit return while repeating to stop)" : "off"); 289 322 } 290 323 … … 294 327 int Board; 295 328 329 Verbose = false; 330 296 331 if (NParam==2 && ConvertToInt(Param[1], &Board)) { 297 332 for (int i=FirstCrate; i<=LastCrate; i++) { 298 Verbose = false;299 333 for (int j=0; j<NUM_CHANNELS; j++) { 300 334 if (j%4 == 0) printf("\nChannel %2d ", j); … … 304 338 } 305 339 printf("\n"); 306 Verbose = true;307 340 } 308 341 } else { … … 332 365 } 333 366 } 334 335 Verbose = true;336 367 } 337 368
Note:
See TracChangeset
for help on using the changeset viewer.