Changeset 230 for hvcontrol/src/HV.cc
- Timestamp:
- 06/24/10 14:16:17 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
hvcontrol/src/HV.cc
r229 r230 27 27 strcpy(BoardName, Name.c_str()); 28 28 29 stringstream Buf;30 Buf << setw(2) << BoardNumber;31 string Result =Buf.str();32 33 29 // Create DIM services 34 NameService = new DimService ((SERVER_NAME"/NAME/ID"+Result).c_str(), BoardName); 35 BiasVolt = new DimService ((char *) (SERVER_NAME"/VOLT/ID"+Result).c_str(), (char *) "D", HVV, NUM_CHAINS*NUM_CHANNELS*sizeof(double)); 36 30 stringstream ID; 31 ID << setfill('0') << setw(2) << BoardNumber; 32 33 NameService = new DimService ((SERVER_NAME"/NAME/ID"+ID.str()).c_str(), BoardName); 34 BiasVolt = new DimService ((char *) (SERVER_NAME"/VOLT/ID"+ID.str()).c_str(), (char *) "D", HVV, NUM_CHAINS*NUM_CHANNELS*sizeof(double)); 35 36 // Initialise board variables 37 37 for (int i=0; i<NUM_CHAINS; i++) Overcurrent[i] = false; 38 38 ResetButton = false; … … 43 43 ClearVoltageArrays(); 44 44 45 // Open device 45 46 if ((fDescriptor = open(("/dev/"+Name).c_str(), O_RDWR|O_NOCTTY|O_NDELAY)) == -1) { 46 if(errno != 2) m->PrintMessage( All,"Error: Could not open device %d/%s (%s)\n", DeviceNumber, Name.c_str(), strerror(errno));47 if(errno != 2) m->PrintMessage("Error: Could not open device %d/%s (%s)\n", DeviceNumber, Name.c_str(), strerror(errno)); 47 48 return; 48 49 } … … 50 51 // Get current serial port settings 51 52 if (tcgetattr(fDescriptor, &tio) == -1) { 52 m->PrintMessage( All,"Error: tcgetattr() failed (%d/%s)\n", errno, strerror(errno));53 m->PrintMessage("Error: tcgetattr() failed (%d/%s)\n", errno, strerror(errno)); 53 54 return; 54 55 } 55 56 56 57 // Set baudrate and raw mode 57 if (cfsetspeed(&tio, BAUDRATE) == -1) m->PrintMessage( All,"Error: Could not set baud rate (%s)\n", strerror(errno));58 if (cfsetspeed(&tio, BAUDRATE) == -1) m->PrintMessage("Error: Could not set baud rate (%s)\n", strerror(errno)); 58 59 cfmakeraw(&tio); 59 if (tcsetattr(fDescriptor, TCSANOW, &tio ) == -1) m->PrintMessage( All,"Error: tcsetattr() failed (%s)\n", strerror(errno));60 if (tcsetattr(fDescriptor, TCSANOW, &tio ) == -1) m->PrintMessage("Error: tcsetattr() failed (%s)\n", strerror(errno)); 60 61 61 62 // Synchronize HV board (if fails, closes device and sets fDescriptor to -2) … … 100 101 // === Write data === 101 102 if ((ret=write(fDescriptor, wbuf, Bytes)) < Bytes) { 102 if (ret == -1) m-> PrintMessage(All, "Could not write data to HV board (%s)\n", strerror(errno));103 else m-> PrintMessage(All, "Could write only %d of %d bytes to HV board\n", ret, Bytes);103 if (ret == -1) m->Message(m->ERROR, "Could not write data to HV board (%s)", strerror(errno)); 104 else m->Message(m->ERROR, "Could write only %d of %d bytes to HV board", ret, Bytes); 104 105 ErrorCount++; 105 106 return 0; … … 110 111 struct timeval WaitTime = {(long) fTimeOut, (long) ((fTimeOut-(long) fTimeOut)*1e6)}; 111 112 if (select(fDescriptor+1, &SelectDescriptor, NULL, NULL, &WaitTime)==-1) { 112 m-> PrintMessage(All, "Error with select() (%s)\n", strerror(errno));113 m->Message(m->ERROR, "Error with select() (%s)", strerror(errno)); 113 114 return 0; 114 115 } … … 118 119 // Read error? 119 120 if ((ret = read(fDescriptor, &rbuf, 1)) == -1) { 120 m-> PrintMessage(All, "Read error (%s)\n", strerror(errno));121 m->Message(m->ERROR, "Read error (%s)", strerror(errno)); 121 122 ErrorCount++; 122 123 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.