diff --git a/slsDetectorSoftware/eigerDetectorServer/9mhvserial_bf.c b/slsDetectorSoftware/eigerDetectorServer/9mhvserial_bf.c index 4e4ee0ac6..fbedbeefa 100644 --- a/slsDetectorSoftware/eigerDetectorServer/9mhvserial_bf.c +++ b/slsDetectorSoftware/eigerDetectorServer/9mhvserial_bf.c @@ -8,6 +8,7 @@ #include // read, close #include // memset #include // I2C_SLAVE, __u8 reg +#include #define PORTNAME "/dev/ttyBF1" #define GOODBYE 200 @@ -89,37 +90,40 @@ int i2c_write(unsigned int value){ int main(int argc, char* argv[]) { - int fd = open(PORTNAME, O_RDWR | O_NOCTTY); + int fd = open(PORTNAME, O_RDWR | O_NOCTTY | O_SYNC); 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; + serial_conf.c_iflag = 0;//IGNPAR; (stuck because it was in ignore parity) // output options serial_conf.c_oflag = 0; // line options serial_conf.c_lflag = ICANON; // flush input - tcflush(fd, TCIFLUSH); + if(tcflush(fd, TCIFLUSH) < 0){ + cprintf(RED,"Warning: error form tcflush %d\n", errno); + return 0; + } // set new options for the port, TCSANOW:changes occur immediately without waiting for data to complete - tcsetattr(fd, TCSANOW, &serial_conf); - - + if(tcsetattr(fd, TCSANOW, &serial_conf) < 0){ + cprintf(RED,"Warning: error form tcsetattr %d\n", errno); + return 0; + } int ret = 0; int n = 0; int ival= 0; char buffer[BUFFERSIZE]; + memset(buffer,0,BUFFERSIZE); buffer[BUFFERSIZE-2] = '\0'; buffer[BUFFERSIZE-1] = '\n'; cprintf(GREEN,"Ready...\n"); diff --git a/slsDetectorSoftware/eigerDetectorServer/FebControl.c b/slsDetectorSoftware/eigerDetectorServer/FebControl.c index de207f7f3..25bc2b44b 100644 --- a/slsDetectorSoftware/eigerDetectorServer/FebControl.c +++ b/slsDetectorSoftware/eigerDetectorServer/FebControl.c @@ -13,6 +13,7 @@ #include #include #include // POSIX terminal control definitions(CS8, CREAD, CLOCAL..) +#include #include "FebRegisterDefs.h" #include "FebControl.h" @@ -225,31 +226,35 @@ int Feb_Control_Init(int master, int top, int normal, int module_num){ int Feb_Control_OpenSerialCommunication(){ cprintf(BG_BLUE,"opening serial communication of hv\n"); - if(Feb_Control_hv_fd != -1) + //if(Feb_Control_hv_fd != -1) close(Feb_Control_hv_fd); - Feb_Control_hv_fd = open(SPECIAL9M_HIGHVOLTAGE_PORT, O_RDWR | O_NOCTTY); + Feb_Control_hv_fd = open(SPECIAL9M_HIGHVOLTAGE_PORT, O_RDWR | O_NOCTTY | O_SYNC); 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)); + 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; + serial_conf.c_iflag = 0;//IGNPAR; (stuck because it was in ignore parity) // output options serial_conf.c_oflag = 0; // line options serial_conf.c_lflag = ICANON; // flush input - tcflush(Feb_Control_hv_fd, TCIFLUSH); + if(tcflush(Feb_Control_hv_fd, TCIFLUSH) < 0){ + cprintf(RED,"Warning: error form tcflush %d\n", errno); + return 0; + } // set new options for the port, TCSANOW:changes occur immediately without waiting for data to complete - tcsetattr(Feb_Control_hv_fd, TCSANOW, &serial_conf); + if(tcsetattr(Feb_Control_hv_fd, TCSANOW, &serial_conf) < 0){ + cprintf(RED,"Warning: error form tcsetattr %d\n", errno); + return 0; + } return 1; } @@ -605,6 +610,7 @@ int Feb_Control_SendHighVoltage(int dacvalue){ } char buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE]; + memset(buffer,0,SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE); buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-2]='\0'; buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1]='\n'; int n; diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.0.0.16.0 b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.0.0.16.1 similarity index 57% rename from slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.0.0.16.0 rename to slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.0.0.16.1 index d7836a000..0dd6872d3 100755 Binary files a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.0.0.16.0 and b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.0.0.16.1 differ diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/hv9m_blackfin_server b/slsDetectorSoftware/eigerDetectorServer/bin/hv9m_blackfin_server new file mode 100755 index 000000000..6aa6ff9eb Binary files /dev/null and b/slsDetectorSoftware/eigerDetectorServer/bin/hv9m_blackfin_server differ