Merge branch '2.2-rc' into hdf5

This commit is contained in:
Dhanya Maliakal 2017-01-06 15:17:40 +01:00
commit b16d087fd1
9 changed files with 451 additions and 91 deletions

View File

@ -0,0 +1,187 @@
#include "ansi.h"
#include <termios.h> /* POSIX terminal control definitions */
#include <stdio.h>
#include <stdlib.h> // atoi
#include <fcntl.h> // File control definitions
#include <sys/ioctl.h> // ioctl
#include <unistd.h> // read, close
#include <string.h> // memset
#include <linux/i2c-dev.h> // I2C_SLAVE, __u8 reg
#define PORTNAME "/dev/ttyBF1"
#define GOODBYE 200
#define BUFFERSIZE 16
#define I2C_DEVICE_FILE "/dev/i2c-0"
#define I2C_DEVICE_ADDRESS 0x4C
//#define I2C_DEVICE_ADDRESS 0x48
#define I2C_REGISTER_ADDRESS 0x40
int i2c_open(const char* file,unsigned int addr){
//device file
int fd = open( file, O_RDWR );
if (fd < 0) {
cprintf(RED,"Warning: Unable to open file %s\n",file);
return -1;
}
//device address
if( ioctl( fd, I2C_SLAVE, addr&0x7F ) < 0 ) {
cprintf(RED,"Warning: Unable to set slave address:0x%x \n",addr);
return -2;
}
return fd;
}
int i2c_read(){
int fd = i2c_open(I2C_DEVICE_FILE, I2C_DEVICE_ADDRESS);
__u8 reg = I2C_REGISTER_ADDRESS & 0xff;
unsigned char buf = reg;
if (write(fd, &buf, 1)!= 1){
cprintf(RED,"Warning: Unable to write read request to register %d\n", reg);
return -1;
}
//read and update value (but old value read out)
if(read(fd, &buf, 1) != 1){
cprintf(RED,"Warning: Unable to read register %d\n", reg);
return -2;
}
//read again to read the updated value
if(read(fd, &buf, 1) != 1){
cprintf(RED,"Warning: Unable to read register %d\n", reg);
return -2;
}
close(fd);
return buf;
}
int i2c_write(unsigned int value){
__u8 val = value & 0xff;
int fd = i2c_open(I2C_DEVICE_FILE, I2C_DEVICE_ADDRESS);
if(fd < 0)
return fd;
__u8 reg = I2C_REGISTER_ADDRESS & 0xff;
char buf[3];
buf[0] = reg;
buf[1] = val;
if (write(fd, buf, 2) != 2) {
cprintf(RED,"Warning: Unable to write %d to register %d\n",val, reg);
return -1;
}
close(fd);
return 0;
}
int main(int argc, char* argv[]) {
int fd = open(PORTNAME, O_RDWR | O_NOCTTY);
if(fd < 0){
cprintf(RED,"Warning: Unable to open port %s\n", PORTNAME);
return -1;
}
struct termios serial_conf;
// Get the current options for the port
tcgetattr(fd, &serial_conf);
// reset structure
memset(&serial_conf,0,sizeof(serial_conf));
// control options
serial_conf.c_cflag = B2400 | CS8 | CREAD | CLOCAL;
// input options
serial_conf.c_iflag = IGNPAR;
// output options
serial_conf.c_oflag = 0;
// line options
serial_conf.c_lflag = ICANON;
// flush input
tcflush(fd, TCIFLUSH);
// set new options for the port, TCSANOW:changes occur immediately without waiting for data to complete
tcsetattr(fd, TCSANOW, &serial_conf);
int ret = 0;
int n = 0;
int ival= 0;
char buffer[BUFFERSIZE];
buffer[BUFFERSIZE-2] = '\0';
buffer[BUFFERSIZE-1] = '\n';
cprintf(GREEN,"Ready...\n");
while(ret != GOODBYE){
n = read(fd,buffer,BUFFERSIZE);
#ifdef VERBOSE
cprintf(BLUE,"Received %d Bytes\n", n);
#endif
cprintf(BLUE,"Got message: %s\n",buffer);
switch(buffer[0]){
case 'p':
if (!sscanf(&buffer[1],"%d",&ival)){
cprintf(RED,"Warning: cannot scan voltage value\n");
break;
}
if(i2c_write(ival)<0)
strcpy(buffer,"fail ");
else
strcpy(buffer,"success ");
cprintf(GREEN,"%s\n",buffer);
n = write(fd, buffer, BUFFERSIZE);
#ifdef VERBOSE
cprintf(BLUE,"Sent %d Bytes\n", n);
#endif
break;
case 'g':
ival = i2c_read();
//ok/ fail
if(ival < 0)
strcpy(buffer,"fail ");
else
strcpy(buffer,"success ");
n = write(fd, buffer, BUFFERSIZE);
#ifdef VERBOSE
cprintf(BLUE,"Sent %d Bytes\n", n);
#endif
//value
if(ival >= 0){
cprintf(GREEN,"%d\n",ival);
sprintf(buffer,"%d ",ival);
n = write(fd, buffer, BUFFERSIZE);
#ifdef VERBOSE
cprintf(BLUE,"Sent %d Bytes\n", n);
#endif
}else cprintf(GREEN,"%s\n",buffer);
break;
case 'e':
printf("Exiting Program\n");
ret = GOODBYE;
break;
default:
printf("Unknown Command. buffer:%s\n",buffer);
break;
}
}
close(fd);
printf("Goodbye Serial Communication for HV(9M)\n");
return 0;
}

View File

@ -12,13 +12,7 @@
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <termios.h> // POSIX terminal control definitions(CS8, CREAD, CLOCAL..)
//#include <fstream>
//#include <iomanip>
//#include <sstream>
//#include <time.h>
#include "FebRegisterDefs.h" #include "FebRegisterDefs.h"
#include "FebControl.h" #include "FebControl.h"
@ -68,6 +62,7 @@ double Feb_Control_rate_meas[16384];
double ratemax=-1; double ratemax=-1;
int Feb_Control_activated = 1; int Feb_Control_activated = 1;
int Feb_Control_hv_fd = -1;
void Module_Module(struct Module* mod,unsigned int number, unsigned int address_top){ void Module_Module(struct Module* mod,unsigned int number, unsigned int address_top){
@ -224,10 +219,45 @@ int Feb_Control_Init(int master, int top, int normal, int module_num){
if(Feb_Control_activated) if(Feb_Control_activated)
Feb_Interface_SetByteOrder(); Feb_Interface_SetByteOrder();
return 1;
}
int Feb_Control_OpenSerialCommunication(){
cprintf(BG_BLUE,"opening serial communication of hv\n");
if(Feb_Control_hv_fd != -1)
close(Feb_Control_hv_fd);
Feb_Control_hv_fd = open(SPECIAL9M_HIGHVOLTAGE_PORT, O_RDWR | O_NOCTTY);
if(Feb_Control_hv_fd < 0){
cprintf(RED,"Warning: Unable to open port %s to set up high voltage serial communciation to the blackfin\n", SPECIAL9M_HIGHVOLTAGE_PORT);
return 0;
}
struct termios serial_conf;
// Get the current options for the port
tcgetattr(Feb_Control_hv_fd, &serial_conf);
// reset structure
memset(&serial_conf,0,sizeof(serial_conf));
// control options
serial_conf.c_cflag = B2400 | CS8 | CREAD | CLOCAL;//57600 too high
// input options
serial_conf.c_iflag = IGNPAR;
// output options
serial_conf.c_oflag = 0;
// line options
serial_conf.c_lflag = ICANON;
// flush input
tcflush(Feb_Control_hv_fd, TCIFLUSH);
// set new options for the port, TCSANOW:changes occur immediately without waiting for data to complete
tcsetattr(Feb_Control_hv_fd, TCSANOW, &serial_conf);
return 1; return 1;
} }
void Feb_Control_CloseSerialCommunication(){
if(Feb_Control_hv_fd != -1)
close(Feb_Control_hv_fd);
}
void Feb_Control_PrintModuleList(){ void Feb_Control_PrintModuleList(){
@ -347,7 +377,8 @@ int Feb_Control_CheckSetup(int master){
ok=0; ok=0;
} }
} }
if((Feb_control_master) &&(Module_GetHighVoltage(&modules[i])<0)){ int value = 0;
if((Feb_control_master) && (!Feb_Control_GetHighVoltage(&value))){
cprintf(RED,"Warning: module %d's high voltage not set.\n",Module_GetModuleNumber(&modules[i])); cprintf(RED,"Warning: module %d's high voltage not set.\n",Module_GetModuleNumber(&modules[i]));
ok=0; ok=0;
} }
@ -496,68 +527,135 @@ float Feb_Control_DACToVoltage(unsigned int digital,unsigned int nsteps,float vm
//only master gets to call this function //only master gets to call this function
int Feb_Control_SetHighVoltage(int value){ int Feb_Control_SetHighVoltage(int value){
printf(" Setting High Voltage:\t");
if(!Feb_control_normal){ /*
cprintf(RED,"\nError: Setting High Voltage not implemented for special modules\n"); * maximum voltage of the hv dc/dc converter:
return 0; * 300 for single module power distribution board
} * 200 for 9M power distribution board
* but limit is 200V for both
printf(" Setting High Voltage: %d(v)\t",value); */
const float vmin=0;
static const unsigned int nsteps = 256; float vmax=200;
static const float vmin=0; if(Feb_control_normal)
static const float vmax=300; vmax=300;
const float vlimit=200;
const unsigned int ntotalsteps = 256;
unsigned int nsteps = ntotalsteps*vlimit/vmax;
unsigned int dacval = 0; unsigned int dacval = 0;
//open file
FILE* fd=fopen("/sys/class/hwmon/hwmon5/device/out0_output","w");
if(fd==NULL){
cprintf(RED,"\nWarning: Could not open file for writing to set high voltage\n");
return 0;
}
//calculate dac value //calculate dac value
if(!Feb_Control_VoltageToDAC(value,&dacval,nsteps,vmin,vmax)){ if(!Feb_Control_VoltageToDAC(value,&dacval,nsteps,vmin,vlimit)){
cprintf(RED,"\nWarning: SetHighVoltage bad value, %d. The range is 0 to 300 V.\n",value); cprintf(RED,"\nWarning: SetHighVoltage bad value, %d. The range is 0 to %d V.\n",value, (int)vlimit);
return 0; return -1;
} }
//convert to string, add 0 and write to file printf("(%d dac):\t%dV\n", dacval, value);
fprintf(fd, "%d0\n", dacval);
printf("%d(dac)\n", dacval); return Feb_Control_SendHighVoltage(dacval);
fclose(fd); }
int Feb_Control_GetHighVoltage(int* value){
printf(" Getting High Voltage:\t");
unsigned int dacval = 0;
if(!Feb_Control_ReceiveHighVoltage(&dacval))
return 0;
//ok, convert dac to v
/*
* maximum voltage of the hv dc/dc converter:
* 300 for single module power distribution board
* 200 for 9M power distribution board
* but limit is 200V for both
*/
const float vmin=0;
float vmax=200;
if(Feb_control_normal)
vmax=300;
const float vlimit=200;
const unsigned int ntotalsteps = 256;
unsigned int nsteps = ntotalsteps*vlimit/vmax;
*value = (int)(Feb_Control_DACToVoltage(dacval,nsteps,vmin,vlimit)+0.5);
printf("(%d dac)\t%dV\n", dacval, *value);
return 1; return 1;
} }
int Feb_Control_GetHighVoltage(int* value){ int Feb_Control_SendHighVoltage(int dacvalue){
//normal
if(Feb_control_normal){
//open file
FILE* fd=fopen(NORMAL_HIGHVOLTAGE_OUTPUTPORT,"w");
if(fd==NULL){
cprintf(RED,"\nWarning: Could not open file for writing to set high voltage\n");
return 0;
}
//convert to string, add 0 and write to file
fprintf(fd, "%d0\n", dacvalue);
fclose(fd);
}
if(!Feb_control_normal){ //9m
cprintf(RED,"\nError: Getting High Voltage not implemented for special modules\n"); else{
/*Feb_Control_OpenSerialCommunication();*/
if (Feb_Control_hv_fd == -1){
cprintf(RED,"\nWarning: High voltage serial communication not set up for 9m\n");
return 0; return 0;
} }
printf(" Getting High Voltage: "); char buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE];
static const unsigned int nsteps = 256; buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-2]='\0';
static const float vmin=0; buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1]='\n';
static const float vmax=300; int n = 0;
sprintf(buffer,"p%d ",dacvalue);
n = write(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
#ifdef VERBOSEI
cprintf(BLUE,"Sent %d Bytes\n", n);
#endif
//ok/fail
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
#ifdef VERBOSEI
cprintf(BLUE,"Received %d Bytes\n", n);
#endif
fflush(stdout);
/*Feb_Control_CloseSerialCommunication();*/
if(buffer[0] != 's'){
cprintf(RED,"\nError: Failed to set high voltage\n");
return 0;
}
cprintf(GREEN,"%s\n",buffer);
unsigned int dacval = 0; }
size_t readbytes=0; return 1;
char* line=NULL; }
int Feb_Control_ReceiveHighVoltage(unsigned int* value){
//normal
if(Feb_control_normal){
//open file //open file
FILE* fd=fopen("/sys/class/hwmon/hwmon5/device/in0_input","r"); FILE* fd=fopen(NORMAL_HIGHVOLTAGE_INPUTPORT,"r");
if(fd==NULL){ if(fd==NULL){
cprintf(RED,"\nWarning: Could not open file for writing to get high voltage\n"); cprintf(RED,"\nWarning: Could not open file for writing to get high voltage\n");
return 0; return 0;
} }
// Read twice, since the first value is sometimes outdated
//read, assigning line to null and readbytes to 0 then getline allocates initial buffer
size_t readbytes=0;
char* line=NULL;
if(getline(&line, &readbytes, fd) == -1){ if(getline(&line, &readbytes, fd) == -1){
cprintf(RED,"\nWarning: could not read file to get high voltage\n"); cprintf(RED,"\nWarning: could not read file to get high voltage\n");
return 0; return 0;
} }
//read again to read the updated value
rewind(fd); rewind(fd);
free(line); free(line);
readbytes=0; readbytes=0;
@ -566,19 +664,54 @@ int Feb_Control_GetHighVoltage(int* value){
cprintf(RED,"\nWarning: could not read file to get high voltage\n"); cprintf(RED,"\nWarning: could not read file to get high voltage\n");
return 0; return 0;
} }
// Remove the trailing 0 // Remove the trailing 0
dacval = atoi(line)/10; *value = atoi(line)/10;
//convert dac to v
*value = (int)(Feb_Control_DACToVoltage(dacval,nsteps,vmin,vmax)+0.5);
printf("%d(v)\t%d(dac)\n", *value, dacval);
free(line); free(line);
fclose(fd); fclose(fd);
return 1;
} }
//9m
else{
/*Feb_Control_OpenSerialCommunication();*/
if (Feb_Control_hv_fd == -1){
cprintf(RED,"\nWarning: High voltage serial communication not set up for 9m\n");
return 0;
}
char buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE];
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-2]='\0';
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1]='\n';
int n = 0;
//request
strcpy(buffer,"g ");
n = write(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
#ifdef VERBOSEI
cprintf(BLUE,"Sent %d Bytes\n", n);
#endif
//ok/fail
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
#ifdef VERBOSEI
cprintf(BLUE,"Received %d Bytes\n", n);
#endif
if(buffer[0] != 's'){
cprintf(RED,"\nWarning: failed to read high voltage\n");
return 0;
}
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
#ifdef VERBOSEI
cprintf(BLUE,"Received %d Bytes\n", n);
#endif
/*Feb_Control_OpenSerialCommunication();*/
if (!sscanf(buffer,"%d",value)){
cprintf(RED,"\nWarning: failed to scan high voltage read\n");
return 0;
}
}
return 1;
}

View File

@ -112,6 +112,8 @@ int Feb_Control_GetModuleNumber();
void Feb_Control_FebControl(); void Feb_Control_FebControl();
int Feb_Control_Init(int master, int top, int normal, int module_num); int Feb_Control_Init(int master, int top, int normal, int module_num);
int Feb_Control_OpenSerialCommunication();
void Feb_Control_CloseSerialCommunication();
int Feb_Control_CheckSetup(); int Feb_Control_CheckSetup();
unsigned int Feb_Control_GetNModules(); unsigned int Feb_Control_GetNModules();
@ -120,6 +122,9 @@ int Feb_Control_GetModuleNumber();
int Feb_Control_SetHighVoltage(int value); int Feb_Control_SetHighVoltage(int value);
int Feb_Control_GetHighVoltage(int* value); int Feb_Control_GetHighVoltage(int* value);
int Feb_Control_SendHighVoltage(int dacvalue);
int Feb_Control_ReceiveHighVoltage(unsigned int* value);
int Feb_Control_SetIDelays(unsigned int module_num, unsigned int ndelay_units); int Feb_Control_SetIDelays(unsigned int module_num, unsigned int ndelay_units);
int Feb_Control_SetIDelays1(unsigned int module_num, unsigned int chip_pos, unsigned int ndelay_units); int Feb_Control_SetIDelays1(unsigned int module_num, unsigned int chip_pos, unsigned int ndelay_units);

View File

@ -1,6 +1,7 @@
CC = powerpc-4xx-softfloat-gcc CC = powerpc-4xx-softfloat-gcc
CCX = powerpc-4xx-softfloat-g++ CCX = powerpc-4xx-softfloat-g++
CFLAGS += -Wall -DDACS_INT -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSE #-DVIRTUAL -DPCCOMPILE -DMARTIN BLACKFIN_CC = bfin-uclinux-gcc
CFLAGS += -Wall -DDACS_INT -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE #-DVIRTUAL -DPCCOMPILE -DMARTIN
LDLIBS += -lm -lstdc++ LDLIBS += -lm -lstdc++
PROGS = eigerDetectorServer PROGS = eigerDetectorServer
@ -15,7 +16,7 @@ SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c
OBJS = $(SRC_CLNT:.c=.o) OBJS = $(SRC_CLNT:.c=.o)
all: clean $(PROGS) #feb_debug beb_debug all: clean $(PROGS) hv9m_blackfin_server #feb_debug beb_debug
boot: $(OBJS) boot: $(OBJS)
@ -34,6 +35,11 @@ beb_debug:$(SRC_CLNT3)
$(CCX) -o beb_debug $(SRC_CLNT3) -I. $(CCX) -o beb_debug $(SRC_CLNT3) -I.
mv beb_debug $(DESTDIR) mv beb_debug $(DESTDIR)
clean: hv9m_blackfin_server:9mhvserial_bf.c
rm -rf $(DESTDIR)/$(PROGS) *.o $(BLACKFIN_CC) -o hv9m_blackfin_server 9mhvserial_bf.c -Wall #-DVERBOSE
mv hv9m_blackfin_server $(DESTDIR)
rm hv9m_blackfin_server.gdb
clean:
rm -rf $(DESTDIR)/$(PROGS) *.o $(DESTDIR)/hv9m_blackfin_server

View File

@ -144,6 +144,11 @@ int initDetector(){
Feb_Interface_FebInterface(); Feb_Interface_FebInterface();
Feb_Control_FebControl(); Feb_Control_FebControl();
Feb_Control_Init(master,top,normal, getDetectorNumber()); Feb_Control_Init(master,top,normal, getDetectorNumber());
//master of 9M, check high voltage serial communication to blackfin
if(master && !normal){
if(Feb_Control_OpenSerialCommunication())
;// Feb_Control_CloseSerialCommunication();
}
printf("FEB Initialization done\n"); printf("FEB Initialization done\n");
Beb_Beb(); Beb_Beb();
printf("BEB Initialization done\n"); printf("BEB Initialization done\n");
@ -162,7 +167,6 @@ int initDetector(){
eiger_photonenergy = -1; eiger_photonenergy = -1;
setReadOutFlags(NONPARALLEL); setReadOutFlags(NONPARALLEL);
setSpeed(0,1);//clk_devider,half speed setSpeed(0,1);//clk_devider,half speed
setHighVoltage(0,0);
setIODelay(650,0); setIODelay(650,0);
setTiming(AUTO_TIMING); setTiming(AUTO_TIMING);
//SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15); //SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15);
@ -170,6 +174,7 @@ int initDetector(){
int enable[2] = {0,1}; int enable[2] = {0,1};
setExternalGating(enable);//disable external gating setExternalGating(enable);//disable external gating
Feb_Control_SetInTestModeVariable(0); Feb_Control_SetInTestModeVariable(0);
setHighVoltage(0,0);
Feb_Control_CheckSetup(); Feb_Control_CheckSetup();
//print detector mac and ip //print detector mac and ip
@ -436,13 +441,18 @@ void setDAC(enum detDacIndex ind, int val, int imod, int mV, int retval[]){
int setHighVoltage(int val, int imod){ int setHighVoltage(int val, int imod){
if(val!=-1){ if(val!=-1){
eiger_highvoltage = val; eiger_highvoltage = val;
if(master) if(master){
Feb_Control_SetHighVoltage(val); int ret = Feb_Control_SetHighVoltage(val);
if(!ret) //could not set
return -2;
else if (ret == -1) //outside range
return -1;
}
} }
if(master && !Feb_Control_GetHighVoltage(&eiger_highvoltage)){ if(master && !Feb_Control_GetHighVoltage(&eiger_highvoltage)){
cprintf(RED,"Warning: Could not read high voltage\n"); cprintf(RED,"Warning: Could not read high voltage\n");
return 0; return -3;
} }
return eiger_highvoltage; return eiger_highvoltage;
} }

View File

@ -44,6 +44,11 @@ enum detAdcIndex{TEMP_FPGAEXT, TEMP_10GE, TEMP_DCDC, TEMP_SODL, TEMP_SODR, TEMP_
enum detNetworkParameter{TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G}; enum detNetworkParameter{TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G};
#define NORMAL_HIGHVOLTAGE_INPUTPORT "/sys/class/hwmon/hwmon5/device/in0_input"
#define NORMAL_HIGHVOLTAGE_OUTPUTPORT "/sys/class/hwmon/hwmon5/device/out0_output"
#define SPECIAL9M_HIGHVOLTAGE_PORT "/dev/ttyS1"
#define SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE 16
#endif /* SLSDETECTORSERVER_DEFS_H_ */ #endif /* SLSDETECTORSERVER_DEFS_H_ */

View File

@ -1259,7 +1259,9 @@ int set_dac(int file_des) {
#endif #endif
//takes time to set high voltage, so no check for it //takes time to set high voltage, so no check for it
if(ret == OK && ind != HV_POT && ind != HV_NEW){ if(ret == OK){
if(ind != HV_POT && ind != HV_NEW){
if(mV) if(mV)
temp = retval[1]; temp = retval[1];
else else
@ -1270,6 +1272,18 @@ int set_dac(int file_des) {
ret=FAIL; ret=FAIL;
printf("Setting dac %d of module %d: wrote %d but read %d\n", idac, imod, val, temp); printf("Setting dac %d of module %d: wrote %d but read %d\n", idac, imod, val, temp);
} }
}else {
if(retval[0] < 0){
if(retval[0] == -1)
sprintf(mess, "Setting high voltage failed.Bad value %d. The range is from 0 to 200 V.\n",val);
else if(retval[0] == -2)
strcpy(mess, "Setting high voltage failed. Serial/i2c communication failed.\n");
else if(retval[0] == -3)
strcpy(mess, "Getting high voltage failed. Serial/i2c communication failed.\n");
ret = FAIL;
}
}
} }
if(ret == OK && differentClients) if(ret == OK && differentClients)