setting and getting printouts, changed the rx mess to 1000

This commit is contained in:
Dhanya Maliakal 2016-11-07 15:34:47 +01:00
parent 8caa9d8779
commit e4dcd1cb6b
7 changed files with 66 additions and 45 deletions

View File

@ -1177,7 +1177,10 @@ int64_t get64BitReg(int aLSB, int aMSB){
int64_t setFrames(int64_t value){
if(value!=-1)
printf("\nSetting number of frames to %lld\n",(long long int)value);
return set64BitReg(value, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
int64_t retval = set64BitReg(value, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
printf("Getting number of frames: %lld\n",(long long int)retval);
return retval;
}
int64_t getFrames(){
@ -1186,10 +1189,12 @@ int64_t getFrames(){
int64_t setExposureTime(int64_t value){
if (value!=-1){
printf("\nSetting exptime to %lld\n",(long long int)value);
printf("\nSetting exptime to %lldns\n",(long long int)value);
value*=(1E-3*clockdivider);
}
return set64BitReg(value,SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG)/(1E-3*clockdivider);//(1E-9*CLK_FREQ);
int64_t retval = set64BitReg(value,SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG)/(1E-3*clockdivider);//(1E-9*CLK_FREQ);
printf("Getting exptime: %lldns\n",(long long int)retval);
return retval;
}
int64_t getExposureTime(){
@ -1199,7 +1204,10 @@ int64_t getExposureTime(){
int64_t setGates(int64_t value){
if(value!=-1)
printf("\nSetting number of gates to %lld\n",(long long int)value);
return set64BitReg(value, SET_GATES_LSB_REG, SET_GATES_MSB_REG);
int64_t retval = set64BitReg(value, SET_GATES_LSB_REG, SET_GATES_MSB_REG);
printf("Getting number of gates: %lld\n",(long long int)retval);
return retval;
}
int64_t getGates(){
@ -1208,11 +1216,13 @@ int64_t getGates(){
int64_t setPeriod(int64_t value){
if (value!=-1){
printf("\nSetting period to %lld\n",(long long int)value);
printf("\nSetting period to %lldns\n",(long long int)value);
value*=(1E-3*clockdivider);
}
return set64BitReg(value,SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG)/(1E-3*clockdivider);//(1E-9*CLK_FREQ);
int64_t retval = set64BitReg(value,SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG)/(1E-3*clockdivider);//(1E-9*CLK_FREQ);
printf("Getting period: %lldns\n",(long long int)retval);
return retval;
}
int64_t getPeriod(){
@ -1221,10 +1231,13 @@ int64_t getPeriod(){
int64_t setDelay(int64_t value){
if (value!=-1){
printf("\nSetting delay to %lld\n",(long long int)value);
printf("\nSetting delay to %lldns\n",(long long int)value);
value*=(1E-3*clockdivider);
}
return set64BitReg(value,SET_DELAY_LSB_REG, SET_DELAY_MSB_REG)/(1E-3*clockdivider);//(1E-9*CLK_FREQ);
int64_t retval = set64BitReg(value,SET_DELAY_LSB_REG, SET_DELAY_MSB_REG)/(1E-3*clockdivider);//(1E-9*CLK_FREQ);
printf("Getting delay: %lldns\n",(long long int)retval);
return retval;
}
int64_t getDelay(){
@ -1234,7 +1247,10 @@ int64_t getDelay(){
int64_t setTrains(int64_t value){
if(value!=-1)
printf("\nSetting number of cycles to %lld\n",(long long int)value);
return set64BitReg(value, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
int64_t retval = set64BitReg(value, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
printf("Getting number of cycles: %lld\n",(long long int)retval);
return retval;
}
int64_t getTrains(){
@ -1589,7 +1605,7 @@ int configureInterface(uint32_t destip,uint64_t destmac,uint64_t sourcemac,int
//int configureMAC(int ipad,long long int macad,long long int detectormacad, int detipad, int ival, int udpport){
volatile u_int32_t conf= bus_r(CONFIG_REG);
/*volatile u_int32_t conf= bus_r(CONFIG_REG);*/
long int checksum=calcChecksum(sourceip, destip);
#ifdef NEW_GBE_INTERFACE
@ -1679,7 +1695,6 @@ int configureMAC(uint32_t destip,uint64_t destmac,uint64_t sourcemac,int source
uint32_t sourceport = 0x7e9a; // 0xE185;
int interface=0;
int ngb;
volatile u_int32_t conf= bus_r(CONFIG_REG);
#ifdef NEW_GBE_INTERFACE
ngb=2;
@ -1760,7 +1775,7 @@ int startStateMachine(){
int stopStateMachine(){
//#ifdef VERBOSE
printf("*******Stopping State Machine*******\n");
cprintf(BG_RED,"*******Stopping State Machine*******\n");
//#endif
#ifdef SHAREDMEMORY
write_stop_sm(1);

View File

@ -1603,7 +1603,12 @@ int start_acquisition(int file_des) {
if (differentClients==1 && lockStatus==1) {
ret=FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
} else {
} else if (setPeriod(-1)==0){
ret=FAIL;
sprintf(mess,"Frame Period is 0. Set it to start acquisition\n");
cprintf(RED,"%s",mess);
}
else {
ret=startStateMachine();
}
if (ret==FAIL)
@ -1754,7 +1759,7 @@ int get_run_status(int file_des) {
}
int read_frame(int file_des) {
dataret=FAIL;
if (differentClients==1 && lockStatus==1) {
dataret=FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
@ -1772,19 +1777,17 @@ int read_frame(int file_des) {
if (getFrames()+1>0) {
dataret=FAIL;
sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()+1));
cprintf(RED,"%s\n",mess);
} else {
dataret=FINISHED;
sprintf(mess,"acquisition successfully finished\n");
printf("%s",mess);
if (differentClients)
dataret=FORCE_UPDATE;
}
#endif
sendDataOnly(file_des,&dataret,sizeof(dataret));
sendDataOnly(file_des,mess,sizeof(mess));
if(dataret == FAIL)
cprintf(RED,"%s\n",mess);
else
printf("%s",mess);
return dataret;
}
@ -1833,7 +1836,6 @@ int set_timer(int file_des) {
int64_t retval;
int ret=OK;
sprintf(mess,"can't set timer\n");
n = receiveDataOnly(file_des,&ind,sizeof(ind));
@ -1891,16 +1893,19 @@ int set_timer(int file_des) {
}
}
}
if (ret!=OK) {
printf(mess);
if (differentClients)
ret=FORCE_UPDATE;
if(ret == OK && (retval!=tns) && (tns != -1)){
ret = FAIL;
sprintf(mess,"Setting timer %d of failed: wrote %lld but read %lld\n", ind, (long long int)tns, (long long int)retval);
cprintf(RED,"%s",mess);
}else if (ret!=OK) {
cprintf(RED,"%s",mess);
cprintf(RED,"set timer failed\n");
}
if (ret!=OK) {
printf(mess);
printf("set timer failed\n");
}
if (ret==OK && differentClients)
ret=FORCE_UPDATE;
n = sendDataOnly(file_des,&ret,sizeof(ret));
if (ret==FAIL) {
@ -2024,7 +2029,6 @@ int set_dynamic_range(int file_des) {
int retval;
int ret=OK;
printf("Set dynamic range\n");
sprintf(mess,"can't set dynamic range\n");

View File

@ -1350,7 +1350,6 @@ int multiSlsDetector::startAcquisition(){
int multiSlsDetector::stopAcquisition(){
int i=0;
int ret=OK, ret1=OK;
@ -1447,7 +1446,8 @@ int* multiSlsDetector::getDataFromDetector() {
}
//eiger returns only null
if(getDetectorsType() == EIGER)
detectorType types = getDetectorsType();
if(types == EIGER || types == JUNGFRAU)
return NULL;
if (nodatadet>=0) {

View File

@ -3640,7 +3640,6 @@ int slsDetector::startAcquisition(){
};
int slsDetector::stopAcquisition(){
int fnum=F_STOP_ACQUISITION;
int ret=FAIL;
char mess[MAX_STR_LENGTH]="";
@ -4088,20 +4087,22 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
args[1] = timerValue[ACQUISITION_TIME];
}
char mess[MAX_STR_LENGTH]="";
if (connectData() == OK)
ret=thisReceiver->sendIntArray(fnum2,retval,args);
ret=thisReceiver->sendIntArray(fnum2,retval,args,mess);
disconnectData();
if((args[1] != retval)|| (ret==FAIL)){
ret = FAIL;
if(index==FRAME_PERIOD){
//exptime sent if acq period = 0
if(retval){
cout << "ERROR:Acquisition Period in receiver set incorrectly to " << retval << " instead of " << args[1] << endl;
if(strstr(mess,"receiver not idle")==NULL)
cout << "ERROR:Acquisition Period in receiver set incorrectly to " << retval << " instead of " << args[1] << endl;
setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET));
}
}else{
cout << "ERROR:Number of Frames (* Number of cycles) in receiver set incorrectly to " << retval << " instead of " << args[1] << endl;
if(strstr(mess,"receiver not idle")==NULL)
cout << "ERROR:Number of Frames (* Number of cycles) in receiver set incorrectly to " << retval << " instead of " << args[1] << endl;
setErrorMask((getErrorMask())|(RECEIVER_FRAME_NUM_NOT_SET));
}
}

View File

@ -23,7 +23,7 @@ receiverInterface::~receiverInterface(){
int receiverInterface::sendString(int fnum, char retval[], char arg[]){
int ret = slsDetectorDefs::FAIL;
char mess[100] = "";
char mess[MAX_STR_LENGTH] = "";
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(arg,MAX_STR_LENGTH);
@ -42,7 +42,7 @@ int receiverInterface::sendString(int fnum, char retval[], char arg[]){
int receiverInterface::sendUDPDetails(int fnum, char retval[], char arg[3][MAX_STR_LENGTH]){
char args[3][MAX_STR_LENGTH];
int ret = slsDetectorDefs::FAIL;
char mess[100] = "";
char mess[MAX_STR_LENGTH] = "";
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(arg,sizeof(args));
@ -60,7 +60,7 @@ int receiverInterface::sendUDPDetails(int fnum, char retval[], char arg[3][MAX_S
int receiverInterface::sendInt(int fnum, int &retval, int arg){
int ret = slsDetectorDefs::FAIL;
char mess[100] = "";
char mess[MAX_STR_LENGTH] = "";
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(&arg,sizeof(arg));
@ -78,7 +78,7 @@ int receiverInterface::sendInt(int fnum, int &retval, int arg){
int receiverInterface::getInt(int fnum, int &retval){
int ret = slsDetectorDefs::FAIL;
char mess[100] = "";
char mess[MAX_STR_LENGTH] = "";
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
@ -95,7 +95,7 @@ int receiverInterface::getInt(int fnum, int &retval){
int receiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){
int ret = slsDetectorDefs::FAIL;
char mess[100] = "";
char mess[MAX_STR_LENGTH] = "";
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(&arg,sizeof(arg));
@ -111,15 +111,15 @@ int receiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){
int receiverInterface::sendIntArray(int fnum, int64_t &retval, int64_t arg[2]){
int receiverInterface::sendIntArray(int fnum, int64_t &retval, int64_t arg[2], char mess[]){
int64_t args[2];
char messs[MAX_STR_LENGTH];
int ret = slsDetectorDefs::FAIL;
char mess[100] = "";
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(arg,sizeof(args));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==slsDetectorDefs::FAIL){
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
dataSocket->ReceiveDataOnly(mess,sizeof(messs));
std::cout<< "Receiver returned error: " << mess << std::endl;
}
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
@ -132,7 +132,7 @@ int receiverInterface::sendIntArray(int fnum, int64_t &retval, int64_t arg[2]){
int receiverInterface::sendIntArray(int fnum, int &retval, int arg[2]){
int args[2];
int ret = slsDetectorDefs::FAIL;
char mess[100] = "";
char mess[MAX_STR_LENGTH] = "";
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->SendDataOnly(arg,sizeof(args));
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));

View File

@ -91,9 +91,10 @@ public:
* @param fnum function enum to determine what parameter
* @param retval return value
* @param arg values to send
* @param mess message returned
* \returns success of operation
*/
int sendIntArray(int fnum, int64_t &retval, int64_t arg[2]);
int sendIntArray(int fnum, int64_t &retval, int64_t arg[2],char mess[]);
/**