mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 03:40:04 +02:00
eigerserver changes, need to include martins changes
This commit is contained in:
parent
1ed4407c11
commit
5dd2f273fc
@ -102,13 +102,13 @@ int main(int argc, char* argv[]) {
|
|||||||
// control options
|
// control options
|
||||||
serial_conf.c_cflag = B2400 | CS8 | CREAD | CLOCAL;
|
serial_conf.c_cflag = B2400 | CS8 | CREAD | CLOCAL;
|
||||||
// input options
|
// input options
|
||||||
serial_conf.c_iflag = 0;//IGNPAR; (stuck because it was in ignore parity)
|
serial_conf.c_iflag = IGNPAR;
|
||||||
// output options
|
// output options
|
||||||
serial_conf.c_oflag = 0;
|
serial_conf.c_oflag = 0;
|
||||||
// line options
|
// line options
|
||||||
serial_conf.c_lflag = ICANON;
|
serial_conf.c_lflag = ICANON;
|
||||||
// flush input
|
// flush input
|
||||||
if(tcflush(fd, TCIFLUSH) < 0){
|
if(tcflush(fd, TCIOFLUSH) < 0){
|
||||||
cprintf(RED,"Warning: error form tcflush %d\n", errno);
|
cprintf(RED,"Warning: error form tcflush %d\n", errno);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -118,17 +118,39 @@ int main(int argc, char* argv[]) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(tcsetattr(fd, TCSAFLUSH, &serial_conf) < 0){
|
||||||
|
cprintf(RED,"Warning: error form tcsetattr %d\n", errno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int ival= 0;
|
int ival= 0;
|
||||||
char buffer[BUFFERSIZE];
|
char buffer[BUFFERSIZE];
|
||||||
memset(buffer,0,BUFFERSIZE);
|
memset(buffer,0,BUFFERSIZE);
|
||||||
buffer[BUFFERSIZE-2] = '\0';
|
|
||||||
buffer[BUFFERSIZE-1] = '\n';
|
buffer[BUFFERSIZE-1] = '\n';
|
||||||
cprintf(GREEN,"Ready...\n");
|
cprintf(GREEN,"Ready...\n");
|
||||||
|
|
||||||
|
/*
|
||||||
|
int once = 1;
|
||||||
|
while(strcmp(buffer,"start")){
|
||||||
|
if(once){
|
||||||
|
once=0;
|
||||||
|
cprintf(MAGENTA,"in the loop, checking\n");
|
||||||
|
}
|
||||||
|
memset(buffer,0,BUFFERSIZE);
|
||||||
|
n = read(fd,buffer,BUFFERSIZE);
|
||||||
|
//#ifdef VERBOSE
|
||||||
|
cprintf(BLUE,"Received %d Bytes\n", n);
|
||||||
|
//#endif
|
||||||
|
cprintf(BLUE,"Got message: %s\n",buffer);
|
||||||
|
}
|
||||||
|
cprintf(GREEN,"started\n");
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
while(ret != GOODBYE){
|
while(ret != GOODBYE){
|
||||||
|
memset(buffer,0,BUFFERSIZE);
|
||||||
n = read(fd,buffer,BUFFERSIZE);
|
n = read(fd,buffer,BUFFERSIZE);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cprintf(BLUE,"Received %d Bytes\n", n);
|
cprintf(BLUE,"Received %d Bytes\n", n);
|
||||||
@ -141,7 +163,9 @@ int main(int argc, char* argv[]) {
|
|||||||
cprintf(RED,"Warning: cannot scan voltage value\n");
|
cprintf(RED,"Warning: cannot scan voltage value\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// ok/ fail
|
||||||
|
memset(buffer,0,BUFFERSIZE);
|
||||||
|
buffer[BUFFERSIZE-1] = '\n';
|
||||||
if(i2c_write(ival)<0)
|
if(i2c_write(ival)<0)
|
||||||
strcpy(buffer,"fail ");
|
strcpy(buffer,"fail ");
|
||||||
else
|
else
|
||||||
@ -156,6 +180,8 @@ int main(int argc, char* argv[]) {
|
|||||||
case 'g':
|
case 'g':
|
||||||
ival = i2c_read();
|
ival = i2c_read();
|
||||||
//ok/ fail
|
//ok/ fail
|
||||||
|
memset(buffer,0,BUFFERSIZE);
|
||||||
|
buffer[BUFFERSIZE-1] = '\n';
|
||||||
if(ival < 0)
|
if(ival < 0)
|
||||||
strcpy(buffer,"fail ");
|
strcpy(buffer,"fail ");
|
||||||
else
|
else
|
||||||
@ -165,6 +191,8 @@ int main(int argc, char* argv[]) {
|
|||||||
cprintf(BLUE,"Sent %d Bytes\n", n);
|
cprintf(BLUE,"Sent %d Bytes\n", n);
|
||||||
#endif
|
#endif
|
||||||
//value
|
//value
|
||||||
|
memset(buffer,0,BUFFERSIZE);
|
||||||
|
buffer[BUFFERSIZE-1] = '\n';
|
||||||
if(ival >= 0){
|
if(ival >= 0){
|
||||||
cprintf(GREEN,"%d\n",ival);
|
cprintf(GREEN,"%d\n",ival);
|
||||||
sprintf(buffer,"%d ",ival);
|
sprintf(buffer,"%d ",ival);
|
||||||
@ -180,7 +208,7 @@ int main(int argc, char* argv[]) {
|
|||||||
ret = GOODBYE;
|
ret = GOODBYE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("Unknown Command. buffer:%s\n",buffer);
|
printf("Unknown Command. buffer:[%s]\n",buffer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,13 +240,13 @@ int Feb_Control_OpenSerialCommunication(){
|
|||||||
// control options
|
// control options
|
||||||
serial_conf.c_cflag = B2400 | CS8 | CREAD | CLOCAL;//57600 too high
|
serial_conf.c_cflag = B2400 | CS8 | CREAD | CLOCAL;//57600 too high
|
||||||
// input options
|
// input options
|
||||||
serial_conf.c_iflag = 0;//IGNPAR; (stuck because it was in ignore parity)
|
serial_conf.c_iflag = IGNPAR;
|
||||||
// output options
|
// output options
|
||||||
serial_conf.c_oflag = 0;
|
serial_conf.c_oflag = 0;
|
||||||
// line options
|
// line options
|
||||||
serial_conf.c_lflag = ICANON;
|
serial_conf.c_lflag = ICANON;
|
||||||
// flush input
|
// flush input
|
||||||
if(tcflush(Feb_Control_hv_fd, TCIFLUSH) < 0){
|
if(tcflush(Feb_Control_hv_fd, TCIOFLUSH) < 0){
|
||||||
cprintf(RED,"Warning: error form tcflush %d\n", errno);
|
cprintf(RED,"Warning: error form tcflush %d\n", errno);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -255,7 +255,23 @@ int Feb_Control_OpenSerialCommunication(){
|
|||||||
cprintf(RED,"Warning: error form tcsetattr %d\n", errno);
|
cprintf(RED,"Warning: error form tcsetattr %d\n", errno);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if(tcsetattr(Feb_Control_hv_fd, TCSAFLUSH, &serial_conf) < 0){
|
||||||
|
cprintf(RED,"Warning: error form tcsetattr %d\n", errno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
//send start
|
||||||
|
char buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE];
|
||||||
|
memset(buffer,0,SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||||
|
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1] = '\n';
|
||||||
|
strcpy(buffer,"start");
|
||||||
|
int n = write(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||||
|
if (n < 0) {
|
||||||
|
cprintf(RED,"\nWarning: Error writing to i2c bus\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,7 +627,6 @@ int Feb_Control_SendHighVoltage(int dacvalue){
|
|||||||
|
|
||||||
char buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE];
|
char buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE];
|
||||||
memset(buffer,0,SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
memset(buffer,0,SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||||
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-2]='\0';
|
|
||||||
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1]='\n';
|
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1]='\n';
|
||||||
int n;
|
int n;
|
||||||
sprintf(buffer,"p%d",dacvalue);
|
sprintf(buffer,"p%d",dacvalue);
|
||||||
@ -624,6 +639,8 @@ int Feb_Control_SendHighVoltage(int dacvalue){
|
|||||||
cprintf(BLUE,"Sent %d Bytes\n", n);
|
cprintf(BLUE,"Sent %d Bytes\n", n);
|
||||||
#endif
|
#endif
|
||||||
//ok/fail
|
//ok/fail
|
||||||
|
memset(buffer,0,SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||||
|
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1] = '\n';
|
||||||
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
cprintf(RED,"\nWarning: Error reading from i2c bus\n");
|
cprintf(RED,"\nWarning: Error reading from i2c bus\n");
|
||||||
@ -694,10 +711,10 @@ int Feb_Control_ReceiveHighVoltage(unsigned int* value){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
char buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE];
|
char buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE];
|
||||||
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-2]='\0';
|
|
||||||
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1]='\n';
|
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1]='\n';
|
||||||
int n = 0;
|
int n = 0;
|
||||||
//request
|
//request
|
||||||
|
|
||||||
strcpy(buffer,"g ");
|
strcpy(buffer,"g ");
|
||||||
n = write(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
n = write(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
@ -709,6 +726,8 @@ int Feb_Control_ReceiveHighVoltage(unsigned int* value){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//ok/fail
|
//ok/fail
|
||||||
|
memset(buffer,0,SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||||
|
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1] = '\n';
|
||||||
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
cprintf(RED,"\nWarning: Error reading from i2c bus\n");
|
cprintf(RED,"\nWarning: Error reading from i2c bus\n");
|
||||||
@ -722,6 +741,8 @@ int Feb_Control_ReceiveHighVoltage(unsigned int* value){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(buffer,0,SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||||
|
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1] = '\n';
|
||||||
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
cprintf(RED,"\nWarning: Error reading from i2c bus\n");
|
cprintf(RED,"\nWarning: Error reading from i2c bus\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user