diff --git a/slsDetectorSoftware/mythen3DetectorServer/bf_init.sh b/slsDetectorSoftware/mythen3DetectorServer/bf_init.sh new file mode 100755 index 000000000..88eccadb4 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/bf_init.sh @@ -0,0 +1 @@ +export PATH=/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin:$PATH diff --git a/slsDetectorSoftware/mythen3DetectorServer/err.txt b/slsDetectorSoftware/mythen3DetectorServer/err.txt new file mode 100644 index 000000000..530f6676f --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/err.txt @@ -0,0 +1,602 @@ +rm -rf mythen3Server *.o +echo slsDetectorServer.o mythen3Server_funcs.o communication_funcs.o mythen3FunctionList.o +slsDetectorServer.o mythen3Server_funcs.o communication_funcs.o mythen3FunctionList.o +bfin-uclinux-gcc slsDetectorServer.c mythen3Server_funcs.c communication_funcs.c mythen3FunctionList.c -Wall -DVIRTUAL -DDACS_INT -DMYTHEN3D -DVERBOSE -DSLS_DETECTOR_FUNCTION_LIST -lm -I. -I../../slsReceiverSoftware/include/ -o mythen3Server +In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:27, + from communication_funcs.h:7, + from mythen3Server_funcs.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/uio.h: In function ‘setDAC’: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/uio.h:40: error: storage class specified for parameter ‘readv’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/uio.h:50: error: storage class specified for parameter ‘writev’ +In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:35, + from communication_funcs.h:7, + from mythen3Server_funcs.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/socket.h:36: error: storage class specified for parameter ‘socklen_t’ +In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/socket.h:142, + from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:35, + from communication_funcs.h:7, + from mythen3Server_funcs.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/sockaddr.h:29: error: storage class specified for parameter ‘sa_family_t’ +In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:35, + from communication_funcs.h:7, + from mythen3Server_funcs.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/socket.h:147: error: expected specifier-qualifier-list before ‘sa_family_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/socket.h:164: error: expected specifier-qualifier-list before ‘sa_family_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/socket.h:223: error: expected specifier-qualifier-list before ‘socklen_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/socket.h:271: error: storage class specified for parameter ‘__cmsg_nxthdr’ +In file included from communication_funcs.h:7, + from mythen3Server_funcs.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:100: error: storage class specified for parameter ‘socket’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:107: error: storage class specified for parameter ‘socketpair’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:110: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:111: error: storage class specified for parameter ‘bind’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:115: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:115: error: storage class specified for parameter ‘getsockname’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:124: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:124: error: storage class specified for parameter ‘connect’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:129: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:129: error: storage class specified for parameter ‘getpeername’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:136: error: storage class specified for parameter ‘send’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:143: error: storage class specified for parameter ‘recv’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:152: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:152: error: storage class specified for parameter ‘sendto’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:163: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:163: error: storage class specified for parameter ‘recvfrom’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:172: error: storage class specified for parameter ‘sendmsg’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:179: error: storage class specified for parameter ‘recvmsg’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:187: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:187: error: storage class specified for parameter ‘getsockopt’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:193: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:193: error: storage class specified for parameter ‘setsockopt’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:199: error: storage class specified for parameter ‘listen’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:210: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:210: error: storage class specified for parameter ‘accept’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:218: error: storage class specified for parameter ‘shutdown’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/socket.h:231: error: storage class specified for parameter ‘isfdtype’ +In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:23, + from communication_funcs.h:10, + from mythen3Server_funcs.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:93: error: storage class specified for parameter ‘in_port_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:137: error: storage class specified for parameter ‘in_addr_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:140: error: expected specifier-qualifier-list before ‘in_addr_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:207: error: storage class specified for parameter ‘in6addr_any’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:208: error: storage class specified for parameter ‘in6addr_loopback’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:223: error: expected specifier-qualifier-list before ‘sa_family_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:238: error: expected specifier-qualifier-list before ‘sa_family_t’ +In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:23, + from communication_funcs.h:10, + from mythen3Server_funcs.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:357: error: storage class specified for parameter ‘ntohl’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:359: error: storage class specified for parameter ‘ntohs’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:361: error: storage class specified for parameter ‘htonl’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:363: error: storage class specified for parameter ‘htons’ +In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:23, + from communication_funcs.h:10, + from mythen3Server_funcs.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:431: error: storage class specified for parameter ‘bindresvport’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netinet/in.h:435: error: storage class specified for parameter ‘bindresvport6’ +In file included from communication_funcs.h:10, + from mythen3Server_funcs.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:35: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inet_addr’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:38: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inet_lnaof’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:42: error: expected ‘)’ before ‘__net’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:46: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inet_netof’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:50: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inet_network’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:54: error: storage class specified for parameter ‘inet_ntoa’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:56: error: storage class specified for parameter ‘inet_ntoa_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:62: error: storage class specified for parameter ‘inet_pton’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:68: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:69: error: storage class specified for parameter ‘inet_ntop’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:76: error: storage class specified for parameter ‘inet_aton’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:80: error: expected ‘)’ before ‘__net’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:86: error: storage class specified for parameter ‘inet_net_ntop’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:92: error: storage class specified for parameter ‘inet_net_pton’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:98: error: storage class specified for parameter ‘inet_nsap_addr’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/arpa/inet.h:103: error: storage class specified for parameter ‘inet_nsap_ntoa’ +In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:33, + from communication_funcs.h:11, + from mythen3Server_funcs.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/rpc/netdb.h:53: error: storage class specified for parameter ‘setrpcent’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/rpc/netdb.h:54: error: storage class specified for parameter ‘endrpcent’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/rpc/netdb.h:55: error: storage class specified for parameter ‘getrpcbyname’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/rpc/netdb.h:56: error: storage class specified for parameter ‘getrpcbynumber’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/rpc/netdb.h:57: error: storage class specified for parameter ‘getrpcent’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/rpc/netdb.h:62: error: storage class specified for parameter ‘getrpcbyname_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/rpc/netdb.h:66: error: storage class specified for parameter ‘getrpcbynumber_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/rpc/netdb.h:69: error: storage class specified for parameter ‘getrpcent_r’ +In file included from communication_funcs.h:11, + from mythen3Server_funcs.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:60: error: storage class specified for parameter ‘h_errno’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:66: error: storage class specified for parameter ‘__h_errno_location’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:93: error: storage class specified for parameter ‘herror’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:96: error: storage class specified for parameter ‘hstrerror’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:116: error: storage class specified for parameter ‘sethostent’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:122: error: storage class specified for parameter ‘endhostent’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:129: error: storage class specified for parameter ‘gethostent’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:137: error: storage class specified for parameter ‘gethostbyaddr’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:143: error: storage class specified for parameter ‘gethostbyname’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:154: error: storage class specified for parameter ‘gethostbyname2’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:169: error: storage class specified for parameter ‘gethostent_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:176: error: storage class specified for parameter ‘gethostbyaddr_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:182: error: storage class specified for parameter ‘gethostbyname_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:188: error: storage class specified for parameter ‘gethostbyname2_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:197: error: storage class specified for parameter ‘setnetent’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:203: error: storage class specified for parameter ‘endnetent’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:210: error: storage class specified for parameter ‘getnetent’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:217: error: storage class specified for parameter ‘getnetbyaddr’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:223: error: storage class specified for parameter ‘getnetbyname’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:272: error: storage class specified for parameter ‘setservent’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:278: error: storage class specified for parameter ‘endservent’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:285: error: storage class specified for parameter ‘getservent’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:293: error: storage class specified for parameter ‘getservbyname’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:300: error: storage class specified for parameter ‘getservbyport’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:313: error: storage class specified for parameter ‘getservent_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:319: error: storage class specified for parameter ‘getservbyname_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:324: error: storage class specified for parameter ‘getservbyport_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:341: error: storage class specified for parameter ‘setprotoent’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:347: error: storage class specified for parameter ‘endprotoent’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:354: error: storage class specified for parameter ‘getprotoent’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:360: error: storage class specified for parameter ‘getprotobyname’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:366: error: storage class specified for parameter ‘getprotobynumber’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:379: error: storage class specified for parameter ‘getprotoent_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:384: error: storage class specified for parameter ‘getprotobyname_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:389: error: storage class specified for parameter ‘getprotobynumber_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:446: error: storage class specified for parameter ‘ruserpass’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:464: error: storage class specified for parameter ‘rcmd’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:495: error: storage class specified for parameter ‘rexec’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:508: error: expected declaration specifiers or ‘...’ before ‘sa_family_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:508: error: storage class specified for parameter ‘rexec_af’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:519: error: storage class specified for parameter ‘ruserok’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:543: error: storage class specified for parameter ‘rresvport’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:568: error: expected specifier-qualifier-list before ‘socklen_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:640: error: storage class specified for parameter ‘getaddrinfo’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:643: error: storage class specified for parameter ‘freeaddrinfo’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:646: error: storage class specified for parameter ‘gai_strerror’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:653: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:654: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:655: error: expected declaration specifiers or ‘...’ before ‘socklen_t’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/netdb.h:655: error: storage class specified for parameter ‘getnameinfo’ +In file included from communication_funcs.h:13, + from mythen3Server_funcs.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:256: error: storage class specified for parameter ‘access’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:299: error: storage class specified for parameter ‘lseek’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:318: error: storage class specified for parameter ‘close’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:325: error: storage class specified for parameter ‘read’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:331: error: storage class specified for parameter ‘write’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:382: error: storage class specified for parameter ‘pipe’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:391: error: storage class specified for parameter ‘alarm’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:403: error: storage class specified for parameter ‘sleep’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:411: error: storage class specified for parameter ‘ualarm’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:418: error: storage class specified for parameter ‘usleep’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:427: error: storage class specified for parameter ‘pause’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:432: error: storage class specified for parameter ‘chown’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:436: error: storage class specified for parameter ‘fchown’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:442: error: storage class specified for parameter ‘lchown’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:455: error: storage class specified for parameter ‘chdir’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:459: error: storage class specified for parameter ‘fchdir’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:469: error: storage class specified for parameter ‘getcwd’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:488: error: storage class specified for parameter ‘dup’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:491: error: storage class specified for parameter ‘dup2’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:494: error: storage class specified for parameter ‘__environ’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:503: error: storage class specified for parameter ‘execve’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:515: error: storage class specified for parameter ‘execv’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:520: error: storage class specified for parameter ‘execle’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:525: error: storage class specified for parameter ‘execl’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:530: error: storage class specified for parameter ‘execvp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:536: error: storage class specified for parameter ‘execlp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:541: error: storage class specified for parameter ‘nice’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:546: error: storage class specified for parameter ‘_exit’ +In file included from communication_funcs.h:13, + from mythen3Server_funcs.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:556: error: storage class specified for parameter ‘pathconf’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:559: error: storage class specified for parameter ‘fpathconf’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:562: error: storage class specified for parameter ‘sysconf’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:566: error: storage class specified for parameter ‘confstr’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:571: error: storage class specified for parameter ‘getpid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:574: error: storage class specified for parameter ‘getppid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:579: error: storage class specified for parameter ‘getpgrp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:589: error: storage class specified for parameter ‘__getpgid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:598: error: storage class specified for parameter ‘setpgid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:615: error: storage class specified for parameter ‘setpgrp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:632: error: storage class specified for parameter ‘setsid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:640: error: storage class specified for parameter ‘getuid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:643: error: storage class specified for parameter ‘geteuid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:646: error: storage class specified for parameter ‘getgid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:649: error: storage class specified for parameter ‘getegid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:654: error: storage class specified for parameter ‘getgroups’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:665: error: storage class specified for parameter ‘setuid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:670: error: storage class specified for parameter ‘setreuid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:675: error: storage class specified for parameter ‘seteuid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:682: error: storage class specified for parameter ‘setgid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:687: error: storage class specified for parameter ‘setregid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:692: error: storage class specified for parameter ‘setegid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:732: error: storage class specified for parameter ‘vfork’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:738: error: storage class specified for parameter ‘ttyname’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:743: error: storage class specified for parameter ‘ttyname_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:747: error: storage class specified for parameter ‘isatty’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:759: error: storage class specified for parameter ‘link’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:772: error: storage class specified for parameter ‘symlink’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:779: error: storage class specified for parameter ‘readlink’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:794: error: storage class specified for parameter ‘unlink’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:803: error: storage class specified for parameter ‘rmdir’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:807: error: storage class specified for parameter ‘tcgetpgrp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:810: error: storage class specified for parameter ‘tcsetpgrp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:817: error: storage class specified for parameter ‘getlogin’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:825: error: storage class specified for parameter ‘getlogin_r’ +In file included from /afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:840, + from communication_funcs.h:13, + from mythen3Server_funcs.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/getopt.h:61: error: storage class specified for parameter ‘optarg’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/getopt.h:75: error: storage class specified for parameter ‘optind’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/getopt.h:80: error: storage class specified for parameter ‘opterr’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/getopt.h:84: error: storage class specified for parameter ‘optopt’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/bits/getopt.h:155: error: storage class specified for parameter ‘getopt’ +In file included from communication_funcs.h:13, + from mythen3Server_funcs.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:848: error: storage class specified for parameter ‘gethostname’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:856: error: storage class specified for parameter ‘sethostname’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:860: error: storage class specified for parameter ‘sethostid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:867: error: storage class specified for parameter ‘getdomainname’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:869: error: storage class specified for parameter ‘setdomainname’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:875: error: storage class specified for parameter ‘vhangup’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:896: error: storage class specified for parameter ‘acct’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:900: error: storage class specified for parameter ‘getusershell’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:901: error: storage class specified for parameter ‘endusershell’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:902: error: storage class specified for parameter ‘setusershell’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:908: error: storage class specified for parameter ‘daemon’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:915: error: storage class specified for parameter ‘chroot’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:919: error: storage class specified for parameter ‘getpass’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:928: error: storage class specified for parameter ‘fsync’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:935: error: storage class specified for parameter ‘gethostid’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:938: error: storage class specified for parameter ‘sync’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:943: error: storage class specified for parameter ‘getpagesize’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:948: error: storage class specified for parameter ‘getdtablesize’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:954: error: storage class specified for parameter ‘truncate’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:975: error: storage class specified for parameter ‘ftruncate’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:995: error: storage class specified for parameter ‘brk’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:1001: error: storage class specified for parameter ‘sbrk’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:1016: error: storage class specified for parameter ‘syscall’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:1039: error: storage class specified for parameter ‘lockf’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/unistd.h:1071: error: storage class specified for parameter ‘fdatasync’ +In file included from communication_funcs.h:15, + from mythen3Server_funcs.c:5: +sls_detector_defs.h:594: error: expected declaration specifiers before ‘;’ token +In file included from mythen3Server_funcs.c:5: +communication_funcs.h:24: error: storage class specified for parameter ‘intType’ +communication_funcs.h:34: error: expected declaration specifiers or ‘...’ before ‘intType’ +communication_funcs.h:35: error: expected declaration specifiers or ‘...’ before ‘intType’ +communication_funcs.h:36: error: expected declaration specifiers or ‘...’ before ‘intType’ +In file included from mythen3RegisterDefs.h:5, + from mythen3Server_funcs.c:7: +sls_detector_defs.h:594: error: expected declaration specifiers before ‘;’ token +In file included from mythen3Server_funcs.c:7: +mythen3RegisterDefs.h:456: warning: empty declaration +In file included from blackfin.h:7, + from mythen3Server_funcs.c:8: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/fcntl.h:74: error: storage class specified for parameter ‘fcntl’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/fcntl.h:93: error: storage class specified for parameter ‘open’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/fcntl.h:138: error: storage class specified for parameter ‘creat’ +In file included from blackfin.h:8, + from mythen3Server_funcs.c:8: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:59: error: storage class specified for parameter ‘mmap’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:77: error: storage class specified for parameter ‘munmap’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:82: error: storage class specified for parameter ‘mprotect’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:97: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:104: error: storage class specified for parameter ‘madvise’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:134: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:135: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:136: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:137: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:148: error: storage class specified for parameter ‘mincore’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:168: error: storage class specified for parameter ‘shm_open’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:171: error: storage class specified for parameter ‘shm_unlink’ +In file included from mythen3Server_funcs.c:8: +blackfin.h:12: error: parameter ‘CSP0BASE’ is initialized +blackfin.h:23: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +blackfin.h:34: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +blackfin.h:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +blackfin.h:56: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +blackfin.h:68: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +blackfin.h:86: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +blackfin.h:105: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +blackfin.h:114: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +blackfin.h:123: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +In file included from mythen3Server_funcs.c:11: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:40: error: storage class specified for parameter ‘memcpy’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:44: error: storage class specified for parameter ‘memmove’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:53: error: storage class specified for parameter ‘memccpy’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:59: error: storage class specified for parameter ‘memset’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:63: error: storage class specified for parameter ‘memcmp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:67: error: storage class specified for parameter ‘memchr’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:85: error: storage class specified for parameter ‘strcpy’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:89: error: storage class specified for parameter ‘strncpy’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:93: error: storage class specified for parameter ‘strcat’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:96: error: storage class specified for parameter ‘strncat’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:100: error: storage class specified for parameter ‘strcmp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:103: error: storage class specified for parameter ‘strncmp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:107: error: storage class specified for parameter ‘strcoll’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:111: error: storage class specified for parameter ‘strxfrm’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:131: error: storage class specified for parameter ‘strdup’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:168: error: storage class specified for parameter ‘strchr’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:171: error: storage class specified for parameter ‘strrchr’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:185: error: storage class specified for parameter ‘strcspn’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:189: error: storage class specified for parameter ‘strspn’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:192: error: storage class specified for parameter ‘strpbrk’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:195: error: storage class specified for parameter ‘strstr’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:200: error: storage class specified for parameter ‘strtok’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:214: error: storage class specified for parameter ‘strtok_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:247: error: storage class specified for parameter ‘strlen’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:260: error: storage class specified for parameter ‘strerror’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:286: error: storage class specified for parameter ‘__glibc_strerror_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:288: error: storage class specified for parameter ‘strerror_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:307: error: storage class specified for parameter ‘bcopy’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:310: error: storage class specified for parameter ‘bzero’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:314: error: storage class specified for parameter ‘bcmp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:318: error: storage class specified for parameter ‘index’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:322: error: storage class specified for parameter ‘rindex’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:339: error: storage class specified for parameter ‘ffs’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:353: error: storage class specified for parameter ‘strcasecmp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:357: error: storage class specified for parameter ‘strncasecmp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:377: error: storage class specified for parameter ‘strsep’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:430: error: storage class specified for parameter ‘strlcat’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:432: error: storage class specified for parameter ‘strlcpy’ +mythen3Server_funcs.c:16: error: storage class specified for parameter ‘lockStatus’ +mythen3Server_funcs.c:17: error: storage class specified for parameter ‘lastClientIP’ +mythen3Server_funcs.c:18: error: storage class specified for parameter ‘thisClientIP’ +mythen3Server_funcs.c:19: error: storage class specified for parameter ‘differentClients’ +mythen3Server_funcs.c:40: error: parameter ‘myDetectorType’ is initialized +mythen3Server_funcs.c:45: error: parameter ‘dataBytes’ is initialized +mythen3Server_funcs.c:46: error: parameter ‘isControlServer’ is initialized +mythen3Server_funcs.c:47: error: parameter ‘debugflag’ is initialized +mythen3Server_funcs.c:49: error: parameter ‘N_DAC’ is initialized +mythen3Server_funcs.c:50: error: parameter ‘N_PWR’ is initialized +mythen3Server_funcs.c:52: error: parameter ‘vPowerLimit’ is initialized +mythen3Server_funcs.c:56: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:61: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:69: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:92: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:124: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:203: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:295: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:321: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:361: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:380: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:408: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:462: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:505: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:579: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:642: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:724: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:836: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:855: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:874: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:894: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:1239: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:1340: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:1398: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:1441: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:1459: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:1478: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:1549: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:1620: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:1641: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:1717: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:1784: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:1805: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2020: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2135: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2155: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2221: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2278: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2349: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2386: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2425: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2475: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2502: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2532: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2577: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2595: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2686: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2766: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2865: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:2949: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:3049: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:3128: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:3215: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:3229: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:3271: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:3286: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:3350: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:3359: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:3489: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:3618: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:3696: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:3747: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:3796: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:3857: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:3911: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:3971: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:4031: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:4102: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:4121: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:4179: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:4238: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:4290: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:4344: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:4397: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:4471: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:4515: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:4604: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:4747: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:4792: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:4858: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:4918: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:4963: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3Server_funcs.c:5007: error: old-style parameter declarations in prototyped function definition +mythen3Server_funcs.c:5005: error: expected ‘{’ at end of input +communication_funcs.c: In function ‘receiveModuleGeneral’: +communication_funcs.c:540: warning: unused variable ‘id’ +In file included from blackfin.h:7, + from commonServerFunctions.h:5, + from AD9257.h:6, + from mythen3FunctionList.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/fcntl.h: In function ‘setDAC’: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/fcntl.h:74: error: storage class specified for parameter ‘fcntl’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/fcntl.h:93: error: storage class specified for parameter ‘open’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/fcntl.h:138: error: storage class specified for parameter ‘creat’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/fcntl.h:167: error: storage class specified for parameter ‘lockf’ +In file included from blackfin.h:8, + from commonServerFunctions.h:5, + from AD9257.h:6, + from mythen3FunctionList.c:5: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:59: error: storage class specified for parameter ‘mmap’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:77: error: storage class specified for parameter ‘munmap’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:82: error: storage class specified for parameter ‘mprotect’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:97: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:104: error: storage class specified for parameter ‘madvise’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:134: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:135: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:136: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:137: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:148: error: storage class specified for parameter ‘mincore’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:168: error: storage class specified for parameter ‘shm_open’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/sys/mman.h:171: error: storage class specified for parameter ‘shm_unlink’ +In file included from commonServerFunctions.h:5, + from AD9257.h:6, + from mythen3FunctionList.c:5: +blackfin.h:12: error: parameter ‘CSP0BASE’ is initialized +blackfin.h:23: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +blackfin.h:34: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +blackfin.h:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +blackfin.h:56: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +blackfin.h:68: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +blackfin.h:86: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +blackfin.h:105: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +blackfin.h:114: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +blackfin.h:123: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +In file included from AD9257.h:6, + from mythen3FunctionList.c:5: +commonServerFunctions.h:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +In file included from mythen3FunctionList.c:5: +AD9257.h:80: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +AD9257.h:89: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +In file included from mythen3FunctionList.c:8: +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:40: error: storage class specified for parameter ‘memcpy’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:44: error: storage class specified for parameter ‘memmove’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:53: error: storage class specified for parameter ‘memccpy’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:59: error: storage class specified for parameter ‘memset’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:63: error: storage class specified for parameter ‘memcmp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:67: error: storage class specified for parameter ‘memchr’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:85: error: storage class specified for parameter ‘strcpy’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:89: error: storage class specified for parameter ‘strncpy’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:93: error: storage class specified for parameter ‘strcat’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:96: error: storage class specified for parameter ‘strncat’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:100: error: storage class specified for parameter ‘strcmp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:103: error: storage class specified for parameter ‘strncmp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:107: error: storage class specified for parameter ‘strcoll’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:111: error: storage class specified for parameter ‘strxfrm’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:131: error: storage class specified for parameter ‘strdup’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:168: error: storage class specified for parameter ‘strchr’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:171: error: storage class specified for parameter ‘strrchr’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:185: error: storage class specified for parameter ‘strcspn’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:189: error: storage class specified for parameter ‘strspn’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:192: error: storage class specified for parameter ‘strpbrk’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:195: error: storage class specified for parameter ‘strstr’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:200: error: storage class specified for parameter ‘strtok’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:214: error: storage class specified for parameter ‘strtok_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:247: error: storage class specified for parameter ‘strlen’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:260: error: storage class specified for parameter ‘strerror’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:286: error: storage class specified for parameter ‘__glibc_strerror_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:288: error: storage class specified for parameter ‘strerror_r’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:307: error: storage class specified for parameter ‘bcopy’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:310: error: storage class specified for parameter ‘bzero’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:314: error: storage class specified for parameter ‘bcmp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:318: error: storage class specified for parameter ‘index’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:322: error: storage class specified for parameter ‘rindex’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:339: error: storage class specified for parameter ‘ffs’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:353: error: storage class specified for parameter ‘strcasecmp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:357: error: storage class specified for parameter ‘strncasecmp’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:377: error: storage class specified for parameter ‘strsep’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:430: error: storage class specified for parameter ‘strlcat’ +/afs/psi.ch/project/sls_det_firmware/jungfrau_software/uClinux-2010_64bit/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/include/string.h:432: error: storage class specified for parameter ‘strlcpy’ +mythen3FunctionList.c:11: error: parameter ‘nChans’ is initialized +mythen3FunctionList.c:12: error: parameter ‘nChips’ is initialized +mythen3FunctionList.c:13: error: parameter ‘nDacs’ is initialized +mythen3FunctionList.c:14: error: parameter ‘nAdcs’ is initialized +mythen3FunctionList.c:15: error: parameter ‘allSelected’ is initialized +mythen3FunctionList.c:16: error: parameter ‘noneSelected’ is initialized +mythen3FunctionList.c:18: error: parameter ‘detectorModules’ is initialized +mythen3FunctionList.c:19: error: parameter ‘detectorChips’ is initialized +mythen3FunctionList.c:20: error: parameter ‘detectorChans’ is initialized +mythen3FunctionList.c:21: error: parameter ‘detectorDacs’ is initialized +mythen3FunctionList.c:22: error: parameter ‘detectorAdcs’ is initialized +mythen3FunctionList.c:24: error: parameter ‘nModY’ is initialized +mythen3FunctionList.c:25: error: parameter ‘nModX’ is initialized +mythen3FunctionList.c:26: error: parameter ‘dynamicRange’ is initialized +mythen3FunctionList.c:27: error: parameter ‘dataBytes’ is initialized +mythen3FunctionList.c:28: error: parameter ‘masterMode’ is initialized +mythen3FunctionList.c:29: error: parameter ‘syncMode’ is initialized +mythen3FunctionList.c:30: error: parameter ‘timingMode’ is initialized +mythen3FunctionList.c:37: error: storage class specified for parameter ‘dataBytes’ +mythen3FunctionList.c:37: error: redefinition of parameter ‘dataBytes’ +mythen3FunctionList.c:27: error: previous definition of ‘dataBytes’ was here +mythen3FunctionList.c:40: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:89: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:110: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:116: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:127: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:136: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:145: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:164: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:176: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:188: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:197: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:203: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:235: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:256: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:356: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:492: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:500: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:507: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:514: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:520: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:525: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:530: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:535: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:542: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:550: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:557: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:568: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:576: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:583: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:590: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:599: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:668: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:682: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:688: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:696: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:702: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:716: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:724: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:730: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:736: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:741: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:746: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:751: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:756: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:760: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:761: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:762: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:763: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:764: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:765: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:766: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:767: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:775: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:785: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:836: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:954: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:1086: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token +mythen3FunctionList.c:1197: error: old-style parameter declarations in prototyped function definition +mythen3FunctionList.c:1193: error: expected ‘{’ at end of input +make: *** [mythen3Server] Error 1 diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3FunctionList.c b/slsDetectorSoftware/mythen3DetectorServer/mythen3FunctionList.c new file mode 100644 index 000000000..04623d1b9 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/mythen3FunctionList.c @@ -0,0 +1,1201 @@ +#ifdef SLS_DETECTOR_FUNCTION_LIST + +#include "mythen3FunctionList.h" +#include "mythen3RegisterDefs.h" +#include "mythen3Server_defs.h" +#include "blackfin.h" +// #include "AD9257.h" + +#include +#include + + +const int nChans=NCHAN; +const int nChips=NCHIP; +const int nDacs=NDAC; +const int nAdcs=NADC; +const int allSelected=-2; +const int noneSelected=-1; + +sls_detector_module *detectorModules=NULL; +int *detectorChips=NULL; +int *detectorChans=NULL; +dacs_t *detectorDacs=NULL; +dacs_t *detectorAdcs=NULL; + +int nModY = NMAXMOD; +int nModX = NMAXMOD; +int dynamicRange= DYNAMIC_RANGE; +// int dataBytes = NMAXMOD*NCHIP*NCHAN*2; +int masterMode = NO_MASTER; +int syncMode = NO_SYNCHRONIZATION; +int timingMode = AUTO_TIMING; + +int vLimit=-100; + +enum detectorSettings thisSettings; +int sChan, sChip, sMod, sDac, sAdc; +int nModBoard; +extern int dataBytes; +extern enum detectorType myDetectorType; +extern int N_DAC; + +int initializeDetectorStructure(){ + + int imod; + int n=getNModBoard(X)*getNModBoard(Y); +#ifdef VERBOSE + printf("Board is for %d modules\n",n); +#endif + detectorModules=malloc(n*sizeof(sls_detector_module)); + detectorChips=malloc(n*NCHIP*sizeof(int)); + detectorChans=malloc(n*NCHIP*NCHAN*sizeof(int)); + detectorDacs=malloc(n*NDAC*sizeof(int)); + detectorAdcs=malloc(n*NADC*sizeof(int)); +#ifdef VERBOSE + printf("modules from 0x%x to 0x%x\n",(unsigned int)(detectorModules), (unsigned int)(detectorModules+n)); + printf("chips from 0x%x to 0x%x\n",(unsigned int)(detectorChips), (unsigned int)(detectorChips+n*NCHIP)); + printf("chans from 0x%x to 0x%x\n",(unsigned int)(detectorChans), (unsigned int)(detectorChans+n*NCHIP*NCHAN)); + printf("dacs from 0x%x to 0x%x\n",(unsigned int)(detectorDacs), (unsigned int)(detectorDacs+n*NDAC)); + printf("adcs from 0x%x to 0x%x\n",(unsigned int)(detectorAdcs), (unsigned int)(detectorAdcs+n*NADC)); +#endif + for (imod=0; imoddacs=detectorDacs+imod*NDAC; + (detectorModules+imod)->adcs=detectorAdcs+imod*NADC; + (detectorModules+imod)->chipregs=detectorChips+imod*NCHIP; + (detectorModules+imod)->chanregs=detectorChans+imod*NCHIP*NCHAN; + (detectorModules+imod)->ndac=NDAC; + (detectorModules+imod)->nadc=NADC; + (detectorModules+imod)->nchip=NCHIP; + (detectorModules+imod)->nchan=NCHIP*NCHAN; + (detectorModules+imod)->module=imod; + (detectorModules+imod)->gain=0; + (detectorModules+imod)->offset=0; + (detectorModules+imod)->reg=0; + /* initialize registers, dacs, retrieve sn, adc values etc */ + } + thisSettings=UNINITIALIZED; + sChan=noneSelected; + sChip=noneSelected; + sMod=noneSelected; + sDac=noneSelected; + sAdc=noneSelected; + + return OK; +} + + + + + + +int setupDetector(){ + //testFpga(); + //testRAM(); + + //setSettings(GET_SETTINGS,-1); + //setFrames(1); + //setTrains(1); + //setExposureTime(1e6); + //setPeriod(1e9); + //setDelay(0); + //setGates(0); + + //setTiming(GET_EXTERNAL_COMMUNICATION_MODE); + //setMaster(GET_MASTER); + //setSynchronization(GET_SYNCHRONIZATION_MODE); + return OK; +} + + + + +int setNMod(int nm, enum dimension dim){ + return 1; +} + + + +int getNModBoard(enum dimension arg){ + return 1; +} + + + + + + + + +int64_t getModuleId(enum idMode arg, int imod){ + //DETECTOR_SERIAL_NUMBER + //DETECTOR_FIRMWARE_VERSION + return 0; +} + + + + +int64_t getDetectorId(enum idMode arg){ + //DETECTOR_SOFTWARE_VERSION defined in slsDetector_defs.h? + return 0; +} + + + + + +int moduleTest( enum digitalTestMode arg, int imod){ + //template testShiftIn from mcb_funcs.c + + //CHIP_TEST + //testShiftIn + //testShiftOut + //testShiftStSel + //testDataInOutMux + //testExtPulseMux + //testOutMux + //testFpgaMux + + return OK; +} + + + + + +int detectorTest( enum digitalTestMode arg){ + //templates from firmware_funcs.c + + //DETECTOR_FIRMWARE_TEST:testFpga() + //DETECTOR_MEMORY_TEST:testRAM() + //DETECTOR_BUS_TEST:testBus() + //DETECTOR_SOFTWARE_TEST:testFpga() + return OK; +} + +int getDacRegister(int dacnum) { + + bus_w(DAC_NUM_REG, dacnum); + printf("READ dac register value %d address %d\n",(int16_t)bus_r(DAC_VAL_REG),bus_r(DAC_NUM_REG)) ; + return (int16_t)bus_r(DAC_VAL_REG); +} + +int setDacRegister(int dacnum,int dacvalue) { + + bus_w(DAC_NUM_REG, dacnum); + bus_w(DAC_VAL_REG, dacvalue); + bus_w(DAC_NUM_REG, dacnum | (1<<16)); + bus_w(DAC_NUM_REG, dacnum); + printf("Wrote dac register value %d address %d\n",bus_r(DAC_VAL_REG),bus_r(DAC_NUM_REG)) ; + return getDacRegister(dacnum); +} + + + +int dacSPI(int codata) { + u_int32_t offw; + int valw, vv; + int i, ddx,cdx; + + ddx=0; cdx=1; + + offw=DAC_REG; + valw=bus_r(offw); + // codata=((cmd&0xf)<=0) { + cmd=0x3; + } + else if (dacvalue==-100) { + cmd=0x4; + } + codata=cmd< conversion done in slsDetectorServer_funcs.c-> set_dac() + + //if normal dac: + + int dacval = val; // in DAC + u_int32_t offw; + u_int32_t ichip; // DAC-chip (3 chips with each 8 DACs) + u_int16_t valw; + int i,ddx,csdx,cdx; // ddx=data, cdx=clk, csdx=chipselect + + //select dac-chip: + if (myDetectorType==JUNGFRAUCTB || myDetectorType==MYTHEN3){ + ichip=2-ind/8; + printf("This is a CTB (or mythen3)\n"); + } + else { + ichip=ind/8; + printf("This is not a CTB\n"); + } + + // if(val>0 && mV){ // convert to DACu, if val is given in mV + // dacval = val * 4095 / 2500; // convert to DAC + if (val == -1){ + return getDacRegister(ind); + } + else if(dacval<0 || dacval>4095){ + dacval = -1; + printf("The DAC is out of range! Error!\n"); + return getDacRegister(ind); + } + // } + + else if(dacval>=0 && dacval<=4095){ + printf("\nSetting of DAC %d to %d DACunits\n",ind,dacval); + ddx=0; // data is first bit in DAC_REG + cdx=1; // clk is 2nd bit in DAC_REG + if (myDetectorType==JUNGFRAUCTB || myDetectorType==MYTHEN3) + csdx=2; + else + csdx=ichip+2; + + //setting int reference + offw=DAC_REG; + valw=bus_r(offw)|0xff; // alles (ddx,cdx,csdx) auf 1 setzen (for START) + bus_w(offw,(valw)); // start point + //chip select down: + valw=((valw&(~(0x1<=0) { // v_a, v_b, v_c, v_d, v_io + printf("vpower\n"); + dacval=((vmax-val)*4095)/(vmax-vmin); + if (dacval<0) + dacval=0; + if (dacval>4095) + dacval=-100; + if (val==-100) + dacval=-100; + + + } else if (dacindex>=0) {// v_chip + printf("vchip\n"); + dacval=((2700-val)*4095)/1000; + if (dacval<0) + dacval=0; + if (dacval>4095) + dacval=4095; + + } else { // v_limit + vLimit=val; + printf("vlimit %d\n",vLimit ); + } + + } + + if (pwrindex>=0 && val!=-1) {// v_a, v_b, v_c, v_d, v_io + preg=bus_r(POWER_ON_REG); + printf("power reg is %08x\n",bus_r(POWER_ON_REG)); + printf("Switching off power %d\n", pwrindex); + bus_w(POWER_ON_REG,preg&(~(1<<(16+pwrindex)))); + setDAC(dacindex,-100,-1,1); + printf("power reg is %08x\n",bus_r(POWER_ON_REG)); + retval=0; + } + + if (dacindex>0 && dacval!=-100) {// v_a, v_b, v_c, v_d, v_io, v_chip + + printf("Setting power %d to %d mV\n",ind,val); + printf("Setting DAC %d to value %d\n",dacindex,dacval); + retval=setDAC(dacindex,dacval,-1,1);// in mV + if (pwrindex>=0 && dacval>=0 ) {// v_a, v_b, v_c, v_d, v_io + preg=bus_r(POWER_ON_REG); + printf("power reg is %08x\n",bus_r(POWER_ON_REG)); + printf("Switching on power %d\n", pwrindex); + bus_w(POWER_ON_REG,preg|((1<<(16+pwrindex)))); + printf("power reg is %08x\n",bus_r(POWER_ON_REG)); + } + } + + if (pwrindex>=0) {// v_a, v_b, v_c, v_d, v_io + if (bus_r(POWER_ON_REG)&(1<<(16+pwrindex))){ + vmax=2700-(getDacRegister(19)*1000)/4095-200; // 19=v_chip + printf("Vchip id %d mV\n",vmax+200); + // retval1=vmax-(retval*(vmax-vmin))/4095; + retval1=vmax-retval; // mV + printf("Vdac id %d mV\n",retval1); + if (retval1>vmax) + retval1=vmax; + if (retval1=0) { //v_chip + if (retval>=0) { + retval1=2700-(retval*1000)/4095; + printf("Vchip is %d mV\n",vmax); + } else + retval1=-1; + } else { + printf("Get vlimit %d\n",vLimit); + retval=vLimit; + retval1=vLimit; + } + + return retval1; +} + + + + + + + +int setChannel(sls_detector_channel myChan){ + //template initChannelByNumber() from mcb_funcs.c + + return myChan.reg; +} + + +int getChannel(sls_detector_channel *myChan){ + //template getChannelbyNumber() from mcb_funcs.c + return FAIL; +} + + + +int setChip(sls_detector_chip myChip){ + //template initChipbyNumber() from mcb_funcs.c + return myChip.reg; +} + + +int getChip(sls_detector_chip *myChip){ + //template getChipbyNumber() from mcb_funcs.c + return FAIL; +} + +int setModule(sls_detector_module myChan){ + //template initModulebyNumber() from mcb_funcs.c + return OK; +} + +int getModule(sls_detector_module *myChan){ + //template getModulebyNumber() from mcb_funcs.c + return FAIL; +} + +int getThresholdEnergy(int imod){ + //template getThresholdEnergy() from mcb_funcs.c + //depending on settings + return FAIL; +} + + +int setThresholdEnergy(int thr, int imod){ + //template getThresholdEnergy() from mcb_funcs.c + //depending on settings + return FAIL; +} + + + +enum detectorSettings setSettings(enum detectorSettings sett, int imod){ + //template setSettings() from mcb_funcs.c + //reads the dac registers from fpga to confirm which settings, if weird, undefined + + return OK; +} + +int startStateMachine(){ + //template startStateMachine() from firmware_funcs.c + /* + fifoReset(); + now_ptr=(char*)ram_values; + //send start acquisition to fpga + */ + return FAIL; +} + + +int stopStateMachine(){ + //template stopStateMachine() from firmware_funcs.c + // send stop to fpga + //if status = busy after 500us, return FAIL + return FAIL; +} + + +int startReadOut(){ + //template startReadOut() from firmware_funcs.c + //send fpga start readout + return FAIL; +} + + +enum runStatus getRunStatus(){ + //template runState() from firmware_funcs.c + //get status from fpga + return ERROR; +} + + +char *readFrame(int *ret, char *mess){ + //template fifo_read_event() from firmware_funcs.c + //checks if state machine running and if fifo has data(look_at_me_reg) and accordingly reads frame + // memcpy(now_ptr, values, dataBytes); + //returns ptr to values + return NULL; +} + + +int64_t setTimer(enum timerIndex ind, int64_t val){ + //template setDelay() from firmware_funcs.c + //writes to reg + //FRAME_NUMBER --> defined in sls_receiver_defs.h + //ACQUISITION_TIME + //FRAME_PERIOD -> how many frames per trigger + //DELAY_AFTER_TRIGGER + //GATES_NUMBER + //PROBES_NUMBER = # counters + //CYCLES_NUMBER -> how many triggers + + int64_t retval = -1; // return value to check + + switch(ind){ // only change the timer corresponding to ind + + case FRAME_NUMBER: + if(val >= 0) + printf("\nSetting #frames: %lld\n",(long long int)val); + retval = set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG); + printf("Getting #frames: %lld\n",(long long int)retval); + break; + + case ACQUISITION_TIME: // defined in sls_receiver_defs.h + if(val>=0){ + printf("\n Setting the exposure time: %lld ns \n",(long long int)val); + val *= (1E-3 * CLK_RUN); // convert from ns to clk-cycles + // CLK_RUN is defined in slsDetectorServer_defs.h + } + retval = set64BitReg(val,SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG )/(1E-3 * CLK_RUN); // set the register to val and read back, convert back to ns + // SET_EXPTIME_LSB_REG are defined in RegisterDefs.h + printf("Getting the exposure time: %lld ns \n", (long long int)retval); + break; + + case FRAME_PERIOD: // how many frames per trigger + if(val >= 0){ + printf("\nSetting period to %lldns\n",(long long int)val); + val *= (1E-3 * CLK_SYNC); + } + retval = set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG )/ (1E-3 * CLK_SYNC); + // CLK_SYN is defined in slsDetectorServer_defs.h + printf("Getting period: %lldns\n", (long long int)retval); + break; + + case DELAY_AFTER_TRIGGER: + if(val >= 0){ + printf("\nSetting delay to %lldns\n", (long long int)val); + val *= (1E-3 * CLK_SYNC); + } + retval = set64BitReg(val, SET_DELAY_LSB_REG, SET_DELAY_MSB_REG) / (1E-3 * CLK_SYNC); + printf("Getting delay: %lldns\n", (long long int)retval); + break; + + // case PROBES_NUMBER: + + case CYCLES_NUMBER: // how many triggers + if(val >= 0) + printf("\nSetting #cycles to %lld\n", (long long int)val); + retval = set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG); + printf("Getting #cycles: %lld\n", (long long int)retval); + break; + + default: + cprintf(RED,"Warning: Timer Index not implemented for this detector: %d\n", ind); + break; + } + return retval; +} + + +int64_t getTimeLeft(enum timerIndex ind){ + //template getDelay() from firmware_funcs.c + //reads from reg + //FRAME_NUMBER + //ACQUISITION_TIME + //FRAME_PERIOD + //DELAY_AFTER_TRIGGER + //GATES_NUMBER + //PROBES_NUMBER + //CYCLES_NUMBER + return -1; +} + + +int setDynamicRange(int dr){ + //template setDynamicRange() from firmware_funcs.c + return 0; +} + + +enum readOutFlags setReadOutFlags(enum readOutFlags val){ + //template setStoreInRAM from firmware_funcs.c + return -1; +} + + + + +int setROI(int n, ROI arg[], int *retvalsize, int *ret){ + return FAIL; +} + + + +int setSpeed(enum speedVariable arg, int val){ + //template setClockDivider() from firmware_funcs.c + //CLOCK_DIVIDER + //WAIT_STATES + //SET_SIGNAL_LENGTH + //TOT_CLOCK_DIVIDER + //TOT_DUTY_CYCLE + + //returns eg getClockDivider from firmware_funcs.c + return 0; +} + + + +int executeTrimming(enum trimMode mode, int par1, int par2, int imod){ + // template trim_with_noise from trimming_funcs.c + return FAIL; +} + + + + +// int configureMAC(int ipad, long long int imacadd, long long int iservermacadd, int dtb){ +// //detector specific. +// return FAIL; +// } + +int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival){ + return FAIL; +}; + + +int loadImage(enum imageType index, char *imageVals){ + //detector specific. + return FAIL; +} + + +int readCounterBlock(int startACQ, char *counterVals){ + //detector specific. + return FAIL; +} + +int resetCounterBlock(int startACQ){ + //detector specific. + return FAIL; +} + +int startReceiver(int d){ + + return 0; +} + +int calibratePedestal(int frames){ + + return 0; +} + +int calculateDataBytes(){ + return 0; +} + +int getTotalNumberOfChannels(){return 0;} +int getTotalNumberOfChips(){return 0;} +int getTotalNumberOfModules(){return 0;} +int getNumberOfChannelsPerChip(){return 0;} +int getNumberOfChannelsPerModule(){return 0;} +int getNumberOfChipsPerModule(){return 0;} +int getNumberOfDACsPerModule(){return 0;} +int getNumberOfADCsPerModule(){return 0;} + + + + + + + +enum externalSignalFlag getExtSignal(int signalindex){ + //template getExtSignal from firmware_funcs.c + //return signals[signalindex]; + return -1; +} + + + + + +enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag){ + //template setExtSignal from firmware_funcs.c + + //in short..sets signals array, checks if agrees with timing mode, writes to fpga reg, calls synchronization and then settiming + /* + if (signalindex>=0 && signalindex<4) { + signals[signalindex]=flag; +#ifdef VERBOSE + printf("settings signal variable number %d to value %04x\n", signalindex, signals[signalindex]); +#endif + // if output signal, set it! + switch (flag) { + case GATE_IN_ACTIVE_HIGH: + case GATE_IN_ACTIVE_LOW: + if (timingMode==GATE_FIX_NUMBER || timingMode==GATE_WITH_START_TRIGGER)//timingMode = AUTO_TIMING by default and is set in setTiming() + setFPGASignal(signalindex,flag); //not implemented here, checks if flag within limits and writes to fpga reg + else + setFPGASignal(signalindex,SIGNAL_OFF); + break; + case TRIGGER_IN_RISING_EDGE: + case TRIGGER_IN_FALLING_EDGE: + if (timingMode==TRIGGER_EXPOSURE || timingMode==GATE_WITH_START_TRIGGER) + setFPGASignal(signalindex,flag); + else + setFPGASignal(signalindex,SIGNAL_OFF); + break; + case RO_TRIGGER_IN_RISING_EDGE: + case RO_TRIGGER_IN_FALLING_EDGE: + if (timingMode==BURST_TRIGGER) + setFPGASignal(signalindex,flag); + else + setFPGASignal(signalindex,SIGNAL_OFF); + break; + case MASTER_SLAVE_SYNCHRONIZATION: + setSynchronization(syncMode);//syncmode = NO_SYNCHRONIZATION by default and set with this function + break; + default: + setFPGASignal(signalindex,mode); + } + + setTiming(GET_EXTERNAL_COMMUNICATION_MODE); + } + */ + return getExtSignal(signalindex); +} + + + + + + +enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){ + //template setTiming from firmware_funcs.c + //template getFPGASignal from firmware_funcs.c + + + //getFPGASignal(signalindex) used later on in this fucntion + //gets flag from fpga reg, checks if flag within limits, + //if( flag=SIGNAL_OFF and signals[signalindex]==MASTER_SLAVE_SYNCHRONIZATION), return -1, (ensures masterslaveflag !=off now) + //else return flag + + int ret=GET_EXTERNAL_COMMUNICATION_MODE; + //sets timingmode variable + //ensures that the signals are in acceptance with timing mode and according sets the timing mode + /* + int g=-1, t=-1, rot=-1; + + int i; + + switch (ti) { + case AUTO_TIMING: + timingMode=ti; + // disable all gates/triggers in except if used for master/slave synchronization + for (i=0; i<4; i++) { + if (getFPGASignal(i)>0 && getFPGASignal(i)=0 && t>=0 && rot<0) { + ret=GATE_WITH_START_TRIGGER; + } else if (g<0 && t>=0 && rot<0) { + ret=TRIGGER_EXPOSURE; + } else if (g>=0 && t<0 && rot<0) { + ret=GATE_FIX_NUMBER; + } else if (g<0 && t<0 && rot>0) { + ret=TRIGGER_READOUT; + } else if (g<0 && t<0 && rot<0) { + ret=AUTO_TIMING; + } + + */ + return ret; +} + + + +enum masterFlags setMaster(enum masterFlags arg){ + //template setMaster from firmware_funcs.c + /* + int i; + switch(f) { + case NO_MASTER: + // switch of gates or triggers + masterMode=NO_MASTER; + for (i=0; i<4; i++) { + if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { + setFPGASignal(i,SIGNAL_OFF); + } + } + break; + case IS_MASTER: + // configure gate or trigger out + masterMode=IS_MASTER; + for (i=0; i<4; i++) { + if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { + switch (syncMode) { + case NO_SYNCHRONIZATION: + setFPGASignal(i,SIGNAL_OFF); + break; + case MASTER_GATES: + setFPGASignal(i,GATE_OUT_ACTIVE_HIGH); + break; + case MASTER_TRIGGERS: + setFPGASignal(i,TRIGGER_OUT_RISING_EDGE); + break; + case SLAVE_STARTS_WHEN_MASTER_STOPS: + setFPGASignal(i,RO_TRIGGER_OUT_RISING_EDGE); + break; + default: + ; + } + } + } + break; + case IS_SLAVE: + // configure gate or trigger in + masterMode=IS_SLAVE; + for (i=0; i<4; i++) { + if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { + switch (syncMode) { + case NO_SYNCHRONIZATION: + setFPGASignal(i,SIGNAL_OFF); + break; + case MASTER_GATES: + setFPGASignal(i,GATE_IN_ACTIVE_HIGH); + break; + case MASTER_TRIGGERS: + setFPGASignal(i,TRIGGER_IN_RISING_EDGE); + break; + case SLAVE_STARTS_WHEN_MASTER_STOPS: + setFPGASignal(i,TRIGGER_IN_RISING_EDGE); + break; + default: + ; + } + } + } + break; + default: + //do nothing + ; + } + + switch(masterMode) { + case NO_MASTER: + return NO_MASTER; + + + case IS_MASTER: + for (i=0; i<4; i++) { + if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { + switch (syncMode) { + case NO_SYNCHRONIZATION: + return IS_MASTER; + case MASTER_GATES: + if (getFPGASignal(i)==GATE_OUT_ACTIVE_HIGH) + return IS_MASTER; + else + return NO_MASTER; + case MASTER_TRIGGERS: + if (getFPGASignal(i)==TRIGGER_OUT_RISING_EDGE) + return IS_MASTER; + else + return NO_MASTER; + case SLAVE_STARTS_WHEN_MASTER_STOPS: + if (getFPGASignal(i)==RO_TRIGGER_OUT_RISING_EDGE) + return IS_MASTER; + else + return NO_MASTER; + default: + return NO_MASTER; + } + + } + } + + case IS_SLAVE: + for (i=0; i<4; i++) { + if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { + switch (syncMode) { + case NO_SYNCHRONIZATION: + return IS_SLAVE; + case MASTER_GATES: + if (getFPGASignal(i)==GATE_IN_ACTIVE_HIGH) + return IS_SLAVE; + else + return NO_MASTER; + case MASTER_TRIGGERS: + case SLAVE_STARTS_WHEN_MASTER_STOPS: + if (getFPGASignal(i)==TRIGGER_IN_RISING_EDGE) + return IS_SLAVE; + else + return NO_MASTER; + default: + return NO_MASTER; + } + + } + } + + } + */ + + return NO_MASTER; +} + + + +enum synchronizationMode setSynchronization(enum synchronizationMode arg){ + /* + int i; + + switch(s) { + case NO_SYNCHRONIZATION: + syncMode=NO_SYNCHRONIZATION; + for (i=0; i<4; i++) { + if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { + setFPGASignal(i,SIGNAL_OFF); + } + } + break; + // disable external signals? + case MASTER_GATES: + // configure gate in or out + syncMode=MASTER_GATES; + for (i=0; i<4; i++) { + if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { + if (masterMode==IS_MASTER) + setFPGASignal(i,GATE_OUT_ACTIVE_HIGH); + else if (masterMode==IS_SLAVE) + setFPGASignal(i,GATE_IN_ACTIVE_HIGH); + } + } + + break; + case MASTER_TRIGGERS: + // configure trigger in or out + syncMode=MASTER_TRIGGERS; + for (i=0; i<4; i++) { + if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { + if (masterMode==IS_MASTER) + setFPGASignal(i,TRIGGER_OUT_RISING_EDGE); + else if (masterMode==IS_SLAVE) + setFPGASignal(i,TRIGGER_IN_RISING_EDGE); + } + } + break; + + + case SLAVE_STARTS_WHEN_MASTER_STOPS: + // configure trigger in or out + syncMode=SLAVE_STARTS_WHEN_MASTER_STOPS; + for (i=0; i<4; i++) { + if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { + if (masterMode==IS_MASTER) + setFPGASignal(i,RO_TRIGGER_OUT_RISING_EDGE); + else if (masterMode==IS_SLAVE) + setFPGASignal(i,TRIGGER_IN_RISING_EDGE); + } + } + break; + + + default: + //do nothing + ; + } + + switch (syncMode) { + + case NO_SYNCHRONIZATION: + return NO_SYNCHRONIZATION; + + case MASTER_GATES: + + for (i=0; i<4; i++) { + if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { + if (masterMode==IS_MASTER && getFPGASignal(i)==GATE_OUT_ACTIVE_HIGH) + return MASTER_GATES; + else if (masterMode==IS_SLAVE && getFPGASignal(i)==GATE_IN_ACTIVE_HIGH) + return MASTER_GATES; + } + } + return NO_SYNCHRONIZATION; + + case MASTER_TRIGGERS: + for (i=0; i<4; i++) { + if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { + if (masterMode==IS_MASTER && getFPGASignal(i)==TRIGGER_OUT_RISING_EDGE) + return MASTER_TRIGGERS; + else if (masterMode==IS_SLAVE && getFPGASignal(i)==TRIGGER_IN_RISING_EDGE) + return MASTER_TRIGGERS; + } + } + return NO_SYNCHRONIZATION; + + case SLAVE_STARTS_WHEN_MASTER_STOPS: + for (i=0; i<4; i++) { + if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) { + if (masterMode==IS_MASTER && getFPGASignal(i)==RO_TRIGGER_OUT_RISING_EDGE) + return SLAVE_STARTS_WHEN_MASTER_STOPS; + else if (masterMode==IS_SLAVE && getFPGASignal(i)==TRIGGER_IN_RISING_EDGE) + return SLAVE_STARTS_WHEN_MASTER_STOPS; + } + } + return NO_SYNCHRONIZATION; + + default: + return NO_SYNCHRONIZATION; + + } + + + */ + return NO_SYNCHRONIZATION; +} + +void checkFirmwareCompatibility(int flag){ + +} + +#endif diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3FunctionList.h b/slsDetectorSoftware/mythen3DetectorServer/mythen3FunctionList.h new file mode 100644 index 000000000..39c6a06a2 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/mythen3FunctionList.h @@ -0,0 +1,249 @@ +#ifdef SLS_DETECTOR_FUNCTION_LIST +#ifndef SLS_DETECTOR_FUNCTION_LIST_H +#define SLS_DETECTOR_FUNCTION_LIST_H + +#include "sls_receiver_defs.h" +#include "mythen3Server_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h + +#include +#include // FILE + + +/**************************************************** +This functions are used by the slsDetectroServer_funcs interface. +Here are the definitions, but the actual implementation should be done for each single detector. + +****************************************************/ + + +// basic tests +void checkFirmwareCompatibility(int flag); +#ifdef JUNGFRAUD +int checkType(); +u_int32_t testFpga(void); +int testBus(void); +#endif + +#if defined(MYTHEND) || defined(JUNGFRAUD) || defined(MTHEN3D) +int moduleTest( enum digitalTestMode arg, int imod); +#endif +int detectorTest( enum digitalTestMode arg); + +// Ids +int64_t getDetectorId(enum idMode arg); +u_int64_t getFirmwareVersion(); +#ifdef MYTHEND +int64_t getModuleId(enum idMode arg, int imod); +#elif JUNGFRAUDN_DAC +u_int16_t getHardwareVersionNumber(); +u_int16_t getHardwareSerialNumber(); +#endif +u_int32_t getDetectorNumber(); +u_int64_t getDetectorMAC(); +u_int32_t getDetectorIP(); + + +// initialization +void initControlServer(); +void initStopServer(); +#ifdef EIGERD +void getModuleConfiguration(); +#endif + +// set up detector +void allocateDetectorStructureMemory(); +int setupDetector(); + + +// advanced read/write reg +#ifndef EIGERD +extern u_int32_t writeRegister(u_int32_t offset, u_int32_t data); // blackfin.h +extern u_int32_t readRegister(u_int32_t offset); // blackfin.h +#else +uint32_t writeRegister(uint32_t offset, uint32_t data); +uint32_t readRegister(uint32_t offset); +#endif + + +// firmware functions (resets) +#ifdef JUNGFRAUD +int powerChip (int on); +void cleanFifos(); +void resetCore(); +void resetPeripheral(); +int adcPhase(int st); +int getPhase(); +#endif + +// parameters - nmod, dr, roi +int setNMod(int nm, enum dimension dim); // mythen specific, but for detector compatibility as a get +int getNModBoard(enum dimension arg); // mythen specific, but for detector compatibility as a get +int setDynamicRange(int dr); +#ifdef GOTTHARD +int setROI(int n, ROI arg[], int *retvalsize, int *ret); +#endif + +// parameters - readout +int setSpeed(enum speedVariable arg, int val); +#if defined(EIGERD) || defined(MYTHEND) +enum readOutFlags setReadOutFlags(enum readOutFlags val); +#endif +#ifdef MYTHEND +int executeTrimming(enum trimMode mode, int par1, int par2, int imod); +#endif + +// parameters - timer +int64_t setTimer(enum timerIndex ind, int64_t val); +#ifndef EIGERD +int64_t getTimeLeft(enum timerIndex ind); +#endif + + +// parameters - channel, chip, module, settings +#ifdef MYTHEND +int setChannel(sls_detector_channel myChan); +int getChannel(sls_detector_channel *myChan); +int setChip(sls_detector_chip myChip); +int getChip(sls_detector_chip *myChip); +#endif +#ifdef EIGERD +int setModule(sls_detector_module myMod, int delay); +#else +int setModule(sls_detector_module myMod); +#endif +int getModule(sls_detector_module *myMod); +enum detectorSettings setSettings(enum detectorSettings sett, int imod); +enum detectorSettings getSettings(); + + +// parameters - threshold +#if defined(MYTHEND) || defined(EIGERD) +int getThresholdEnergy(int imod); +int setThresholdEnergy(int ev, int imod); +#endif + +// parameters - dac, adc, hv +#ifdef JUNGFRAUD +void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset); +void initDac(int dacnum); +extern void setAdc(int addr, int val); // AD9257.h +int voltageToDac(int value); +int dacToVoltage(unsigned int digital); +#endif +// void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]); +double setDAC(enum DACINDEX ind, double val, int imod, int mV); + +#ifndef MYTHEND +int setHighVoltage(int val); +#endif + + + +// parameters - timing, extsig +#ifdef MYTHEND +enum externalSignalFlag getExtSignal(int signalindex); +enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag); +#endif +enum externalCommunicationMode setTiming( enum externalCommunicationMode arg); + +// configure mac +#ifdef JUNGFRAUD +long int calcChecksum(int sourceip, int destip); +#endif +#ifndef MYTHEND +int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival); +// int configureMAC(int ipad, long long int imacadd, long long int iservermacadd, int dtb); +#endif +#if defined(JUNGFRAUD) || defined(EIGERD) +int setDetectorPosition(int pos[]); +#endif + + +// very detector specific + +// gotthard specific - image, pedestal +#ifdef GOTTHARDD +int loadImage(enum imageType index, char *imageVals); +int readCounterBlock(int startACQ, char *counterVals); +int resetCounterBlock(int startACQ); +int calibratePedestal(int frames); + +// jungfrau specific - pll, flashing firmware +#elif JUNGFRAUD +void resetPLL(); +u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val); +void configurePll(); +extern void eraseFlash(); // programfpga.h +extern int startWritingFPGAprogram(FILE** filefp); // programfpga.h +extern void stopWritingFPGAprogram(FILE* filefp); // programfpga.h +extern int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp); // programfpga.h + +// eiger specific - iodelay, 10g, pulse, rate, temp, activate, delay nw parameter +#elif EIGERD +int setIODelay(int val, int imod); +int enableTenGigabitEthernet(int val); +int setCounterBit(int val); +int pulsePixel(int n, int x, int y); +int pulsePixelNMove(int n, int x, int y); +int pulseChip(int n); +int64_t setRateCorrection(int64_t custom_tau_in_nsec); +int getRateCorrectionEnable(); +int getDefaultSettingsTau_in_nsec(); +void setDefaultSettingsTau_in_nsec(int t); +int64_t getCurrentTau(); +void setExternalGating(int enable[]); +int setAllTrimbits(int val); +int getAllTrimbits(); +int getBebFPGATemp(); +int activate(int enable); +int setNetworkParameter(enum NETWORKINDEX mode, int value); +#endif + + + + +// aquisition +#if defined(EIGERD) || defined(GOTTHARD) +int prepareAcquisition(); +#endif +int startStateMachine(); +#ifdef VIRTUAL +void* start_timer(void* arg); +#endif +int stopStateMachine(); +#ifndef JUNGFRAUD +int startReadOut(); +#endif +enum runStatus getRunStatus(); +// void readFrame(int *ret, char *mess); +char *readFrame(int *ret, char *mess); +#ifdef JUNGFRAUD +u_int32_t runBusy(void); +#endif + + +//common +int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod); +int calculateDataBytes(); +int getTotalNumberOfChannels(); +int getTotalNumberOfChips(); +int getTotalNumberOfModules(); +int getNumberOfChannelsPerModule(); +int getNumberOfChipsPerModule(); +int getNumberOfDACsPerModule(); +int getNumberOfADCsPerModule(); +#ifdef EIGERD +int getNumberOfGainsPerModule(); +int getNumberOfOffsetsPerModule(); +#endif +int getNumberOfChannelsPerChip(); + +// sync +enum masterFlags setMaster(enum masterFlags arg); +enum synchronizationMode setSynchronization(enum synchronizationMode arg); + +int setPower(int ind, int val); + + +#endif +#endif diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3RegisterDefs.h b/slsDetectorSoftware/mythen3DetectorServer/mythen3RegisterDefs.h new file mode 100644 index 000000000..e475e8fcb --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/mythen3RegisterDefs.h @@ -0,0 +1,551 @@ +#ifndef REGISTERS_G_H +#define REGISTERS_G_H + + +#include "sls_detector_defs.h" + + +/* Definitions for FPGA*/ +#define CSP0 0x20200000 +#define MEM_SIZE 0x100000 + + + +/* values defined for FPGA */ +#define MCSNUM 0x0 +#define FIXED_PATT_VAL 0xacdc1980 + + +#define FPGA_INIT_PAT 0x60008 +#define FPGA_INIT_ADDR 0xb0000000 + +//#ifdef JUNGFRAU_DHANYA +#define POWER_ON_REG 0x5e<<11 +// Pwr_I2C_SDA <= PowerReg_s(1) when PowerReg_s(3)='1' else 'Z'; +// Pwr_I2C_SCL <= PowerReg_s(0) when PowerReg_s(2)='1' else 'Z'; + +#define PWR_I2C_SCL_BIT 0 +#define PWR_I2C_SDA_BIT 1 +#define PWR_I2C_SCL_EN_BIT 2 +#define PWR_I2C_SDA_EN_BIT 3 + +#define POWER_STATUS_REG 41<<11 + +#define ADCREG1 0x08 +#define ADCREG2 0x14//20 +#define ADCREG3 0x4 +#define ADCREG4 0x5 +#define ADCREG_VREFS 24 +#define DBIT_PIPELINE_REG 89<<11 //0x59 same PATTERN_N_LOOP2_REG +#define MEM_MACHINE_FIFOS_REG 79<<11 //from gotthard +#define CONFGAIN_REG 93<<11 //from gotthard +#define ADC_PIPELINE_REG 66<<11 //0x42 same as ADC_OFFSET_REG +//#endif + +//#define ADC_OFFSET_REG 93<<11 //same as DAQ_REG +#define ADC_INVERSION_REG 67<<11 + +#define DAC_REG 64<<11//0x17<<11// control the dacs +//ADC +#define ADC_WRITE_REG 65<<11//0x18<<11 +//#define ADC_SYNC_REG 66<<11//0x19<<11 +//#define HV_REG 67<<11//0x20<<11 + + + + +//#define MUTIME_REG 0x1a<<11 +//temperature +#define TEMP_IN_REG 0x1b<<11 +#define TEMP_OUT_REG 0x1c<<11 +//configure MAC +#define TSE_CONF_REG 0x1d<<11 +#define ENET_CONF_REG 0x1e<<11 +//#define WRTSE_SHAD_REG 0x1f<<11 +//HV + + +#define DUMMY_REG 68<<11//0x21<<11 +#define FPGA_VERSION_REG 0<<11 //0x22<<11 +#define PCB_REV_REG 0<<11 +#define FIX_PATT_REG 1<<11 //0x23<<11 +#define CONTROL_REG 79<<11//0x24<<11 +#define STATUS_REG 2<<11 //0x25<<11 +#define CONFIG_REG 77<<11//0x26<<11 +#define EXT_SIGNAL_REG 78<<11// 0x27<<11 +//#define FPGA_SVN_REG 0x29<<11 + + +#define CHIP_OF_INTRST_REG 0x2A<<11 + +//FIFO +#define LOOK_AT_ME_REG 3<<11 //0x28<<11 +#define SYSTEM_STATUS_REG 4<<11 + +#define FIFO_DATA_REG 6<<11 +#define FIFO_STATUS_REG 7<<11 + +// constant FifoDigitalInReg_c : integer := 60; +#define FIFO_DIGITAL_DATA_LSB_REG 60<<11 +#define FIFO_DIGITAL_DATA_MSB_REG 61<<11 + +#define FIFO_DATA_REG_OFF 0x50<<11 /////// +//to read back dac registers +//#define MOD_DACS1_REG 0x65<<11 +//#define MOD_DACS2_REG 0x66<<11 +//#define MOD_DACS3_REG 0x67<<11 + +//user entered + + + + + + +#define GET_ACTUAL_TIME_LSB_REG 16<<11 +#define GET_ACTUAL_TIME_MSB_REG 17<<11 + +#define GET_MEASUREMENT_TIME_LSB_REG 38<<11 +#define GET_MEASUREMENT_TIME_MSB_REG 39<<11 + + +#define SET_DELAY_LSB_REG 96<<11 //0x68<<11 +#define SET_DELAY_MSB_REG 97<<11 //0x69<<11 +#define GET_DELAY_LSB_REG 18<<11//0x6a<<11 +#define GET_DELAY_MSB_REG 19<<11//0x6b<<11 + +#define SET_CYCLES_LSB_REG 98<<11//0x6c<<11 +#define SET_CYCLES_MSB_REG 99<<11//0x6d<<11 +#define GET_CYCLES_LSB_REG 20<<11//0x6e<<11 +#define GET_CYCLES_MSB_REG 21<<11//0x6f<<11 + +#define SET_FRAMES_LSB_REG 100<<11//0x70<<11 +#define SET_FRAMES_MSB_REG 101<<11//0x71<<11 +#define GET_FRAMES_LSB_REG 22<<11//0x72<<11 +#define GET_FRAMES_MSB_REG 23<<11//0x73<<11 + +#define SET_PERIOD_LSB_REG 102<<11//0x74<<11 +#define SET_PERIOD_MSB_REG 103<<11//0x75<<11 +#define GET_PERIOD_LSB_REG 24<<11//0x76<<11 +#define GET_PERIOD_MSB_REG 25<<11//0x77<<11 + +//#define PATTERN_WAIT0_TIME_REG_LSB 114<<11 +//#define PATTERN_WAIT0_TIME_REG_MSB 115<<11 +#define SET_EXPTIME_LSB_REG 114<<11//0x78<<11 +#define SET_EXPTIME_MSB_REG 115<<11//0x79<<11 +#define GET_EXPTIME_LSB_REG 26<<11//0x7a<<11 +#define GET_EXPTIME_MSB_REG 27<<11//0x7b<<11 + +#define SET_GATES_LSB_REG 106<<11//0x7c<<11 +#define SET_GATES_MSB_REG 107<<11//0x7d<<11 +#define GET_GATES_LSB_REG 28<<11//0x7e<<11 +#define GET_GATES_MSB_REG 29<<11//0x7f<<11 + +#define DATA_IN_LSB_REG 30<<11 +#define DATA_IN_MSB_REG 31<<11 + +#define PATTERN_OUT_LSB_REG 32<<11 +#define PATTERN_OUT_MSB_REG 33<<11 + +#define FRAMES_FROM_START_LSB_REG 34<<11 +#define FRAMES_FROM_START_MSB_REG 35<<11 + +#define FRAMES_FROM_START_PG_LSB_REG 36<<11 +#define FRAMES_FROM_START_PG_MSB_REG 37<<11 + +#define SLOW_ADC_REG 43<<11 + + + +#define PLL_PARAM_REG 80<<11//0x37<<11 +#define PLL_PARAM_OUT_REG 5<<11 //0x38<<11 +#define PLL_CNTRL_REG 81<<11//0x34<<11 + + +#ifdef NEW_GBE_INTERFACE +#define GBE_PARAM_OUT_REG 40<<11 +#define GBE_PARAM_REG 69<<11 +#define GBE_CNTRL_REG 70<<11 +#else +#define RX_UDP_AREG 69<<11 //rx_udpip_AReg_c : integer:= 69; *\/ +#define UDPPORTS_AREG 70<<11// udpports_AReg_c : integer:= 70; *\/ +#define RX_UDPMACL_AREG 71<<11//rx_udpmacL_AReg_c : integer:= 71; *\/ +#define RX_UDPMACH_AREG 72<<11//rx_udpmacH_AReg_c : integer:= 72; *\/ +#define DETECTORMACL_AREG 73<<11//detectormacL_AReg_c : integer:= 73; *\/ +#define DETECTORMACH_AREG 74<<11//detectormacH_AReg_c : integer:= 74; *\/ +#define DETECTORIP_AREG 75<<11//detectorip_AReg_c : integer:= 75; *\/ +#define IPCHKSUM_AREG 76<<11//ipchksum_AReg_c : integer:= 76; *\/ */ +#endif + + +#define PATTERN_CNTRL_REG 82<<11 // address of patword +#define PATTERN_LIMITS_AREG 83<<11 // start/stop pattern + +#define PATTERN_LOOP0_AREG 84<<11 // start/stop of loop +#define PATTERN_N_LOOP0_REG 85<<11 // # loops + +#define PATTERN_LOOP1_AREG 86<<11 +#define PATTERN_N_LOOP1_REG 87<<11 + +#define PATTERN_LOOP2_AREG 88<<11 +#define PATTERN_N_LOOP2_REG 89<<11 + +#define PATTERN_WAIT0_AREG 90<<11 // address where to wait +#define PATTERN_WAIT1_AREG 91<<11 +#define PATTERN_WAIT2_AREG 92<<11 + + + +//#define DAQ_REG 93<<11 //unused +#define NSAMPLES_REG 93<<11 //unused + + +#define HV_REG 95<<11 + + + +#define PATTERN_IOCTRL_REG_LSB 108<<11 // if output or not +#define PATTERN_IOCTRL_REG_MSB 109<<11 + +#define PATTERN_IOCLKCTRL_REG_LSB 110<<11//unused +#define PATTERN_IOCLKCTRL_REG_MSB 111<<11//unused +#define PATTERN_IN_REG_LSB 112<<11 // write word +#define PATTERN_IN_REG_MSB 113<<11 +#define PATTERN_WAIT0_TIME_REG_LSB 114<<11 // how long to wait +#define PATTERN_WAIT0_TIME_REG_MSB 115<<11 +#define PATTERN_WAIT1_TIME_REG_LSB 116<<11 +#define PATTERN_WAIT1_TIME_REG_MSB 117<<11 +#define PATTERN_WAIT2_TIME_REG_LSB 118<<11 +#define PATTERN_WAIT2_TIME_REG_MSB 119<<11 + +//#define DAC_REG_OFF 120 +//#define DAC_0_1_VAL_REG 120<<11 +//#define DAC_2_3_VAL_REG 121<<11 +//#define DAC_4_5_VAL_REG 122<<11 +//#define DAC_6_7_VAL_REG 123<<11 +//#define DAC_8_9_VAL_REG 124<<11 +//#define DAC_10_11_VAL_REG 125<<11 +//#define DAC_12_13_VAL_REG 126<<11 +//#define DAC_14_15_VAL_REG 127<<11 +#define DAC_VAL_REG 121<<11 // value of the DAC +#define DAC_NUM_REG 122<<11 // Index of the DAC, only JCTB +#define DAC_VAL_OUT_REG 42<<11 +#define ADC_LATCH_DISABLE_REG 120<<11 + + + + + + + + +/* registers defined in FPGA */ +#define GAIN_REG 0 +//#define FLOW_CONTROL_REG 0x11<<11 +//#define FLOW_STATUS_REG 0x12<<11 +//#define FRAME_REG 0x13<<11 +#define MULTI_PURPOSE_REG 0 +//#define TIME_FROM_START_REG 0x16<<11 + + +#define ROI_REG 0 // 0x35<<11 +#define OVERSAMPLING_REG 0 // 0x36<<11 +#define MOENCH_CNTR_REG 0 // 0x31<<11 +#define MOENCH_CNTR_OUT_REG 0 // 0x33<<11 +#define MOENCH_CNTR_CONF_REG 0 // 0x32<<11 + + + +//image +#define DARK_IMAGE_REG 0 // 0x81<<11 +#define GAIN_IMAGE_REG 0 // 0x82<<11 + +//counter block memory +#define COUNTER_MEMORY_REG 0 // 0x85<<11 //gotthard + + +//not used +//#define MCB_DOUT_REG_OFF 0 // 0x200000 +//#define FIFO_CNTRL_REG_OFF 0 // 0x300000 +//#define FIFO_COUNTR_REG_OFF 0 // 0x400000 +//not used so far +//#define SPEED_REG 0 // 0x006000 +//#define SET_NBITS_REG 0 // 0x008000 +//not used +//#define GET_SHIFT_IN_REG 0 // 0x022000 + + + +#define SHIFTMOD 2 +#define SHIFTFIFO 9 + +/** for PCB_REV_REG */ +#define DETECTOR_TYPE_MASK 0xFF000000 +#define DETECTOR_TYPE_OFFSET 24 +#define BOARD_REVISION_MASK 0xFFFFFF +#define MOENCH03_MODULE_ID 2 +#define JUNGFRAU_MODULE_ID 1 +#define JUNGFRAU_CTB_ID 3 + + + + +/* for control register (16bit only)*/ +#define START_ACQ_BIT 0x0001 +#define STOP_ACQ_BIT 0x0002 +#define START_FIFOTEST_BIT 0x0004 // ????? +#define STOP_FIFOTEST_BIT 0x0008 // ?????? +#define START_READOUT_BIT 0x0010 +#define STOP_READOUT_BIT 0x0020 +#define START_EXPOSURE_BIT 0x0040 +#define STOP_EXPOSURE_BIT 0x0080 +#define START_TRAIN_BIT 0x0100 +#define STOP_TRAIN_BIT 0x0200 +#define FIFO_RESET_BIT 0x8000 +#define SYNC_RESET 0x0400 +#define GB10_RESET_BIT 0x0800 +#define MEM_RESET_BIT 0x1000 + +/* for status register */ +#define RUN_BUSY_BIT 0x00000001 +#define READOUT_BUSY_BIT 0x00000002 +#define FIFOTEST_BUSY_BIT 0x00000004 //???? +#define WAITING_FOR_TRIGGER_BIT 0x00000008 +#define DELAYBEFORE_BIT 0x00000010 +#define DELAYAFTER_BIT 0x00000020 +#define EXPOSING_BIT 0x00000040 +#define COUNT_ENABLE_BIT 0x00000080 +#define READSTATE_0_BIT 0x00000100 +#define READSTATE_1_BIT 0x00000200 +#define READSTATE_2_BIT 0x00000400 +#define LAM_BIT 0x00000400 // error! +#define SOME_FIFO_FULL_BIT 0x00000800 // error! + + + +#define RUNSTATE_0_BIT 0x00001000 +#define RUNSTATE_1_BIT 0x00002000 +#define RUNSTATE_2_BIT 0x00004000 +#define STOPPED_BIT 0x00008000 // stopped! +#define ALL_FIFO_EMPTY_BIT 0x00010000 // data ready +#define RUNMACHINE_BUSY_BIT 0x00020000 +#define READMACHINE_BUSY_BIT 0x00040000 +#define PLL_RECONFIG_BUSY 0x00100000 + + + +/* for fifo status register */ +#define FIFO_ENABLED_BIT 0x80000000 +#define FIFO_DISABLED_BIT 0x01000000 +#define FIFO_ERROR_BIT 0x08000000 +#define FIFO_EMPTY_BIT 0x04000000 +#define FIFO_DATA_READY_BIT 0x02000000 +#define FIFO_COUNTER_MASK 0x000001ff +#define FIFO_NM_MASK 0x00e00000 +#define FIFO_NM_OFF 21 +#define FIFO_NC_MASK 0x001ffe00 +#define FIFO_NC_OFF 9 + +/* for config register *///not really used yet +#define TOT_ENABLE_BIT 0x00000002 +#define TIMED_GATE_BIT 0x00000004 +#define CONT_RO_ENABLE_BIT 0x00080000 +#define GB10_NOT_CPU_BIT 0x00001000 +#define ADC_OUTPUT_DISABLE_BIT 0x00100 +#define DIGITAL_OUTPUT_ENABLE_BIT 0x00200 + + +/* for speed register */ +#define CLK_DIVIDER_MASK 0x000000ff +#define CLK_DIVIDER_OFFSET 0 +#define SET_LENGTH_MASK 0x00000f00 +#define SET_LENGTH_OFFSET 8 +#define WAIT_STATES_MASK 0x0000f000 +#define WAIT_STATES_OFFSET 12 +#define TOTCLK_DIVIDER_MASK 0xff000000 +#define TOTCLK_DIVIDER_OFFSET 24 +#define TOTCLK_DUTYCYCLE_MASK 0x00ff0000 +#define TOTCLK_DUTYCYCLE_OFFSET 16 + +/* for external signal register */ +#define SIGNAL_OFFSET 4 +#define SIGNAL_MASK 0xF +#define EXT_SIG_OFF 0x0 +#define EXT_GATE_IN_ACTIVEHIGH 0x1 +#define EXT_GATE_IN_ACTIVELOW 0x2 +#define EXT_TRIG_IN_RISING 0x3 +#define EXT_TRIG_IN_FALLING 0x4 +#define EXT_RO_TRIG_IN_RISING 0x5 +#define EXT_RO_TRIG_IN_FALLING 0x6 +#define EXT_GATE_OUT_ACTIVEHIGH 0x7 +#define EXT_GATE_OUT_ACTIVELOW 0x8 +#define EXT_TRIG_OUT_RISING 0x9 +#define EXT_TRIG_OUT_FALLING 0xA +#define EXT_RO_TRIG_OUT_RISING 0xB +#define EXT_RO_TRIG_OUT_FALLING 0xC + + + +/* for temperature register */ +#define T1_CLK_BIT 0x00000001 +#define T1_CS_BIT 0x00000002 +#define T2_CLK_BIT 0x00000004 +#define T2_CS_BIT 0x00000008 + + + +/* fifo control register */ +//#define FIFO_RESET_BIT 0x00000001 +//#define FIFO_DISABLE_TOGGLE_BIT 0x00000002 + + +//chip shiftin register meaning +#define OUTMUX_OFF 20 +#define OUTMUX_MASK 0x1f +#define PROBES_OFF 4 +#define PROBES_MASK 0x7f +#define OUTBUF_OFF 0 +#define OUTBUF_MASK 1 + + +/* multi purpose register */ +#define PHASE_STEP_BIT 0x00000001 +#define PHASE_STEP_OFFSET 0 +// #define xxx_BIT 0x00000002 +#define RESET_COUNTER_BIT 0x00000004 +#define RESET_COUNTER_OFFSET 2 +//#define xxx_BIT 0x00000008 +//#define xxx_BIT 0x00000010 +#define SW1_BIT 0x00000020 +#define SW1_OFFSET 5 +#define WRITE_BACK_BIT 0x00000040 +#define WRITE_BACK_OFFSET 6 +#define RESET_BIT 0x00000080 +#define RESET_OFFSET 7 +#define ENET_RESETN_BIT 0x00000800 +#define ENET_RESETN_OFFSET 11 +#define INT_RSTN_BIT 0x00002000 +#define INT_RSTN_OFFSET 13 +#define DIGITAL_TEST_BIT 0x00004000 +#define DIGITAL_TEST_OFFSET 14 +//#define CHANGE_AT_POWER_ON_BIT 0x00008000 +//#define CHANGE_AT_POWER_ON_OFFSET 15 + + +/* settings/conf gain register */ +#define GAIN_MASK 0x0000000f +#define GAIN_OFFSET 0 +#define SETTINGS_MASK 0x000000f0 +#define SETTINGS_OFFSET 4 + + +/* CHIP_OF_INTRST_REG */ +#define CHANNEL_MASK 0xffff0000 +#define CHANNEL_OFFSET 16 +#define ACTIVE_ADC_MASK 0x0000001f + + + +/**ADC SYNC CLEAN FIFO*/ +#define ADCSYNC_CLEAN_FIFO_BITS 0x300000 +#define CLEAN_FIFO_MASK 0x0fffff + + + + +enum {run_clk_c, adc_clk_c, sync_clk_c, dbit_clk_c}; + + + + +#define PLL_CNTR_ADDR_OFF 16 //PLL_CNTR_REG bits 21 downto 16 represent the counter address + +#define PLL_CNTR_RECONFIG_RESET_BIT 0 +#define PLL_CNTR_READ_BIT 1 +#define PLL_CNTR_WRITE_BIT 2 +#define PLL_CNTR_PLL_RESET_BIT 3 + + +#define PLL_CNTR_PHASE_EN_BIT 8 +#define PLL_CNTR_UPDN_BIT 9 +#define PLL_CNTR_CNTSEL_OFF 10 + + + + + +#define PLL_MODE_REG 0x0 +#define PLL_STATUS_REG 0x1 +#define PLL_START_REG 0x2 +#define PLL_N_COUNTER_REG 0x3 +#define PLL_M_COUNTER_REG 0x4 +#define PLL_C_COUNTER_REG 0x5 //which ccounter stands in param 22:18; 7:0 lowcount 15:8 highcount; 16 bypassenable; 17 oddivision +#define PLL_PHASE_SHIFT_REG 0x6 // which ccounter stands in param 16:20; 21 updown (1 up, 0 down) +#define PLL_K_COUNTER_REG 0x7 +#define PLL_BANDWIDTH_REG 0x8 +#define PLL_CHARGEPUMP_REG 0x9 +#define PLL_VCO_DIV_REG 0x1c +#define PLL_MIF_REG 0x1f + +#define PPL_M_CNT_PARAM_DEFAULT 0x4040 +#define PPL_N_CNT_PARAM_DEFAULT 0x20D0C +#define PPL_C0_CNT_PARAM_DEFAULT 0x20D0C +#define PPL_C1_CNT_PARAM_DEFAULT 0xA0A0 +#define PPL_C2_CNT_PARAM_DEFAULT 0x20D0C +#define PPL_C3_CNT_PARAM_DEFAULT 0x0808 +#define PPL_BW_PARAM_DEFAULT 0x2EE0 +#define PPL_VCO_PARAM_DEFAULT 0x1 + +#define NEW_PLL_RECONFIG + +#ifdef NEW_PLL_RECONFIG +#define PLL_VCO_FREQ_MHZ 400//480//800 +#else +#define PLL_VCO_FREQ_MHZ 480//800 +#endif + + + + + +/* + GBE parameter and control registers definitions +*/ + +#define GBE_CTRL_WSTROBE 0 +#define GBE_CTRL_VAR_OFFSET 16 +#define GBE_CTRL_VAR_MASK 0XF +#define GBE_CTRL_RAMADDR_OFFSET 24 +#define GBE_CTRL_RAMADDR_MASK 0X3F +#define GBE_CTRL_INTERFACE 23 + +#define RX_UDP_IP_ADDR 0 +#define RX_UDP_PORTS_ADDR 1 +#define RX_UDP_MAC_L_ADDR 2 +#define RX_UDP_MAC_H_ADDR 3 +#define IPCHECKSUM_ADDR 4 +#define GBE_DELAY_ADDR 5 +#define GBE_RESERVED1_ADDR 6 +#define GBE_RESERVED2_ADDR 7 +#define DETECTOR_MAC_L_ADDR 8 +#define DETECTOR_MAC_H_ADDR 9 +#define DETECTOR_IP_ADDR 10 + + + +/**------------------ +-- pattern registers definitions +--------------------------------------------- */ +#define IOSIGNALS_MASK 0xfffffffffffff +#define ADC_ENABLE_BIT 63 +#define APATTERN_MASK 0xffff +#define ASTART_OFFSET 0 +#define ASTOP_OFFSET 16 +#define PATTERN_CTRL_WRITE_BIT 0 +#define PATTERN_CTRL_READ_BIT 1 +#define PATTERN_CTRL_ADDR_OFFSET 16 +#define MAX_PATTERN_LENGTH 1024 + + +#endif + diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3Server b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server new file mode 100755 index 000000000..2f0fcf0df Binary files /dev/null and b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server differ diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3Server.gdb b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server.gdb new file mode 100755 index 000000000..4d4b23a68 Binary files /dev/null and b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server.gdb differ diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_defs.h b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_defs.h new file mode 100644 index 000000000..705a9f891 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_defs.h @@ -0,0 +1,93 @@ +/* + * mythen3Server_defs.h + * + * Created on: Jan 24, 2013 + * Author: l_maliakal_d, changed my Marie A. + */ + +#ifndef SLSDETECTORSERVER_DEFS_H_ +#define SLSDETECTORSERVER_DEFS_H_ + +#include "sls_detector_defs.h" +#include + +/** This is only an example file!!! */ + + + +#define GOODBYE (-200) +enum ADCINDEX {TEMP_FPGA, TEMP_ADC}; +enum DACINDEX {vIpre, vIbias, Vrf, VrfSh, vIinSh, VdcSh, Vth2, VPL, Vth1, Vth3, Vtrim, casSh, cas, vIbiasSh, vIcin, VPH, NC, vIpreOut}; // Mythen 3.01 +#define DEFAULT_DAC_VALS { 2150, /* vIpre */ \ + 1200, /* vIbias */ \ + 900, /* Vrf */ \ + 1050, /* VrfSh */ \ + 1400, /* vIinSh */ \ + 655, /* VdcSh */ \ + 850, /* Vth2 */ \ + 1400, /* VPL */ \ + 850, /* Vth1 */ \ + 850, /* Vth3 */ \ + 2294, /* Vtrim */ \ + 983, /* casSh */ \ + 1474, /* cas */ \ + 1200, /* vIbiasSh */ \ + 1600, /* vIcin */ \ + 1520, /* VPH */ \ + 0, /* NC */ \ + 1000 /* vIpreOut */ \ + }; + +/*Hardware Definitions +#define NMAXMOD (1) +#define NMOD (1) +#define NCHAN (256 * 256) +#define NCHIP (4) +#define NADC (0) +#define NDAC (16) +#define NGAIN (0) +#define NOFFSET (0) +*/ + +/** Default Parameters */ +#define DEFAULT_EXPTIME (10*1000) //ns + +/* Hardware Definitions */ +//#define NMAXMOD (1) +#define NMOD (1) +//#define NCHAN (256 * 256) +//#define NCHIP (8) +//#define NADC (0) +#define NDAC (8) +#define NDAC_OLDBOARD (16) +#define DYNAMIC_RANGE (16) +#define NUM_BITS_PER_PIXEL (DYNAMIC_RANGE / 8) +#define DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL) +#define IP_PACKETSIZE (0x2052) +#define CLK_RUN (40) /* MHz */ +#define CLK_SYNC (20) /* MHz */ + + +// Hardware definitions + +#define NCHAN 36 +#define NCHIP 1 +#define NADC 9 // + +/* #ifdef CTB */ +/* #define NDAC 24 */ +/* #define NPWR 5 */ +/* #else */ +/* #define NDAC 16 */ +/* #define NPWR 0 */ +/* #endif */ +#define DAC_CMD_OFF 20 + +#define NMAXMODX 1 +#define NMAXMODY 1 +#define NMAXMOD (NMAXMODX*NMAXMODY) + +#define NCHANS (NCHAN*NCHIP*NMAXMOD) +#define NDACS (NDAC*NMAXMOD) + +#endif /* SLSDETECTORSERVER_DEFS_H_ */ diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_funcs.c b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_funcs.c new file mode 100755 index 000000000..5631c4187 --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_funcs.c @@ -0,0 +1,4916 @@ + +#include "sls_detector_defs.h" +#include "mythen3Server_funcs.h" +#include "mythen3FunctionList.h" +#include "communication_funcs.h" +#include "mythen3Server_defs.h" +// #include "mythen3RegisterDefs.h" +// #include "blackfin.h" + +#include +#include +#include + + +// Global variables +extern int lockStatus; +extern char lastClientIP[INET_ADDRSTRLEN]; +extern char thisClientIP[INET_ADDRSTRLEN]; +extern int differentClients; + +//defined in the detector specific Makefile +/*#ifdef MYTHEND +const enum detectorType myDetectorType=MYTHEN; +#elif GOTTHARDD +const enum detectorType myDetectorType=GOTTHARD; +#elif EIGERD +const enum detectorType myDetectorType=EIGER; +#elif PICASSOD +const enum detectorType myDetectorType=PICASSO; +#elif MOENCHD +const enum detectorType myDetectorType=MOENCH; +#elif JUNGFRAUD +const enum detectorType myDetectorType=JUNGFRAU; +#elif MYTHEN3D +const enum detectorType myDetectorType=MYTHEN3D; +#else +const enum detectorType myDetectorType=GENERIC; +#endif +*/ +enum detectorType myDetectorType=MYTHEN3; + +int sockfd; // (updated in slsDetectorServer) as extern +int (*flist[NUM_DET_FUNCTIONS])(int); +char mess[MAX_STR_LENGTH]; +int dataBytes = 10; +int isControlServer = 0; +int debugflag = 0; + +int N_DAC=24; +int N_PWR=5; + +int vPowerLimit = 1400; // mV + +/* initialization functions */ + +int printSocketReadError() { + cprintf(BG_RED, "Error reading from socket. Possible socket crash\n"); + return FAIL; +} + +void basictests(int flag) { + debugflag = flag; +#ifdef SLS_DETECTOR_FUNCTION_LIST + checkFirmwareCompatibility(debugflag); +#endif +} + + +void init_detector(int controlserver) { +// #ifdef VIRTUAL +// printf("This is a VIRTUAL detector\n"); +// #endif + +// #ifdef SLS_DETECTOR_FUNCTION_LIST +// if (controlserver) { +// isControlServer = 1; +// initControlServer(); +// } +// else initStopServer(); +// #endif + + strcpy(mess,"dummy message"); + strcpy(lastClientIP,"none"); + strcpy(thisClientIP,"none1"); + lockStatus=0; + #ifdef MYTHEN3D +printf("This is a mythen3 detector\n"); + #endif +} + + +int decode_function(int file_des) { + int fnum,n; + int ret=FAIL; +#ifdef VERBOSE + printf( "\nreceive data\n"); +#endif + n = receiveData(file_des,&fnum,sizeof(fnum),INT32); + if (n <= 0) { +#ifdef VERBOSE + printf("ERROR reading from socket %d, %d %d (%s)\n", n, fnum, file_des, getFunctionName((enum detFuncs)fnum)); +#endif + return FAIL; + } +#ifdef VERBOSE + else + printf("size of data received %d\n",n); +#endif + +#ifdef VERBOSE + printf(" calling function fnum=%d, (%s) located at 0x%x\n", fnum, getFunctionName((enum detFuncs)fnum), (unsigned int)flist[fnum]); +#endif + if (fnum<0 || fnum>=NUM_DET_FUNCTIONS) { + cprintf(BG_RED,"Unknown function enum %d\n", fnum); + ret=(M_nofunc)(file_des); + }else + ret=(*flist[fnum])(file_des); + if (ret == FAIL) + cprintf(RED, "Error executing the function = %d (%s)\n", fnum, getFunctionName((enum detFuncs)fnum)); + return ret; +} + + +const char* getFunctionName(enum detFuncs func) { + switch (func) { + case F_EXEC_COMMAND: return "F_EXEC_COMMAND"; + case F_GET_ERROR: return "F_GET_ERROR"; + case F_GET_DETECTOR_TYPE: return "F_GET_DETECTOR_TYPE"; + case F_SET_NUMBER_OF_MODULES: return "F_SET_NUMBER_OF_MODULES"; + case F_GET_MAX_NUMBER_OF_MODULES: return "F_GET_MAX_NUMBER_OF_MODULES"; + case F_SET_EXTERNAL_SIGNAL_FLAG: return "F_SET_EXTERNAL_SIGNAL_FLAG"; + case F_SET_EXTERNAL_COMMUNICATION_MODE: return "F_SET_EXTERNAL_COMMUNICATION_MODE"; + case F_GET_ID: return "F_GET_ID"; + case F_DIGITAL_TEST: return "F_DIGITAL_TEST"; + case F_ANALOG_TEST: return "F_ANALOG_TEST"; + case F_ENABLE_ANALOG_OUT: return "F_ENABLE_ANALOG_OUT"; + case F_CALIBRATION_PULSE: return "F_CALIBRATION_PULSE"; + case F_SET_DAC: return "F_SET_DAC"; + case F_GET_ADC: return "F_GET_ADC"; + case F_WRITE_REGISTER: return "F_WRITE_REGISTER"; + case F_READ_REGISTER: return "F_READ_REGISTER"; + case F_WRITE_MEMORY: return "F_WRITE_MEMORY"; + case F_READ_MEMORY: return "F_READ_MEMORY"; + case F_SET_CHANNEL: return "F_SET_CHANNEL"; + case F_GET_CHANNEL: return "F_GET_CHANNEL"; + case F_SET_ALL_CHANNELS: return "F_SET_ALL_CHANNELS"; + case F_SET_CHIP: return "F_SET_CHIP"; + case F_GET_CHIP: return "F_GET_CHIP"; + case F_SET_ALL_CHIPS: return "F_SET_ALL_CHIPS"; + case F_SET_MODULE: return "F_SET_MODULE"; + case F_GET_MODULE: return "F_GET_MODULE"; + case F_SET_ALL_MODULES: return "F_SET_ALL_MODULES"; + case F_SET_SETTINGS: return "F_SET_SETTINGS"; + case F_GET_THRESHOLD_ENERGY: return "F_GET_THRESHOLD_ENERGY"; + case F_SET_THRESHOLD_ENERGY: return "F_SET_THRESHOLD_ENERGY"; + case F_START_ACQUISITION: return "F_START_ACQUISITION"; + case F_STOP_ACQUISITION: return "F_STOP_ACQUISITION"; + case F_START_READOUT: return "F_START_READOUT"; + case F_GET_RUN_STATUS: return "F_GET_RUN_STATUS"; + case F_START_AND_READ_ALL: return "F_START_AND_READ_ALL"; + case F_READ_FRAME: return "F_READ_FRAME"; + case F_READ_ALL: return "F_READ_ALL"; + case F_SET_TIMER: return "F_SET_TIMER"; + case F_GET_TIME_LEFT: return "F_GET_TIME_LEFT"; + case F_SET_DYNAMIC_RANGE: return "F_SET_DYNAMIC_RANGE"; + case F_SET_READOUT_FLAGS: return "F_SET_READOUT_FLAGS"; + case F_SET_ROI: return "F_SET_ROI"; + case F_SET_SPEED: return "F_SET_SPEED"; + case F_EXECUTE_TRIMMING: return "F_EXECUTE_TRIMMING"; + case F_EXIT_SERVER: return "F_EXIT_SERVER"; + case F_LOCK_SERVER: return "F_LOCK_SERVER"; + case F_GET_LAST_CLIENT_IP: return "F_GET_LAST_CLIENT_IP"; + case F_SET_PORT: return "F_SET_PORT"; + case F_UPDATE_CLIENT: return "F_UPDATE_CLIENT"; + case F_CONFIGURE_MAC: return "F_CONFIGURE_MAC"; + case F_LOAD_IMAGE: return "F_LOAD_IMAGE"; + case F_SET_MASTER: return "F_SET_MASTER"; + case F_SET_SYNCHRONIZATION_MODE: return "F_SET_SYNCHRONIZATION_MODE"; + case F_READ_COUNTER_BLOCK: return "F_READ_COUNTER_BLOCK"; + case F_RESET_COUNTER_BLOCK: return "F_RESET_COUNTER_BLOCK"; + case F_CALIBRATE_PEDESTAL: return "F_CALIBRATE_PEDESTAL"; + case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA"; + case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS"; + case F_SET_CTB_PATTERN: return "F_SET_CTB_PATTERN"; + case F_WRITE_ADC_REG: return "F_WRITE_ADC_REG"; + case F_SET_COUNTER_BIT: return "F_SET_COUNTER_BIT"; + case F_PULSE_PIXEL: return "F_PULSE_PIXEL"; + case F_PULSE_PIXEL_AND_MOVE: return "F_PULSE_PIXEL_AND_MOVE"; + case F_PULSE_CHIP: return "F_PULSE_CHIP"; + case F_SET_RATE_CORRECT: return "F_SET_RATE_CORRECT"; + case F_GET_RATE_CORRECT: return "F_GET_RATE_CORRECT"; + case F_SET_NETWORK_PARAMETER: return "F_SET_NETWORK_PARAMETER"; + case F_PROGRAM_FPGA: return "F_PROGRAM_FPGA"; + case F_RESET_FPGA: return "F_RESET_FPGA"; + case F_POWER_CHIP: return "F_POWER_CHIP"; + case F_ACTIVATE: return "F_ACTIVATE"; + case F_PREPARE_ACQUISITION: return "F_PREPARE_ACQUISITION"; + case F_CLEANUP_ACQUISITION: return "F_CLEANUP_ACQUISITION"; + default: return "Unknown Function"; + } +} + +void function_table() { + flist[F_EXEC_COMMAND] = &exec_command; + flist[F_GET_ERROR] = &get_error; + flist[F_GET_DETECTOR_TYPE] = &get_detector_type; + flist[F_SET_NUMBER_OF_MODULES] = &set_number_of_modules; + flist[F_GET_MAX_NUMBER_OF_MODULES] = &get_max_number_of_modules; + flist[F_SET_EXTERNAL_SIGNAL_FLAG] = &set_external_signal_flag; + flist[F_SET_EXTERNAL_COMMUNICATION_MODE] = &set_external_communication_mode; + flist[F_GET_ID] = &get_id; + flist[F_DIGITAL_TEST] = &digital_test; + flist[F_ANALOG_TEST] = &analog_test; + flist[F_ENABLE_ANALOG_OUT] = &enable_analog_out; + flist[F_CALIBRATION_PULSE] = &calibration_pulse; + flist[F_SET_DAC] = &set_dac; + flist[F_GET_ADC] = &get_adc; + flist[F_WRITE_REGISTER] = &write_register; + flist[F_READ_REGISTER] = &read_register; + flist[F_WRITE_MEMORY] = &write_memory; + flist[F_READ_MEMORY] = &read_memory; + flist[F_SET_CHANNEL] = &set_channel; + flist[F_GET_CHANNEL] = &get_channel; + flist[F_SET_ALL_CHANNELS] = &set_all_channels; + flist[F_SET_CHIP] = &set_chip; + flist[F_GET_CHIP] = &get_chip; + flist[F_SET_ALL_CHIPS] = &set_all_chips; + flist[F_SET_MODULE] = &set_module; + flist[F_GET_MODULE] = &get_module; + flist[F_SET_ALL_MODULES] = &set_all_modules; + flist[F_SET_SETTINGS] = &set_settings; + flist[F_GET_THRESHOLD_ENERGY] = &get_threshold_energy; + flist[F_SET_THRESHOLD_ENERGY] = &set_threshold_energy; + flist[F_START_ACQUISITION] = &start_acquisition; + flist[F_STOP_ACQUISITION] = &stop_acquisition; + flist[F_START_READOUT] = &start_readout; + flist[F_GET_RUN_STATUS] = &get_run_status; + flist[F_START_AND_READ_ALL] = &start_and_read_all; + flist[F_READ_FRAME] = &read_frame; + flist[F_READ_ALL] = &read_all; + flist[F_SET_TIMER] = &set_timer; + flist[F_GET_TIME_LEFT] = &get_time_left; + flist[F_SET_DYNAMIC_RANGE] = &set_dynamic_range; + flist[F_SET_READOUT_FLAGS] = &set_readout_flags; + flist[F_SET_ROI] = &set_roi; + flist[F_SET_SPEED] = &set_speed; + flist[F_EXECUTE_TRIMMING] = &execute_trimming; + flist[F_EXIT_SERVER] = &exit_server; + flist[F_LOCK_SERVER] = &lock_server; + flist[F_GET_LAST_CLIENT_IP] = &get_last_client_ip; + flist[F_SET_PORT] = &set_port; + flist[F_UPDATE_CLIENT] = &update_client; + flist[F_CONFIGURE_MAC] = &configure_mac; + flist[F_LOAD_IMAGE] = &load_image; + flist[F_SET_MASTER] = &set_master; + flist[F_SET_SYNCHRONIZATION_MODE] = &set_synchronization; + flist[F_READ_COUNTER_BLOCK] = &read_counter_block; + flist[F_RESET_COUNTER_BLOCK] = &reset_counter_block; + flist[F_CALIBRATE_PEDESTAL] = &calibrate_pedestal; + flist[F_ENABLE_TEN_GIGA] = &enable_ten_giga; + flist[F_SET_ALL_TRIMBITS] = &set_all_trimbits; + flist[F_SET_CTB_PATTERN] = &set_ctb_pattern; + flist[F_WRITE_ADC_REG] = &write_adc_register; + flist[F_SET_COUNTER_BIT] = &set_counter_bit; + flist[F_PULSE_PIXEL] = &pulse_pixel; + flist[F_PULSE_PIXEL_AND_MOVE] = &pulse_pixel_and_move; + flist[F_PULSE_CHIP] = &pulse_chip; + flist[F_SET_RATE_CORRECT] = &set_rate_correct; + flist[F_GET_RATE_CORRECT] = &get_rate_correct; + flist[F_SET_NETWORK_PARAMETER] = &set_network_parameter; + flist[F_PROGRAM_FPGA] = &program_fpga; + flist[F_RESET_FPGA] = &reset_fpga; + flist[F_POWER_CHIP] = &power_chip; + flist[F_ACTIVATE] = &set_activate; + flist[F_PREPARE_ACQUISITION] = &prepare_acquisition; + flist[F_CLEANUP_ACQUISITION] = &cleanup_acquisition; + + // check + if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) { + cprintf(BG_RED,"The last detector function enum has reached its limit\nGoodbye!\n"); + exit(EXIT_FAILURE); + } + +#ifdef VERYVERBOSE + { + int i=0; + for (i = 0; i < NUM_DET_FUNCTIONS ; i++) { + printf("function fnum=%d, (%s) located at 0x%x\n", i, getFunctionName((enum detFuncs)i), (unsigned int)flist[i]); + } + } +#endif +} + + +int M_nofunc(int file_des){ + int ret=FAIL,ret1=FAIL; + int n=0; + + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + + sprintf(mess,"Unrecognized Function. Please do not proceed.\n"); + cprintf(BG_RED,"Error: %s",mess); + n = sendData(file_des,&ret1,sizeof(ret1),INT32); + n = sendData(file_des,mess,sizeof(mess),OTHER); + + // return ok / fail + return ret; +} + + + + + + +/* functions called by client */ + + + +int exec_command(int file_des) { + int ret=OK,ret1=OK; + int n=0; + char cmd[MAX_STR_LENGTH]=""; + int sysret=0; + + // receive arguments + n = receiveData(file_des,cmd,MAX_STR_LENGTH,OTHER); + if (n < 0) return printSocketReadError(); + + // execute action if the arguments correctly arrived +#ifdef VERBOSE + printf("executing command %s\n", cmd); +#endif + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } else { + sysret=system(cmd); + //should be replaced by popen + if (sysret==0) { + sprintf(mess,"Succeeded\n"); + } else { + ret = FAIL; + sprintf(mess,"Executing Command failed\n"); + cprintf(RED, "Warning: %s", mess); + } + } + + ret1=ret; + n = sendData(file_des,&ret1,sizeof(ret),INT32); + n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); + + // return ok / fail + return ret; +} + + + +int get_error(int file_des) { + int ret=FAIL,ret1=FAIL; + int n=0; + sprintf(mess,"Function (Get Error) is not implemented for this detector\n"); + cprintf(RED, "Error: %s", mess); + + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + + n = sendData(file_des,&ret1,sizeof(ret),INT32); + n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); + + // return ok / fail + return ret; +} + + + +int get_detector_type(int file_des) { + int ret=OK,ret1=OK; + int n=0; + enum detectorType retval=-1; + + // execute action + retval=myDetectorType; +#ifdef VERBOSE + printf("Returning detector type %d\n",retval); +#endif + + if (differentClients) + ret=FORCE_UPDATE; + + // send ok / fail + n += sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; + + +} + + + + +int set_number_of_modules(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=0; + int arg[2]={-1,-1}; + sprintf(mess,"set number of modules failed\n"); + + // receive arguments + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + enum dimension dim=arg[0]; + int nm=arg[1]; + + // execute action +#ifdef VERBOSE + printf("Setting the number of modules in dimension %d to %d\n",dim,nm ); +#endif + if (lockStatus && differentClients && nm!=GET_FLAG) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { + retval=setNMod(nm, dim); + dataBytes=calculateDataBytes(); + } +#endif + + if (retval==nm || nm==GET_FLAG) { + ret=OK; + if (differentClients) + ret=FORCE_UPDATE; + } else + ret=FAIL; + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret!=FAIL) { + n += sendData(file_des,&retval,sizeof(retval),INT32); + } else { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + +int get_max_number_of_modules(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + enum dimension arg=0; + sprintf(mess,"get max number of modules failed\n"); + + // receive arguments + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action +#ifdef VERBOSE + printf("Getting the max number of modules in dimension %d \n",arg); +#endif +#ifdef SLS_DETECTOR_FUNCTION_LIST + retval=getNModBoard(arg); +#endif +#ifdef VERBOSE + printf("Max number of module in dimension %d is %d\n",arg,retval ); +#endif + if (differentClients && ret==OK) { + ret=FORCE_UPDATE; + } + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret!=FAIL) { + n += sendData(file_des,&retval,sizeof(retval),INT32); + } else { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + +int set_external_signal_flag(int file_des) { + int ret=OK,ret1=OK; + int n=0; + enum externalSignalFlag retval=GET_EXTERNAL_SIGNAL_FLAG; + sprintf(mess,"set external signal flag failed\n"); + +#ifndef MYTHEND + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Set External Signal Flag) is not implemented for this detector\n"); + cprintf(RED, "%s", mess); +#else + + // receive arguments + int arg[2]={-1,-1}; + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + int signalindex=arg[0]; + enum externalSignalFlag flag=arg[1]; + + // execute action + if (lockStatus && differentClients && flag!=GET_EXTERNAL_SIGNAL_FLAG) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } + +#ifdef SLS_DETECTOR_FUNCTION_LIST + else{ +#ifdef VERBOSE + printf("Setting external signal %d to flag %d\n",signalindex,flag); +#endif + switch (flag) { + case GET_EXTERNAL_SIGNAL_FLAG: + retval=getExtSignal(signalindex); + break; + default: + retval=setExtSignal(signalindex,flag); + if (retval!=flag) { + ret=FAIL; + sprintf(mess,"External signal %d flag should be 0x%04x but is 0x%04x\n", signalindex, flag, retval); + cprintf(RED, "%s", mess); + } + break; + } +#ifdef VERBOSE + printf("Set to flag %d\n",retval); +#endif + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret!=FAIL) { + n += sendData(file_des,&retval,sizeof(retval),INT32); + } else { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; + +} + + +int set_external_communication_mode(int file_des) { + int ret=OK,ret1=OK; + int n=0; + enum externalCommunicationMode arg=GET_EXTERNAL_COMMUNICATION_MODE; + enum externalCommunicationMode retval=GET_EXTERNAL_COMMUNICATION_MODE; + sprintf(mess,"set external communication mode failed\n"); + + // receive arguments + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action +#ifdef VERBOSE + printf("Setting external communication mode to %d\n", arg); +#endif +#ifdef SLS_DETECTOR_FUNCTION_LIST + switch(arg){ +#ifdef EIGERD + case GET_EXTERNAL_COMMUNICATION_MODE: + case AUTO_TIMING: + case TRIGGER_EXPOSURE: + case GATE_FIX_NUMBER: + case BURST_TRIGGER: +#elif JUNGFRAUD + case GET_EXTERNAL_COMMUNICATION_MODE: + case AUTO_TIMING: + case TRIGGER_EXPOSURE: +#endif + retval=setTiming(arg); + break; + default: + ret = FAIL; + sprintf(mess,"Timing mode (%d) is not implemented for this detector\n",(int)arg); + cprintf(RED, "Warning: %s", mess); + break; + } +#ifdef VERBOSE + if(ret==OK) + printf("retval:%d\n",retval); +#endif + if (ret==OK && differentClients==1) + ret=FORCE_UPDATE; + +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret!=FAIL) { + n += sendData(file_des,&retval,sizeof(retval),INT32); + } else { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + +int get_id(int file_des) { + int ret=OK,ret1=OK; + int n=0; + enum idMode arg=0; + int imod=-1; + int64_t retval=-1; + sprintf(mess,"get id failed\n"); + + // receive arguments + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + if (arg == MODULE_FIRMWARE_VERSION) { + n = receiveData(file_des,&imod,sizeof(imod),INT32); + if (n < 0) return printSocketReadError(); + } + + // execute action +#ifdef VERBOSE + printf("Getting id %d\n", arg); +#endif + +#ifdef SLS_DETECTOR_FUNCTION_LIST + switch (arg) { +#ifdef MYTHEND + case MODULE_SERIAL_NUMBER: + case MODULE_FIRMWARE_VERSION: +#ifdef VERBOSE + printf("of module %d\n", imod); +#endif + + if (imod>=0 && imod 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Digital Test) is not implemented for this detector\n"); + cprintf(RED, "%s", mess); +#else + + enum digitalTestMode arg=0; + int imod=-1; + int ival=-1; + + // receive arguments + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + if (arg == CHIP_TEST) { + n = receiveData(file_des,&imod,sizeof(imod),INT32); + if (n < 0) return printSocketReadError(); + } + + if (arg == DIGITAL_BIT_TEST) { + n = receiveData(file_des,&ival,sizeof(ival),INT32); + if (n < 0) return printSocketReadError(); + } + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } else { +#ifdef VERBOSE + printf("Digital test mode %d\n",arg ); +#endif +#ifdef SLS_DETECTOR_FUNCTION_LIST + switch (arg) { + +#ifdef GOTTHARD + case DIGITAL_BIT_TEST: + retval=0; + break; + +#elif MYTHEND + case CHIP_TEST: +#ifdef VERBOSE + printf("of module %d\n", imod); +#endif + if (imod>=0 && imod 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + + n = sendData(file_des,&ret1,sizeof(ret),INT32); + n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); + + // return ok / fail + return ret; +} + + + +int enable_analog_out(int file_des) { + int ret=FAIL,ret1=FAIL; + int n=0; + sprintf(mess,"Function (Enable Analog Out) is not implemented for this detector\n"); + cprintf(RED, "Error: %s", mess); + + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + + n = sendData(file_des,&ret1,sizeof(ret),INT32); + n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); + + // return ok / fail + return ret; +} + + + +int calibration_pulse(int file_des) { + int ret=FAIL,ret1=FAIL; + int n=0; + sprintf(mess,"Function (Calibration Pulse) is not implemented for this detector\n"); + cprintf(RED, "Error: %s", mess); + + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + + n = sendData(file_des,&ret1,sizeof(ret),INT32); + n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); + + // return ok / fail + return ret; +} + + + + +int set_dac(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int arg[3]={-1,-1,-1}; + int val=-1; + enum dacIndex ind=0; + int imod=-1; + double retval[2]={-1,-1}; + int mV=0; + sprintf(mess,"set DAC failed\n"); + + // receive arguments + n = receiveData(file_des,arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + ind=arg[0]; + imod=arg[1]; + mV=arg[2]; + + if (mV) + printf("DAC will be set in mV %d!\n",mV); + else + printf("DAC will be set in DACu! %d\n", mV); + + n = receiveData(file_des,&val,sizeof(val),INT32); + if (n < 0) return printSocketReadError(); + printf("ind = %d val = %d \n", ind,val); + // checks + +#ifdef SLS_DETECTOR_FUNCTION_LIST + if (imod>=getTotalNumberOfModules()) { + ret = FAIL; + sprintf(mess,"Module number %d out of range\n",imod); + cprintf(RED, "Warning: %s", mess); + } +#endif + + // check if dac exists for this detector + enum DACINDEX idac=0; + idac=ind; + printf("idac=%d, ind=%d \n",idac,ind); + printf("Set DAC of Mythen 3 \n"); + + switch (ind) { + + case M_vIpre: + idac = vIpre; + printf("vIpre\n"); + break; + case M_vIbias: + idac = vIbias; + printf("vIbias \n"); + break; + case PREAMP: + idac = Vrf; + printf("Vrf\n"); + break; + case SHAPER1: + idac = VrfSh; + printf("VrfSh\n"); + break; + case M_vIinSh: + idac = vIinSh; + printf("vIinSh \n"); + break; + case M_VdcSh: + idac = VdcSh; + printf("VdcSh \n"); + break; + case THRESHOLD: + idac = Vth1; + printf("Vth1\n"); + break; + case M_Vth2: + idac = Vth2; + printf("Vth2\n"); + break; + case M_Vth3: + idac = Vth3; + printf("Vth3\n"); + break; + case M_VPL: + idac = VPL; + printf("VPL\n"); + break; + case CALIBRATION_PULSE: // !!! pulse height + 1400 DACu + idac = VPH; + printf("VPH\n"); + break; + case TRIMBIT_SIZE: + idac = Vtrim; + printf("Vtrim\n"); + break; + case M_casSh: + idac = casSh; + printf("casSh\n"); + break; + case M_cas: + idac = cas; + pritnf("cas\n"); + break; + case M_vIbiasSh: + idac = vIbiasSh; + printf("vIbiasSh\n"); + break; + case M_vIcin: + idac = vIcin; + printf("vIcin\n"); + break; + case M_vIpreOut: + idac = vIpreOut; + printf("vIpreOut\n"); + break; + case V_POWER_A: + case V_POWER_B: + //case V_POWER_C: + //case V_POWER_D: + case V_POWER_IO: + case V_POWER_CHIP: + case V_LIMIT: + break; + + default: + if(ind<0){ + ret = FAIL; + sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind); + cprintf(RED, "Warning: %s", mess); + } + else{ + printf("The dac has no name yet. \n"); + } + break; + } + + + printf("idac=%d, ind=%d \n",idac,ind); + + // execute action +//#ifdef VERBOSE + printf("Setting DAC %d of module %d to %d \n", idac, imod, val); +//#endif +//#ifdef SLS_DETECTOR_FUNCTION_LIST + double temp; + if (ret==OK) { + if (differentClients && lockStatus && val!=-1) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } + else { + + if(ind == V_POWER_A || ind == V_POWER_B || ind == V_POWER_IO){ + printf("Setting a power: %d \n",ind); + if(mV){ + + if( val >=0 && val <=vPowerLimit){ + retval[1] = setPower(ind,val); // in mV + retval[0] = retval[1]*4095/2500.; + } + else if(val==-1){ + retval[1] = setPower(ind,val); + retval[0] = retval[1]*4095/2500.; + printf("READ ONLY: val=-1, read %f mV",retval[1]); + } + else{ + printf("********power %d exceeds voltage limits", ind); + } + } + else{ + printf("********power %d should be set in mV instead of DACu", ind); + } + } + else if(ind == V_LIMIT){ + if(mV){ // without safetycheck + retval[1] = setPower(ind, val); + retval[0] = 0; // to avoid wrong error messages + } + else{ + printf("********power %d should be set in mV instead of DACu", ind); + } + } + //dac: + else{ + if(val==-1){ + retval[0]=setDAC(idac,val,imod,mV); + retval[1]=retval[0]*2500./4095; + printf("READ ONLY: val=-1, read %4.0f DAC \n",retval[0]); + } + else if(mV && (val>0 && val<2500)){ // val given in mV, check that val is not out of range + int dacval = (int)val*4095./2500.; // convert to DACu + retval[1] = setDAC(idac,dacval,imod,mV); + retval[0] = retval[1]*4095./2500.; // convert to DACu (for later printout) + } + else if(!mV && (val>0 && val<4095)){ // val given in DACu + retval[0] = setDAC(idac,val,imod,mV); + retval[1] = retval[0] *2500/4095; // convert to mV + } + + //check + if(retval[0]==-1 || retval[1] == -1){// something in setDAC failed (should never occur) + ret = FAIL; + sprintf(mess,"Setting DAC %d of module %d: wrote %d but read %f\n", idac, imod, val, temp); + cprintf(RED, "Warning: %s", mess); + } + if(mV) + temp = retval[1]; + else + temp = retval[0]; + if ((abs(temp-val)<=5) || val==-1) { // ??? + ret=OK; + } + else { + ret = FAIL; + sprintf(mess,"Setting dac %d of module %d: wrote %d but read %f\n", idac, imod, val, temp); + cprintf(RED, "Warning: %s", mess); + } + } // end else dac + } // end else "detector not locked" + } // end if ret==OK +//#endif +//#ifdef VERBOSE + if(ret==OK){ + printf("DAC set to %4.0f in dac units and %f mV\n", retval[0],retval[1]); + } + else{ + printf("ERROR! Not able to set DAC to %4.0f in dac units and %f mV\n", retval[0],retval[1]); + } +//#endif + + if(ret == OK && differentClients) + ret=FORCE_UPDATE; + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret!=FAIL) { + n += sendData(file_des,&retval,sizeof(retval),INT32); + } else { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + + + +int get_adc(int file_des) { + int ret=OK; //ret1=OK; +// int n=0; +// int arg[2]={-1,-1}; +// int retval=-1; +// enum dacIndex ind=0; +// int imod=-1; +// sprintf(mess,"get ADC failed\n"); + +// // receive arguments +// n = receiveData(file_des,arg,sizeof(arg),INT32); +// if (n < 0) return printSocketReadError(); +// ind=arg[0]; +// imod=arg[1]; + +// #ifdef MYTHEND +// #ifdef SLS_DETECTOR_FUNCTION_LIST +// if (imod>=getTotalNumberOfModules() || imod<0) { +// ret = FAIL; +// sprintf(mess,"Module number %d out of range\n",imod); +// cprintf(RED, "Warning: %s", mess); +// } +// #endif +// #endif + +// enum ADCINDEX iadc=0; +// switch (ind) { +// #ifdef EIGERD +// case TEMPERATURE_FPGAEXT: +// iadc = TEMP_FPGAEXT; +// break; +// case TEMPERATURE_10GE: +// iadc = TEMP_10GE; +// break; +// case TEMPERATURE_DCDC: +// iadc = TEMP_DCDC; +// break; +// case TEMPERATURE_SODL: +// iadc = TEMP_SODL; +// break; +// case TEMPERATURE_SODR: +// iadc = TEMP_SODR; +// break; +// case TEMPERATURE_FPGA: +// iadc = TEMP_FPGA; +// break; +// case TEMPERATURE_FPGA2: +// iadc = TEMP_FPGAFEBL; +// break; +// case TEMPERATURE_FPGA3: +// iadc = TEMP_FPGAFEBR; +// break; +// #endif +// #if defined(GOTTHARD) || defined(JUNGFRAUD) +// case TEMPERATURE_FPGA: +// iadc = TEMP_FPGA; +// break; +// case TEMPERATURE_ADC: +// iadc = TEMP_ADC; +// break; +// #endif +// default: +// ret = FAIL; +// sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind); +// cprintf(RED, "Warning: %s", mess); +// break; +// } + +// #ifdef VERBOSE +// printf("Getting ADC %d of module %d\n", iadc, imod); +// #endif +// #ifdef SLS_DETECTOR_FUNCTION_LIST +// if (ret==OK) +// retval=getADC(iadc,imod); +// #endif +// #ifdef VERBOSE +// printf("ADC is %f\n", retval); +// #endif + +// if (ret==OK && differentClients) +// ret=FORCE_UPDATE; + +// // ret could be swapped during sendData +// ret1 = ret; +// // send ok / fail +// n = sendData(file_des,&ret1,sizeof(ret),INT32); +// // send return argument +// if (ret!=FAIL) { +// n += sendData(file_des,&retval,sizeof(retval),INT32); +// } else { +// n += sendData(file_des,mess,sizeof(mess),OTHER); +// } + + // return ok / fail + return ret; +} + + + + + +int write_register(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"write to register failed\n"); + + // receive arguments + int arg[2]={-1,-1}; + n = receiveData(file_des,arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + int addr=arg[0]; + int val=arg[1]; + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { +#ifdef VERBOSE + printf("writing to register 0x%x data 0x%x\n", addr, val); +#endif + retval=writeRegister(addr,val); + if (retval!=val) { + ret = FAIL; + sprintf(mess,"Writing to register 0x%x failed: wrote 0x%x but read 0x%x\n", addr, val, retval); + cprintf(RED, "Warning: %s", mess); + } + } +#endif +#ifdef VERBOSE + printf("Data set to 0x%x\n", retval); +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret!=FAIL) { + n += sendData(file_des,&retval,sizeof(retval),INT32); + } else { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; + +} + + + + + +int read_register(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"read register failed\n"); + + // receive arguments + int arg=0; + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + int addr=arg; + + // execute action +#ifdef VERBOSE + printf("reading register 0x%x\n", addr); +#endif +#ifdef SLS_DETECTOR_FUNCTION_LIST + retval=readRegister(addr); +#endif +#ifdef VERBOSE + printf("Returned value 0x%x\n", retval); +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret!=FAIL) { + n += sendData(file_des,&retval,sizeof(retval),INT32); + } else { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + +int write_memory(int file_des) { + int ret=FAIL,ret1=FAIL; + int n=0; + sprintf(mess,"Function (Write Memory) is not implemented for this detector\n"); + cprintf(RED, "Error: %s", mess); + + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + + n = sendData(file_des,&ret1,sizeof(ret),INT32); + n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); + + // return ok / fail + return ret; +} + + +int read_memory(int file_des) { + int ret=FAIL,ret1=FAIL; + int n=0; + sprintf(mess,"Function (Read Memory) is not implemented for this detector\n"); + cprintf(RED, "Error: %s", mess); + + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + + n = sendData(file_des,&ret1,sizeof(ret),INT32); + n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); + + // return ok / fail + return ret; +} + + + +int set_channel(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"set channel failed\n"); + +#ifndef MYTHEND + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Set Channel) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + sls_detector_channel myChan; + n=receiveChannel(file_des, &myChan); + if (n < 0) return printSocketReadError(); + + // execute action +#ifdef VERBOSE + printf("Setting channel\n"); + printf("channel number is %d, chip number is %d, module number is %d, register is %lld\n", myChan.chan,myChan.chip, myChan.module, myChan.reg); +#endif + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else if (myChan.chan>=getNumberOfChannelsPerChip()) { + ret = FAIL; + sprintf(mess,"channel number %d too large!\n",myChan.chan); + cprintf(RED, "Warning: %s", mess); + } + else if (myChan.chip>=getNumberOfChipsPerModule()) { + ret = FAIL; + sprintf(mess,"chip number %d too large!\n",myChan.chip); + cprintf(RED, "Warning: %s", mess); + } + else if (myChan.module>=getTotalNumberOfModules()) { + ret = FAIL; + sprintf(mess,"module number %d too large!\n",myChan.module); + cprintf(RED, "Warning: %s", mess); + } + else + retval=setChannel(myChan); +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret!=FAIL) { + n += sendData(file_des,&retval,sizeof(retval),INT32); + } else { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + +int get_channel(int file_des) { + int ret=OK,ret1=OK; + int n=0; + sls_detector_channel retval; + sprintf(mess,"get channel failed\n"); + +#ifndef MYTHEND + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Get Channel) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int arg[3]={-1,-1,-1}; + n = receiveData(file_des,arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + int ichan=arg[0]; + int ichip=arg[1]; + int imod=arg[2]; +#ifdef SLS_DETECTOR_FUNCTION_LIST + if (ichan>=getNumberOfChannelsPerChip()) { + ret=FAIL; + sprintf(mess, "channel number %d too large!\n",myChan.chan); + cprintf(RED, "Warning: %s", mess); + } else + retval.chan=ichan; + if (ichip>=getNumberOfChipsPerModule()) { + ret=FAIL; + sprintf(mess, "chip number %d too large!\n",myChan.chip); + cprintf(RED, "Warning: %s", mess); + } else + retval.chip=ichip; + + if (imod>=getTotalNumberOfModules()) { + ret=FAIL; + sprintf(mess, "module number %d too large!\n",myChan.module); + cprintf(RED, "Warning: %s", mess); + } else { + retval.module=imod; + ret=getChannel(&retval); +#ifdef VERBOSE + printf("Returning channel %d %d %d, 0x%llx\n", retval.chan, retval.chip, retval.mod, (retval.reg)); +#endif + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret!=FAIL) { + ret=sendChannel(file_des, &retval); + } else { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + +int set_all_channels(int file_des) { + int ret=FAIL,ret1=FAIL; + int n=0; + sprintf(mess,"Function (Set All Channels) is not implemented for this detector\n"); + cprintf(RED, "Error: %s", mess); + + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + + n = sendData(file_des,&ret1,sizeof(ret),INT32); + n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); + + // return ok / fail + return ret; +} + + + + + +int set_chip(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"set chip failed\n"); + +#ifndef MYTHEND + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Set Channel) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + sls_detector_chip myChip; + +#ifdef SLS_DETECTOR_FUNCTION_LIST + myChip.nchan=getNumberOfChannelsPerChip(); + int *ch(int*)malloc((myChip.nchan)*sizeof(int)); + myChip.chanregs=ch; + + // receive arguments + n=receiveChip(file_des, &myChip); +#ifdef VERBOSE + printf("Chip received\n"); +#endif + if(n < 0) return FAIL; + + // execute action + if (differentClients==1 && lockStatus==1) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } + else{ +#ifdef VERBOSE + printf("Setting chip\n"); + printf("chip number is %d, module number is %d, register is %d, nchan %d\n",myChip.chip, myChip.module, myChip.reg, myChip.nchan); +#endif + if (myChip.chip>=getNumberOfChipsPerModule()) { + ret = FAIL; + sprintf(mess,"chip number %d too large!\n",myChan.chip); + cprintf(RED, "Warning: %s", mess); + } + else if (myChip.module>=getTotalNumberOfModules()) { + ret = FAIL; + sprintf(mess,"module number %d too large!\n",myChan.module); + cprintf(RED, "Warning: %s", mess); + } + else + retval=setChip(myChip); + } + free(ch); +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret!=FAIL) { + n += sendData(file_des,&retval,sizeof(retval),INT32); + } else { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + +int get_chip(int file_des) { + int ret=OK,ret1=OK; + int n=0; + sls_detector_chip retval; + sprintf(mess,"get chip failed\n"); + +#ifndef MYTHEND + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Set Channel) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int arg[2]={-1,-1}; + n = receiveData(file_des,arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + +#ifdef SLS_DETECTOR_FUNCTION_LIST + int ichip=arg[0]; + int imod=arg[1]; + + // execute action + if (ichip>=getNumberOfChipsPerModule()) { + ret = FAIL; + sprintf(mess,"channel number %d too large!\n",myChan.chan); + cprintf(RED, "Warning: %s", mess); + } else + retval.chip=ichip; + + if (imod>=getTotalNumberOfModules()) { + ret = FAIL; + sprintf(mess,"module number %d too large!\n",imod); + cprintf(RED, "Warning: %s", mess); + } else + retval.module=imod; + + if (ret==OK) + ret=getChip(&retval); +#endif +#ifdef VERBOSE + printf("Returning chip %d %d\n", ichip, imod); +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret!=FAIL) { + ret=sendChip(file_des, &retval); + } else { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + +int set_all_chips(int file_des) { + int ret=FAIL,ret1=FAIL; + int n=0; + sprintf(mess,"Function (Set All Chips) is not implemented for this detector\n"); + cprintf(RED, "Error: %s", mess); + + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + + n = sendData(file_des,&ret1,sizeof(ret),INT32); + n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); + + // return ok / fail + return ret; +} + + + + + +int set_module(int file_des) { + return -1; +} + /*int ret=OK,ret1=OK; + int n=0; + sls_detector_module myModule; + int retval=-1; +#ifdef EIGERD + int myIODelay=-1; + int myTau=-1; + int myEV=-1; +#endif + sprintf(mess,"set module failed\n"); + +#ifdef SLS_DETECTOR_FUNCTION_LIST + int *myDac=NULL; + int *myAdc=NULL; + int *myChip = NULL; + int *myChan = NULL; + + myDac=(int*)malloc(getNumberOfDACsPerModule()*sizeof(int)); + if (getNumberOfDACsPerModule() > 0 && myDac == NULL) { + ret = FAIL; + sprintf(mess,"could not allocate dacs\n"); + cprintf(RED, "Warning: %s", mess); + } + else { + myModule.dacs=myDac; + myAdc=(int*)malloc(getNumberOfADCsPerModule()*sizeof(int)); + if (getNumberOfADCsPerModule() > 0 && myAdc == NULL) { + ret = FAIL; + sprintf(mess,"could not allocate adcs\n"); + cprintf(RED, "Warning: %s", mess); + } + else { + myModule.adcs=myAdc; + //no chips and chans allocated for jungfrau, too much memory +#ifdef JUNGFRAUD + myModule.chipregs=NULL; + myModule.chanregs=NULL; +#else + myChip=(int*)malloc(getNumberOfChipsPerModule()*sizeof(int)); + if (getNumberOfChipsPerModule() > 0 && myChip == NULL) { + ret = FAIL; + sprintf(mess,"could not allocate chips\n"); + cprintf(RED, "Warning: %s", mess); + } + else { + myModule.chipregs=myChip; + myChan=(int*)malloc(getNumberOfChannelsPerModule()*sizeof(int)); + if (getNumberOfChannelsPerModule() > 0 && myChan == NULL) { + ret = FAIL; + sprintf(mess,"could not allocate chans\n"); + cprintf(RED, "Warning: %s", mess); + } + else { + myModule.chanregs=myChan; +#endif + myModule.nchip=getNumberOfChipsPerModule(); + myModule.nchan=getNumberOfChannelsPerModule(); + myModule.ndac=getNumberOfDACsPerModule(); + myModule.nadc=getNumberOfADCsPerModule(); + + + // receive arguments +#ifdef VERBOSE + printf("Setting module\n"); +#endif + n=receiveModuleGeneral(file_des, &myModule, +#ifdef JUNGFRAUD + 0 //0 is to receive partially (without trimbits etc.) +#else + 1 +#endif + ); + if (n<0) return FAIL; +#ifdef VERBOSE + printf("module number is %d,register is %d, nchan %d, nchip %d, ndac %d, nadc %d, gain %f, offset %f\n", + myModule.module, myModule.reg, myModule.nchan, myModule.nchip, myModule.ndac, myModule.nadc, myModule.gain,myModule.offset); +#endif +#ifdef EIGERD + n = receiveData(file_des,&myIODelay,sizeof(myIODelay),INT32); + if (n<0) return FAIL; + n = receiveData(file_des,&myTau,sizeof(myTau),INT32); + if (n<0) return FAIL; + n = receiveData(file_des,&myEV,sizeof(myEV),INT32); + if (n<0) return FAIL; +#ifdef VERBOSE + printf("IO Delay:%d\n",myIODelay); + printf("Tau:%d\n",myTau); + printf("eV:%d\n",myEV); +#endif +#endif +#ifndef JUNGFRAUD + } + } +#endif + } + } + + //check settings index + if (ret==OK) { +#ifdef MYTHEND + if (myModule.module>=getNModBoard()) { + ret = FAIL; + sprintf(mess,"Module Number to Set Module (%d) is too large\n", myModule.module); + cprintf(RED, "Warning: %s", mess); + } + if (myModule.module<0) + myModule.module=ALLMOD; +#endif +#if defined(JUNGFRAUD) || defined(EIGERD) + switch(myModule.reg){ + case GET_SETTINGS: + case UNINITIALIZED: +#ifdef EIGERD + case STANDARD: + case HIGHGAIN: + case LOWGAIN: + case VERYHIGHGAIN: + case VERYLOWGAIN: +#elif JUNGFRAUD + case DYNAMICGAIN: + case DYNAMICHG0: + case FIXGAIN1: + case FIXGAIN2: + case FORCESWITCHG1: + case FORCESWITCHG2: +#endif + break; + default: + ret = FAIL; + sprintf(mess,"Setting (%d) is not implemented for this detector\n", myModule.reg); + cprintf(RED, "Warning: %s", mess); + break; + } + } +#endif + + + // execute action + if (ret==OK) { + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef EIGERD + //set dacs, trimbits and iodelay + ret=setModule(myModule, myIODelay); + //set threshhold + if (myEV >= 0) + setThresholdEnergy(myEV,-1); + else { + //changes settings to undefined (loading a random trim file) + setSettings(UNDEFINED,-1); + cprintf(RED,"Settings has been changed to undefined (random trim file)\n"); + } + //rate correction + //switch off rate correction: no value read from load calib/load settings) + if(myTau == -1){ + if(getRateCorrectionEnable()){ + setRateCorrection(0); + ret = FAIL; + strcat(mess,"Cannot set Rate correction. No default tau provided. Deactivating Rate Correction\n"); + cprintf(RED, "Warning: %s", mess); + } + } + //normal tau value (only if enabled) + else{ + setDefaultSettingsTau_in_nsec(myTau); + if (getRateCorrectionEnable()){ + int64_t retvalTau = setRateCorrection(myTau); + if(myTau != retvalTau){ + cprintf(RED,"%s",mess); + ret=FAIL; + } + } + } + retval = getSettings(); +#else + retval=setModule(myModule); + if (retval != myModule.reg) + ret = FAIL; +#endif + if(myChip != NULL) free(myChip); + if(myChan != NULL) free(myChan); + if(myDac != NULL) free(myDac); + if(myAdc != NULL) free(myAdc); + } + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret!=FAIL) { + n += sendData(file_des,&retval,sizeof(retval),INT32); + } else { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +}*/ + + + + + + + + + +int get_module(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int arg=-1; + int imod=-1; + sls_detector_module myModule; + sprintf(mess,"get module failed\n"); + + // receive arguments + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + imod=arg; + + // execute action +#ifdef SLS_DETECTOR_FUNCTION_LIST + int *myDac=NULL; + int *myAdc=NULL; + int *myChip = NULL; + int *myChan = NULL; + + if (imod<0 || imod>getTotalNumberOfModules()) { + ret = FAIL; + sprintf(mess,"Module Index (%d) is out of range\n", imod); + cprintf(RED, "Warning: %s", mess); + } + else { + myDac=(int*)malloc(getNumberOfDACsPerModule()*sizeof(int)); + if (getNumberOfDACsPerModule() > 0 && myDac == NULL) { + ret = FAIL; + sprintf(mess,"could not allocate dacs\n"); + cprintf(RED, "Warning: %s", mess); + } + else { + myModule.dacs=myDac; + myAdc=(int*)malloc(getNumberOfADCsPerModule()*sizeof(int)); + if (getNumberOfADCsPerModule() > 0 && myAdc == NULL) { + ret = FAIL; + sprintf(mess,"could not allocate adcs\n"); + cprintf(RED, "Warning: %s", mess); + } + else { + myModule.adcs=myAdc; + //no chips and chans allocated for jungfrau, too much memory +#ifdef JUNGFRAUD + myModule.chipregs=NULL; + myModule.chanregs=NULL; +#else + myChip=(int*)malloc(getNumberOfChipsPerModule()*sizeof(int)); + if (getNumberOfChipsPerModule() > 0 && myChip == NULL) { + ret = FAIL; + sprintf(mess,"could not allocate chips\n"); + cprintf(RED, "Warning: %s", mess); + } + else { + myModule.chipregs=myChip; + myChan=(int*)malloc(getNumberOfChannelsPerModule()*sizeof(int)); + if (getNumberOfChannelsPerModule() > 0 && myChan == NULL) { + ret = FAIL; + sprintf(mess,"could not allocate chans\n"); + cprintf(RED, "Warning: %s", mess); + } + else { + myModule.chanregs=myChan; +#endif + myModule.nchip=getNumberOfChipsPerModule(); + myModule.nchan=getNumberOfChannelsPerModule(); + myModule.ndac=getNumberOfDACsPerModule(); + myModule.nadc=getNumberOfADCsPerModule(); + myModule.module=imod; + getModule(&myModule); +#ifdef VERBOSE + printf("Returning module %d of register %x\n", imod, myModule.reg); +#endif +#ifndef JUNGFRAUD + } + } +#endif + } + } + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret!=FAIL) { + ret=sendModuleGeneral(file_des, &myModule, +#ifdef JUNGFRAUD + 0 //0 is to receive partially (without trimbits etc.) +#else + 1 +#endif + ); + } else { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + +#ifdef SLS_DETECTOR_FUNCTION_LIST + if(myChip != NULL) free(myChip); + if(myChan != NULL) free(myChan); + if(myDac != NULL) free(myDac); + if(myAdc != NULL) free(myAdc); +#endif + + // return ok / fail + return ret; + +} + + + +int set_all_modules(int file_des) { + int ret=FAIL,ret1=FAIL; + int n=0; + sprintf(mess,"Function (Set All Modules) is not implemented for this detector\n"); + cprintf(RED, "Error: %s", mess); + + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + + n = sendData(file_des,&ret1,sizeof(ret),INT32); + n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); + + // return ok / fail + return ret; +} + + + + +int set_settings(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int arg[2]={-1,-1}; + int retval=-1; + int imod=-1; + enum detectorSettings isett=-1; + sprintf(mess,"set settings failed\n"); + + // receive arguments + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + imod=arg[1]; + isett=arg[0]; + + // execute action + if (differentClients && lockStatus && isett!=GET_SETTINGS) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else if (imod>=getTotalNumberOfModules()) { + ret = FAIL; + sprintf(mess,"Module number %d out of range\n",imod); + cprintf(RED, "Warning: %s", mess); + } + else { +#ifdef VERBOSE + printf("Changing settings of module %d to %d\n", imod, isett); +#endif + retval=setSettings(isett, imod); +#ifdef VERBOSE + printf("Settings changed to %d\n", isett); +#endif + if (retval==isett || isett<0) { + ret=OK; + } else { + ret = FAIL; + sprintf(mess,"Changing settings of module %d: wrote %d but read %d\n", imod, isett, retval); + cprintf(RED, "Warning: %s", mess); + } + } +#endif + + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + + +int get_threshold_energy(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"get threshold energy failed\n"); + +#if !defined(MYTHEND) && !defined(EIGERD) + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Get Threshold Energy) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int imod=-1; + n = receiveData(file_des,&imod,sizeof(imod),INT32); + if (n < 0) return printSocketReadError(); + + // execute action +#ifdef VERBOSE + printf("Getting threshold energy of module %d\n", imod); +#endif +#ifdef SLS_DETECTOR_FUNCTION_LIST + if (imod>=getTotalNumberOfModules()) { + ret=FAIL; + sprintf(mess,"Module number %d out of range\n",imod); + } + else { + retval=getThresholdEnergy(imod); +#ifdef VERBOSE + printf("Threshold is %d eV\n", retval); +#endif + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + +int set_threshold_energy(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"set thhreshold energy failed\n"); + +#ifndef MYTHEND + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; +#ifdef EIGERD + sprintf(mess,"Function (Set Threshold Energy) is only implemented via Set Settings for this detector\n"); +#else + sprintf(mess,"Function (Set Threshold Energy) is not implemented for this detector\n"); +#endif + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int arg[3]={-1,-1,-1}; + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + int ethr=arg[0]; + int imod=arg[1]; + enum detectorSettings isett=arg[2]; + if (differentClients && lockStatus) { + ret=FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else if (imod>=getTotalNumberOfModules()) { + ret=FAIL; + sprintf(mess,"Module number %d out of range\n",imod); + } + else { + printf("Setting threshold energy of module %d to %d eV with settings %d\n", imod, ethr, isett); + retval=setThresholdEnergy(ethr, imod); +#ifdef VERBOSE + printf("Threshold set to %d eV\n", retval); +#endif + if (retval!=ethr) { + ret=FAIL; + sprintf(mess,"Setting threshold of module %d: wrote %d but read %d\n", imod, ethr, retval); + cprintf(RED, "Warning: %s", mess); + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + + +int start_acquisition(int file_des) { + int ret=OK,ret1=OK; + int n=0; + sprintf(mess,"start acquisition failed\n"); + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { + printf("Starting acquisition\n"); + ret=startStateMachine(); + if (ret==FAIL) + cprintf(RED, "Warning: %s", mess); + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + +int stop_acquisition(int file_des) { + int ret=OK,ret1=OK; + int n=0; + sprintf(mess,"stop acquisition failed\n"); + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { + printf("Stopping acquisition\n"); + ret=stopStateMachine(); + if (ret==FAIL) + cprintf(RED, "Warning: %s", mess); + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + + +int start_readout(int file_des) { + int ret=OK,ret1=OK; + int n=0; + sprintf(mess,"start readout failed\n"); + +#ifdef JUNGFRAUD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Start Readout) is not implemented for this detector\n"); + cprintf(RED, "%s", mess); +#else + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { + printf("Starting readout\n"); + ret=startReadOut(); + if (ret==FAIL) + cprintf(RED, "Warning: %s", mess); + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + + + +int get_run_status(int file_des) { + int ret=OK,ret1=OK; + enum runStatus s=ERROR; + + // execute action +#ifdef VERBOSE + printf("Getting status\n"); +#endif +#ifdef SLS_DETECTOR_FUNCTION_LIST + s= getRunStatus(); +#endif + if (differentClients) + ret=FORCE_UPDATE; + + // send ok / fail + sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + sendData(file_des,&s,sizeof(s),INT32); + + // return ok / fail + return ret; +} + + + + + +int start_and_read_all(int file_des) { + int dataret1=FAIL, dataret=FAIL; +#ifdef VERBOSE + printf("Starting and reading all frames\n"); +#endif + + // execute action + if (differentClients && lockStatus) { + dataret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + // ret could be swapped during sendData + dataret1 = dataret; + // send fail + sendData(file_des,&dataret1,sizeof(dataret),INT32); + // send return argument + sendData(file_des,mess,sizeof(mess),OTHER); + // return fail + return dataret; + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + startStateMachine(); + read_all(file_des); +#endif + return OK; +} + + + + +int read_frame(int file_des) { + int dataret1=FAIL, dataret=FAIL; + int n=0; + sprintf(mess, "read frame failed\n"); + + // execute action + if (differentClients && lockStatus) { + dataret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + // ret could be swapped during sendData + dataret1 = dataret; + // send fail + sendData(file_des,&dataret1,sizeof(dataret),INT32); + // send return argument + sendData(file_des,mess,sizeof(mess),OTHER); + // return fail + return dataret; + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + readFrame(&dataret, mess); +#endif + if(dataret == FAIL) + cprintf(RED,"%s\n",mess); + else + cprintf(GREEN,"%s",mess); + + if (differentClients) + dataret=FORCE_UPDATE; + + //dataret could be swapped during sendData + dataret1 = dataret; + // send finished / fail + n=sendData(file_des,&dataret1,sizeof(dataret1),INT32); + if (n<0) return FAIL; // if called from read_all, should fail to stop talking to a closed client socket + // send return argument + n=sendData(file_des,mess,sizeof(mess),OTHER); + if (n<0) return FAIL; // if called from read_all, should fail to stop talking to a closed client socket + // return finished / fail + return dataret; +} + + + + +int read_all(int file_des) { +#ifdef SLS_DETECTOR_FUNCTION_LIST + while(read_frame(file_des)==OK) { +#ifdef VERBOSE + printf("frame read\n"); +#endif + ; + } +#endif +#ifdef VERBOSE + printf("Frames finished or failed\n"); +#endif + return OK; +} + + + + +int set_timer(int file_des) { + int ret=OK,ret1=OK; + int n=0; + enum timerIndex ind=0; + int64_t tns=-1; + int64_t retval=-1; + sprintf(mess,"set timer failed\n"); + + // receive arguments + n = receiveData(file_des,&ind,sizeof(ind),INT32); + if (n < 0) return printSocketReadError(); + + n = receiveData(file_des,&tns,sizeof(tns),INT64); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus && tns!=-1) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { +#ifdef VERBOSE + printf("setting timer %d to %lld ns\n",ind,tns); +#endif + switch(ind) { +#ifdef EIGERD + case SUBFRAME_ACQUISITION_TIME: + if (tns > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ){ + ret=FAIL; + strcpy(mess,"Sub Frame exposure time should not exceed 5.368 seconds\n"); + break; + } +#endif +#ifdef MYTHEN + case PROBES_NUMBER: + case GATES_NUMBER: + case DELAY_AFTER_TRIGGER: +#elif JUNGFRAUD + case DELAY_AFTER_TRIGGER: +#endif + case FRAME_NUMBER: + case ACQUISITION_TIME: // for all detectors + case FRAME_PERIOD: + case CYCLES_NUMBER: + retval = setTimer(ind,tns); + break; + default: + ret = FAIL; + sprintf(mess,"Timer Index (%d) is not implemented for this detector\n", (int) ind); + cprintf(RED, "%s", mess); + break; + } +#if defined(MYTHEND) || defined(GOTTHARD) + if (ret == OK && ind==FRAME_NUMBER) { + ret=allocateRAM(); + if (ret!=OK) { + ret = FAIL; + sprintf(mess,"Could not allocate RAM for %lld frames\n", tns); + cprintf(RED, "%s", mess); + } + } +#endif + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT64); + + // return ok / fail + return ret; +} + + + + + + + + + +int get_time_left(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int64_t retval=-1; + sprintf(mess,"get timer left failed\n"); + + + +#ifdef EIGERD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Get Timer Left) is not implemented for this detector\n"); + cprintf(RED, "%s", mess); +#else + + // receive arguments + enum timerIndex ind=0; + n = receiveData(file_des,&ind,sizeof(ind),INT32); + if (n < 0) return printSocketReadError(); + +#ifdef VERBOSE + printf("getting time left on timer %d \n",ind); +#endif +#ifdef SLS_DETECTOR_FUNCTION_LIST + switch(ind) { +#ifdef MYTHEND + case PROBES_NUMBER: +#endif + case FRAME_NUMBER: + case ACQUISITION_TIME: + case FRAME_PERIOD: + case DELAY_AFTER_TRIGGER: +#ifndef JUNGFRAUD + case GATES_NUMBER: +#endif + case CYCLES_NUMBER: + case PROGRESS: + case ACTUAL_TIME: + case MEASUREMENT_TIME: +#ifdef JUNGFRAUD + case FRAMES_FROM_START: + case FRAMES_FROM_START_PG: +#endif + retval=getTimeLeft(ind); + break; + default: + ret = FAIL; + sprintf(mess,"Timer Left Index (%d) is not implemented for this detector\n", (int)ind); + cprintf(RED, "%s", mess); + break; + } +#ifdef VERBOSE + printf("Time left on timer %d is %lld\n",ind, retval); +#endif +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT64); + + // return ok / fail + return ret; +} + + + + + + +int set_dynamic_range(int file_des) { + int ret=OK,ret1=OK; + int rateret=OK,rateret1=OK; + int n=0; + int dr=-1; + int retval=-1; + sprintf(mess,"set dynamic range failed\n"); + + // receive arguments + n = receiveData(file_des,&dr,sizeof(dr),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus && dr>=0) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { + switch(dr){ + case -1: + case 16: +#ifdef EIGERD + case 4: case 8: case 32: +#endif + break; + default: + ret = FAIL; + sprintf(mess,"Dynamic Range (%d) is not implemented for this detector\n", dr); + cprintf(RED, "Warning: %s", mess); + } + } + if(ret == OK){ +#ifdef EIGERD + int old_dr = setDynamicRange(-1); + retval=setDynamicRange(dr); + if (dr>=0 && retval!=dr) + ret=FAIL; + //look at rate correction only if dr change worked + if((ret==OK) && (dr!=32) && (dr!=16) && (dr!=-1) && (getRateCorrectionEnable())){ + setRateCorrection(0); + rateret = FAIL; + strcpy(mess,"Switching off Rate Correction. Must be in 32 or 16 bit mode\n"); + cprintf(RED,"%s",mess); + }else{ + //setting it if dr changed from 16 to 32 or vice versa with tau value as in rate table + if((dr!=-1) && (old_dr != dr) && getRateCorrectionEnable() && (dr == 16 || dr == 32)){ + setRateCorrection(-1); //tau_ns will not be -1 here + if(!getRateCorrectionEnable()){ + ret = FAIL; + strcpy(mess,"Deactivating Rate Correction. Could not set it.\n"); + cprintf(RED,"%s",mess); + } + } + } + +#else + retval = setDynamicRange(dr); +#endif + if (dr>=0) dataBytes=calculateDataBytes(); + } +#endif + if ((ret == OK) && dr>=0 && retval!=dr) { + ret = FAIL; + cprintf(RED,"%s",mess); + } + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + + //rate correction ret + // ret could be swapped during sendData + rateret1 = rateret; + // send ok / fail + n = sendData(file_des,&rateret1,sizeof(rateret1),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + + + +int set_readout_flags(int file_des) { + int ret=OK,ret1=OK; + int n=0; + enum readOutFlags retval=-1; + sprintf(mess,"set readout flags failed\n"); + +#if !defined(MYTHEND) && !defined(EIGERD) + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret=FAIL; + sprintf(mess,"Function (Set Read Out Flags) is not implemented for this detector\n"); + cprintf(RED, "%s",mess); +#else + + // receive arguments + enum readOutFlags arg=-1; + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus && arg!=GET_READOUT_FLAGS) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { +#ifdef VERBOSE + printf("setting readout flags to %d\n",arg); +#endif + switch(arg) { + case GET_READOUT_FLAGS: +#ifdef MYTHEND + case TOT_MODE: + case NORMAL_READOUT: + case STORE_IN_RAM: + case CONTINOUS_RO: +#elif EIGERD + case STORE_IN_RAM: + case CONTINOUS_RO: + case PARALLEL: + case NONPARALLEL: + case SAFE: +#endif + retval=setReadOutFlags(arg); + break; + default: + ret = FAIL; + sprintf(mess,"Readout Flag Index (%d) is not implemented for this detector\n", (int)arg); + cprintf(RED, "Warning: %s", mess); + break; + } +#endif + if (ret==OK && ((retval == -1) || ((arg!=-1) && ((retval&arg)!=arg)))){ + ret = FAIL; + sprintf(mess,"Could not change readout flag: should be 0x%x but is 0x%x\n", arg, retval); + cprintf(RED, "Warning: %s", mess); + } + + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + } +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + + + +int set_roi(int file_des) { + int ret=OK,ret1=OK; + int n=0; + strcpy(mess,"set nroi failed\n"); + +#ifndef GOTTHARDD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret=FAIL; + sprintf(mess,"Function (Set ROI) is not implemented for this detector\n"); + cprintf(RED, "%s",mess); +#else + + ROI* retval=0; + int retvalsize=0,retvalsize1=0; + + // receive arguments + int nroi=-1; + ROI arg[MAX_ROIS]; + n = receiveData(file_des,&nroi,sizeof(nroi),INT32); + if (n < 0) return printSocketReadError(); + + { + int i; + if(nroi!=-1){ + for(i=0;i=0) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { +#ifdef VERBOSE + printf("setting speed variable %d to %d\n",arg,val); +#endif + switch (arg) { +#ifdef JUNGFRAUD + case ADC_PHASE: + adcPhase(val); + break; +#endif +#ifdef MYTHEND + case CLOCK_DIVIDER: + case WAIT_STATES: + case SET_SIGNAL_LENGTH: + case TOT_CLOCK_DIVIDER: + case TOT_DUTY_CYCLE: +#elif EIGERD + case CLOCK_DIVIDER: +#elif JUNGFRAUD + case CLOCK_DIVIDER: +#endif + retval=setSpeed(arg, val); + if ((retval!=val) && (val>=0)) { + ret=FAIL; + sprintf(mess,"could not change speed variable %d: should be %d but is %d \n",arg, val, retval); + cprintf(RED, "Warning: %s", mess); + } + break; + default: + ret = FAIL; + sprintf(mess,"Speed Index (%d) is not implemented for this detector\n",(int) arg); + cprintf(RED, "Warning: %s", mess); + break; + } + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + + +int execute_trimming(int file_des) { + int ret=OK,ret1=OK; + int n=0; + sprintf(mess,"execute trimming failed\n"); + +#ifndef MYTHEND + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Execute Trimming) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + int retval=-1; + + // receive arguments + enum trimMode mode=0; + int arg[3]={-1,-1,-1}; + n = receiveData(file_des,&mode,sizeof(mode),INT32); + if (n < 0) return printSocketReadError(); + + n = receiveData(file_des,arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + int imod, par1,par2; + imod=arg[0]; + par1=arg[1]; + par2=arg[2]; + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else if (imod>=getTotalNumberOfModules()) { + ret = FAIL; + sprintf(mess,"Module Number (%d) is out of range\n"); + cprintf(RED, "Warning: %s", mess); + } + else { +#ifdef VERBOSE + printf("trimming module %d mode %d, parameters %d %d \n",imod,mode, par1, par2); +#endif + switch(mode) { + case NOISE_TRIMMING: + case BEAM_TRIMMING: + case IMPROVE_TRIMMING: + case FIXEDSETTINGS_TRIMMING: + retval=executeTrimming(mode, par1, par2, imod); + if ((ret!=OK) && (retval>0)) { + ret=FAIL; + sprintf(mess,"Could not trim %d channels\n", retval); + cprintf(RED, "Warning: %s", mess); + } + break; + default: + ret = FAIL; + sprintf(mess,"Trimming Mode (%d) is not implemented for this detector\n", (int) mode); + cprintf(RED, "Warning: %s", mess); + break; + } + + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + + +int exit_server(int file_des) { + int ret=FAIL; + sprintf(mess,"Closing Server\n"); + cprintf(BG_RED,"Error: %s",mess); + // send ok / fail + sendData(file_des,&ret,sizeof(ret),INT32); + // send return argument + sendData(file_des,mess,sizeof(mess),OTHER); + return GOODBYE; +} + + + + +int lock_server(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int lock=0; + sprintf(mess,"lock server failed\n"); + + // receive arguments + n = receiveData(file_des,&lock,sizeof(lock),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (lock>=0) { + if (lockStatus==0 || strcmp(lastClientIP,thisClientIP)==0 || strcmp(lastClientIP,"none")==0) { + lockStatus=lock; + strcpy(lastClientIP,thisClientIP); + } else { + ret = FAIL; + sprintf(mess,"Server already locked by %s\n", lastClientIP); + cprintf(RED, "Warning: %s", mess); + } + } + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&lockStatus,sizeof(lockStatus),INT32); + + // return ok / fail + return ret; +} + + + + + +int get_last_client_ip(int file_des) { + int ret=OK,ret1=OK; + if (differentClients) + ret=FORCE_UPDATE; + // send ok / fail + sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + sendData(file_des,lastClientIP,sizeof(lastClientIP),OTHER); + // return ok / fail + return ret; +} + + + + +int set_port(int file_des) { + int ret=OK,ret1=OK; + int n=0; + enum portType p_type=0; + int p_number=-1; + sprintf(mess,"set port failed\n"); + + // receive arguments + n = receiveData(file_des,&p_type,sizeof(p_type),INT32); + if (n < 0) return printSocketReadError(); + + n = receiveData(file_des,&p_number,sizeof(p_number),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + int sd=-1; + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } + else { + if (p_number<1024) { + ret = FAIL; + sprintf(mess,"Port Number (%d) too low\n", p_number); + cprintf(RED, "Warning: %s", mess); + } + printf("set port %d to %d\n",p_type, p_number); + sd=bindSocket(p_number); + if (sd<0) { + ret = FAIL; + sprintf(mess,"Could not bind port %d\n", p_number); + cprintf(RED, "Warning: %s", mess); + if (sd==-10) { + ret = FAIL; + sprintf(mess,"Port %d already set\n", p_number); + cprintf(RED, "Warning: %s", mess); + } + } + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + } + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n = sendData(file_des,mess,sizeof(mess),OTHER); + } else { + n = sendData(file_des,&p_number,sizeof(p_number),INT32); + closeConnection(file_des); + exitServer(sockfd); + sockfd=sd; + } + + // return ok / fail + return ret; +} + + + + +int update_client(int file_des) { + int ret=OK; + sendData(file_des,&ret,sizeof(ret),INT32); + return send_update(file_des); +} + + + + +int send_update(int file_des) { + int n=0; // if (n<0) should fail to stop talking to a closed client socket + int nm=0; + int64_t retval = 0; + enum detectorSettings t; + + n = sendData(file_des,lastClientIP,sizeof(lastClientIP),OTHER); + if (n < 0) return printSocketReadError(); + + +#ifdef SLS_DETECTOR_FUNCTION_LIST + nm=setNMod(GET_FLAG,X); +#endif + n = sendData(file_des,&nm,sizeof(nm),INT32); + if (n < 0) return printSocketReadError(); + + +#ifdef SLS_DETECTOR_FUNCTION_LIST + nm=setNMod(GET_FLAG,Y); +#endif + n = sendData(file_des,&nm,sizeof(nm),INT32); + if (n < 0) return printSocketReadError(); + + +#ifdef SLS_DETECTOR_FUNCTION_LIST + nm=setDynamicRange(GET_FLAG); +#endif + n = sendData(file_des,&nm,sizeof(nm),INT32); + if (n < 0) return printSocketReadError(); + + +#ifdef SLS_DETECTOR_FUNCTION_LIST + dataBytes=calculateDataBytes(); +#endif + n = sendData(file_des,&dataBytes,sizeof(dataBytes),INT32); + if (n < 0) return printSocketReadError(); + + +#ifdef SLS_DETECTOR_FUNCTION_LIST + t=setSettings(GET_SETTINGS, GET_FLAG); +#endif + n = sendData(file_des,&t,sizeof(t),INT32); + if (n < 0) return printSocketReadError(); + + +#if defined(MYTHEND) || defined(EIGERD) +#ifdef SLS_DETECTOR_FUNCTION_LIST + nm=getThresholdEnergy(GET_FLAG); +#endif + n = sendData(file_des,&nm,sizeof(nm),INT32); + if (n < 0) return printSocketReadError(); +#endif + + +#ifdef SLS_DETECTOR_FUNCTION_LIST + retval=setTimer(FRAME_NUMBER,GET_FLAG); +#endif + n = sendData(file_des,&retval,sizeof(int64_t),INT64); + if (n < 0) return printSocketReadError(); + + +#ifdef SLS_DETECTOR_FUNCTION_LIST + retval=setTimer(ACQUISITION_TIME,GET_FLAG); +#endif + n = sendData(file_des,&retval,sizeof(int64_t),INT64); + if (n < 0) return printSocketReadError(); + + +#ifdef EIGERD +#ifdef SLS_DETECTOR_FUNCTION_LIST + retval=setTimer(SUBFRAME_ACQUISITION_TIME,GET_FLAG); +#endif + n = sendData(file_des,&retval,sizeof(int64_t),INT64); + if (n < 0) return printSocketReadError(); +#endif + + +#ifdef SLS_DETECTOR_FUNCTION_LIST + retval=setTimer(FRAME_PERIOD,GET_FLAG); +#endif + n = sendData(file_des,&retval,sizeof(int64_t),INT64); + if (n < 0) return printSocketReadError(); + + +#ifndef EIGERD +#ifdef SLS_DETECTOR_FUNCTION_LIST + retval=setTimer(DELAY_AFTER_TRIGGER,GET_FLAG); +#endif + n = sendData(file_des,&retval,sizeof(int64_t),INT64); + if (n < 0) return printSocketReadError(); +#endif + + +#if !defined(EIGERD) && !defined(JUNGFRAUD) +#ifdef SLS_DETECTOR_FUNCTION_LIST + retval=setTimer(GATES_NUMBER,GET_FLAG); +#endif + n = sendData(file_des,&retval,sizeof(int64_t),INT64); + if (n < 0) return printSocketReadError(); +#endif + + +#ifdef MYTHEND +#ifdef SLS_DETECTOR_FUNCTION_LIST + retval=setTimer(PROBES_NUMBER,GET_FLAG); +#endif + n = sendData(file_des,&retval,sizeof(int64_t),INT64); + if (n < 0) return printSocketReadError(); +#endif + + +#ifdef SLS_DETECTOR_FUNCTION_LIST + retval=setTimer(CYCLES_NUMBER,GET_FLAG); +#endif + n = sendData(file_des,&retval,sizeof(int64_t),INT64); + if (n < 0) return printSocketReadError(); + + + if (lockStatus==0) { + strcpy(lastClientIP,thisClientIP); + } + + return OK; +} + + + + + + +int configure_mac(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=-100; + sprintf(mess,"configure mac failed\n"); + +#ifdef MYTHEND + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + strcpy(mess,"Function (Configure MAC) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + char arg[6][50]; + memset(arg,0,sizeof(arg)); + n = receiveData(file_des,arg,sizeof(arg),OTHER); +#if defined(JUNGFRAUD) || defined(EIGERD) + int pos[3]={0,0,0}; + n = receiveData(file_des,pos,sizeof(pos),INT32); +#endif + if (n < 0) return printSocketReadError(); + + uint32_t ipad; + uint64_t imacadd; + uint64_t idetectormacadd; + uint32_t udpport; + uint32_t udpport2; + uint32_t detipad; + sscanf(arg[0], "%x", &ipad); +#ifdef VIRTUAL + sscanf(arg[1], "%lx", &imacadd); +#else + sscanf(arg[1], "%llx", &imacadd); +#endif + sscanf(arg[2], "%x", &udpport); +#ifdef VIRTUAL + sscanf(arg[3], "%lx", &idetectormacadd); +#else + sscanf(arg[3], "%llx", &idetectormacadd); +#endif + sscanf(arg[4], "%x", &detipad); + sscanf(arg[5], "%x", &udpport2); + + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { +#ifdef VERBOSE + int i; + //#ifdef GOTTHARD + //printf("\ndigital_test_bit in server %d\t",digitalTestBit); + //#endif + printf("\nipadd %x\t",ipad); + printf("destination ip is %d.%d.%d.%d = 0x%x \n",(ipad>>24)&0xff,(ipad>>16)&0xff,(ipad>>8)&0xff,(ipad)&0xff,ipad); + printf("macad:%llx\n",imacadd); + for (i=0;i<6;i++) + printf("mac adress %d is 0x%x \n",6-i,(unsigned int)(((imacadd>>(8*i))&0xFF))); + printf("udp port:0x%x\n",udpport); + printf("detector macad:%llx\n",idetectormacadd); + for (i=0;i<6;i++) + printf("detector mac adress %d is 0x%x \n",6-i,(unsigned int)(((idetectormacadd>>(8*i))&0xFF))); + printf("detipad %x\n",detipad); + printf("udp port2:0x%x\n",udpport2); + printf("\n"); + //printf("Configuring MAC of module %d at port %x\n", imod, udpport); + +#if defined(JUNGFRAUD) || defined(EIGERD) + printf("Position: [%d,%d,%d]\n", pos[0],pos[1],pos[2]); +#endif +#endif + if(getRunStatus() == RUNNING){ + ret = stopStateMachine(); + } + if(ret==FAIL) { + sprintf(mess,"Could not stop detector acquisition to configure mac\n"); + cprintf(RED, "Warning: %s", mess); + } + else { + retval=configureMAC(ipad,imacadd,idetectormacadd,detipad,udpport,udpport2,0); //digitalTestBit); + if(retval==-1) { + ret = FAIL; + sprintf(mess,"Configure Mac failed\n"); + cprintf(RED, "Warning: %s", mess); + } + else { + printf("Configure MAC successful\n"); +#if defined(JUNGFRAUD) || defined(EIGERD) + ret = setDetectorPosition(pos); + if (ret == FAIL) { + sprintf(mess,"could not set detector position\n"); + cprintf(RED, "Warning: %s", mess); + } +#endif + } +#ifdef VERBOSE + printf("Configured MAC with retval %d\n", retval); +#endif + } + + } +#endif + if (differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + + +int load_image(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"Loading image failed\n"); + +#ifndef GOTTHARDD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Load Image) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + enum imageType index=0; + char ImageVals[dataBytes]; + memset(ImageVals,0,dataBytes); + n = receiveData(file_des,&index,sizeof(index),INT32); + if (n < 0) return printSocketReadError(); + + n = receiveData(file_des,ImageVals,dataBytes,OTHER); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { + switch (index) { + case DARK_IMAGE : +#ifdef VERBOSE + printf("Loading Dark image\n"); +#endif + case GAIN_IMAGE : +#ifdef VERBOSE + printf("Loading Gain image\n"); +#endif + retval=loadImage(index,ImageVals); + if (retval==-1) { + ret = FAIL; + cprintf(RED, "Warning: %s", mess); + } + break; + default: + ret = FAIL; + sprintf(mess,"Load Image Index (%d) is not implemented for this detector\n", (int)index); + cprintf(RED, "Warning: %s", mess); + break; + } + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + + +int set_master(int file_des) { + int ret=OK,ret1=OK; + int n=0; + enum masterFlags arg=GET_MASTER; + enum masterFlags retval=GET_MASTER; + sprintf(mess,"set master failed\n"); + + // receive arguments + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus && ((int)arg!=(int)GET_MASTER)) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { +#ifdef VERBOSE + printf("setting master flags to %d\n",arg); +#endif + retval=setMaster(arg); + if (retval==GET_MASTER) + ret=FAIL; + + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + } +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + + + + +int set_synchronization(int file_des) { + int ret=OK,ret1=OK; + int n=0; + enum synchronizationMode arg=GET_SYNCHRONIZATION_MODE; + enum synchronizationMode retval=GET_SYNCHRONIZATION_MODE; + sprintf(mess,"synchronization mode failed\n"); + + // receive arguments + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus && ((int)arg!=(int)GET_SYNCHRONIZATION_MODE)) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { +#ifdef VERBOSE + printf("setting master flags to %d\n",arg); +#endif + retval=setSynchronization(arg); + if (retval==GET_SYNCHRONIZATION_MODE) + ret=FAIL; + + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + } +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + + +int read_counter_block(int file_des) { + int ret=OK,ret1=OK; + int n=0; + char CounterVals[dataBytes]; + memset(CounterVals,0,dataBytes); + sprintf(mess,"Read counter block failed\n"); + +#ifndef GOTTHARDD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Read Counter Block) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int startACQ=-1; + n = receiveData(file_des,&startACQ,sizeof(startACQ),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { + ret=readCounterBlock(startACQ,CounterVals); + if (ret == FAIL) + cprintf(RED, "Warning: %s", mess); +#ifdef VERBOSE + int i; + for(i=0;i<6;i++) + printf("%d:%d\t",i,CounterVals[i]); +#endif + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,CounterVals,dataBytes,OTHER); + + // return ok / fail + return ret; +} + + + + + +int reset_counter_block(int file_des) { + int ret=OK,ret1=OK; + int n=0; + sprintf(mess,"Reset counter block failed\n"); + +#ifndef GOTTHARDD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Reset Counter Block) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int startACQ=-1; + n = receiveData(file_des,&startACQ,sizeof(startACQ),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { + ret=resetCounterBlock(startACQ); + if (ret == FAIL) + cprintf(RED, "Warning: %s", mess); + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + + +int calibrate_pedestal(int file_des){ + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"calibrate pedestal failed\n"); + + +#ifndef GOTTHARDD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Calibrate Pedestal) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int frames=-1; + n = receiveData(file_des,&frames,sizeof(frames),INT32); + if (n < 0) return printSocketReadError(); + + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { + ret=calibratePedestal(frames); + if (ret == FAIL) + cprintf(RED, "Warning: %s", mess); + } +#endif + if(ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + + + + + +int enable_ten_giga(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"Enabling/disabling 10GbE failed\n"); + + // execute action +#ifndef EIGERD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Enable 10 GbE) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int arg=-1; + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus && arg!=-1) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { +#ifdef VERBOSE + printf("Enabling/Disabling 10Gbe :%d \n",arg); +#endif + retval=enableTenGigabitEthernet(arg); + if((arg != -1) && (retval != arg)) { + ret=FAIL; + cprintf(RED, "Warning: %s", mess); + } + else if (differentClients) + ret=FORCE_UPDATE; + } +#endif +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + +int set_all_trimbits(int file_des){ + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"setting all trimbits failed\n"); + +#ifndef EIGERD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Set All Trimbits) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int arg=-1; + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + + // execute action + if (differentClients && lockStatus && arg!=-1) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { +#ifdef VERBOSE + printf("setting all trimbits to %d\n",arg); +#endif + if(arg < -1){ + ret = FAIL; + strcpy(mess,"Cant set trimbits to this value\n"); + cprintf(RED, "Warning: %s", mess); + }else { + if(arg >= 0){ + ret = setAllTrimbits(arg); + //changes settings to undefined + setSettings(UNDEFINED,-1); + cprintf(RED,"Settings has been changed to undefined (change all trimbits)\n"); + } + retval = getAllTrimbits(); + if (arg!=-1 && arg!=retval) { + ret=FAIL; + sprintf(mess,"Could not set all trimbits: should be %d but is %d\n", arg, retval); + cprintf(RED, "Warning: %s", mess); + } + } + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + +int set_ctb_pattern(int file_des) { + int ret=FAIL,ret1=FAIL; + int n=0; + sprintf(mess,"Function (Set CTB Pattern) is not implemented for this detector\n"); + cprintf(RED, "Error: %s", mess); + + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + + n = sendData(file_des,&ret1,sizeof(ret),INT32); + n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); + + // return ok / fail + return ret; +} + + + +int write_adc_register(int file_des) { + int ret=OK, ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"write to adc register failed\n"); + +#ifndef JUNGFRAUD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Write ADC Register) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int arg[2]={-1,-1}; + n = receiveData(file_des,arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + int addr=arg[0]; + int val=arg[1]; + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } + else { +#ifdef VERBOSE + printf("writing to register 0x%x data 0x%x\n", addr, val); +#endif + setAdc(addr,val); +#ifdef VERBOSE + printf("Data set to 0x%x\n", retval); +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + } +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + +int set_counter_bit(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"set counter bit failed \n"); + +#ifndef EIGERD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + strcpy(mess,"Function (Set Counter Bit) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int arg=-1; + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus && arg!=-1) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { +#ifdef VERBOSE + printf("Getting/Setting/Resetting counter bit :%d \n",arg); +#endif + retval=setCounterBit(arg); + if((arg != -1) && (retval != arg)) { + ret=FAIL; + cprintf(RED, "Warning: %s", mess); + } + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + } +#endif +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + +int pulse_pixel(int file_des) { + int ret=OK,ret1=OK; + int n=0; + sprintf(mess,"pulse pixel failed\n"); + +#ifndef EIGERD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + strcpy(mess,"Function (Pulse Pixel) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int arg[3]={-1,-1,-1}; + n = receiveData(file_des,arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { + ret=pulsePixel(arg[0],arg[1],arg[2]); + if (ret == FAIL) + cprintf(RED, "Warning: %s", mess); + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + +int pulse_pixel_and_move(int file_des) { + int ret=OK,ret1=OK; + int n=0; + sprintf(mess,"pulse pixel and move failed\n"); + +#ifndef EIGERD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + strcpy(mess,"Function (Pulse Pixel and Move) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int arg[3]={-1,-1,-1}; + n = receiveData(file_des,arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { + ret=pulsePixelNMove(arg[0],arg[1],arg[2]); + if (ret == FAIL) + cprintf(RED, "Warning: %s", mess); + } +#endif + if(ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + + + +int pulse_chip(int file_des) { + int ret=OK,ret1=OK; + int n=0; + sprintf(mess,"pulse chip failed\n"); + +#ifndef EIGERD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + strcpy(mess,"Function (Pulse Chip) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int arg = -1; + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { + ret=pulseChip(arg); + if (ret == FAIL) + cprintf(RED, "Warning: %s", mess); + } +#endif + if(ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + + +int set_rate_correct(int file_des) { + int ret=OK,ret1=OK; + int n=0; + sprintf(mess,"Set rate correct failed\n"); + +#ifndef EIGERD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret=FAIL; + sprintf(mess,"Function (Rate Correction) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int64_t tau_ns=-1; + n = receiveData(file_des,&tau_ns,sizeof(tau_ns),INT64); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { + printf("Setting rate correction to %lld ns\n",(long long int)tau_ns); + //set rate + //wrong bit mode + if((setDynamicRange(-1)!=32) && (setDynamicRange(-1)!=16) && (tau_ns!=0)){ + ret=FAIL; + strcpy(mess,"Rate correction Deactivated, must be in 32 or 16 bit mode\n"); + cprintf(RED, "Warning: %s", mess); + } + //16 or 32 bit mode + else{ + if(tau_ns < 0) + tau_ns = getDefaultSettingsTau_in_nsec(); + else if(tau_ns > 0){ + //changing tau to a user defined value changes settings to undefined + setSettings(UNDEFINED,-1); + cprintf(RED,"Settings has been changed to undefined (tau changed)\n"); + } + + int64_t retval = setRateCorrection(tau_ns); + if(tau_ns != retval){ + ret=FAIL; + cprintf(RED, "Warning: %s", mess); + } + } + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n = sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + + +int get_rate_correct(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int64_t retval=-1; + sprintf(mess,"Get Rate correct failed\n"); + +#ifndef EIGERD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret=FAIL; + sprintf(mess,"Function (Get Rate Correction) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + +#ifdef SLS_DETECTOR_FUNCTION_LIST + + // execute action + retval = getCurrentTau(); + printf("Getting rate correction %lld\n",(long long int)retval); + +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT64); + + // return ok / fail + return ret; +} + + + + + +int set_network_parameter(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"set network parameter failed\n"); + +#ifndef EIGERD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret=FAIL; + sprintf(mess,"Function(Set Network Parmaeter) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + enum NETWORKINDEX index; + + // receive arguments + enum networkParameter mode=0; + int value=-1; + n = receiveData(file_des,&mode,sizeof(mode),INT32); + if (n < 0) return printSocketReadError(); + + n = receiveData(file_des,&value,sizeof(value),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus && value<0) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { +#ifdef VERBOSE + printf("setting network parameter mode %d to %d\n",(int)mode,value); +#endif + switch (mode) { + case DETECTOR_TXN_DELAY_LEFT: + index = TXN_LEFT; + break; + case DETECTOR_TXN_DELAY_RIGHT: + index = TXN_RIGHT; + break; + case DETECTOR_TXN_DELAY_FRAME: + index = TXN_FRAME; + break; + case FLOW_CONTROL_10G: + index = FLOWCTRL_10G; + break; + default: + ret=FAIL; + sprintf(mess,"Network Parameter Index (%d) is not implemented for this detector\n",(int) mode); + cprintf(RED, "Warning: %s", mess); + break; + } + if (ret==OK) { + retval=setNetworkParameter(index, value); + if ((retval!=value) && (value>=0)) { + ret=FAIL; + sprintf(mess,"could not change network parameter mode %d: should be %d but is %d \n",index, value, retval); + cprintf(RED, "Warning: %s", mess); + } + } + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + + + +int program_fpga(int file_des) { + int ret=OK,ret1=OK; + int n=0; + sprintf(mess,"program FPGA failed\n"); + + +#ifndef JUNGFRAUD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret=FAIL; + sprintf(mess,"Function (Program FPGA) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + size_t filesize = 0; + size_t totalsize = 0; + size_t unitprogramsize = 0; + char* fpgasrc = NULL; + FILE* fp = NULL; + + // receive arguments - filesize + n = receiveData(file_des,&filesize,sizeof(filesize),INT32); + if (n < 0) return printSocketReadError(); + totalsize = filesize; +#ifdef VERY_VERBOSE + printf("\n\n Total size is:%d\n",totalsize); +#endif + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { + //opening file pointer to flash and telling FPGA to not touch flash + if(startWritingFPGAprogram(&fp) != OK) { + ret=FAIL; + sprintf(mess,"Could not write to flash. Error at startup.\n"); + cprintf(RED,"%s",mess); + } + + //---------------- first ret ---------------- + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + //---------------- first ret ---------------- + + if(ret!=FAIL) { + //erasing flash + eraseFlash(); + fpgasrc = (char*)malloc(MAX_FPGAPROGRAMSIZE); + } + + //writing to flash part by part + while(ret != FAIL && filesize){ + + unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb + if(unitprogramsize > filesize) //less than 2mb + unitprogramsize = filesize; + #ifdef VERY_VERBOSE + printf("unit size to receive is:%d\n",unitprogramsize); + printf("filesize:%d currentpointer:%d\n",filesize,currentPointer); + #endif + + //receive + n = receiveData(file_des,fpgasrc,unitprogramsize,OTHER); + if (n < 0) return printSocketReadError(); + + if(!(unitprogramsize - filesize)){ + fpgasrc[unitprogramsize]='\0'; + filesize-=unitprogramsize; + unitprogramsize++; + }else + filesize-=unitprogramsize; + + ret = writeFPGAProgram(fpgasrc,unitprogramsize,fp); + + //---------------- middle rets ---------------- + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + cprintf(RED,"Failure: Breaking out of program receiving\n"); + } + //---------------- middle rets ---------------- + + if(ret != FAIL){ + //print progress + printf("Writing to Flash:%d%%\r",(int) (((double)(totalsize-filesize)/totalsize)*100) ); + fflush(stdout); + } + } + + printf("\n"); + + //closing file pointer to flash and informing FPGA + stopWritingFPGAprogram(fp); + + //free resources + if(fpgasrc != NULL) + free(fpgasrc); + if(fp!=NULL) + fclose(fp); +#ifdef VERY_VERBOSE + printf("Done with program receiving command\n"); +#endif + if (isControlServer) + basictests(debugflag); + init_detector(isControlServer); + } +#endif + if (ret==OK) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + + + +int reset_fpga(int file_des) { + int ret=OK,ret1=OK; + int n=0; + sprintf(mess,"Reset FPGA unsuccessful\n"); + +#ifndef JUNGFRAUD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Start Readout) is not implemented for this detector\n"); + cprintf(RED, "%s", mess); +#else + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { + if (isControlServer) + basictests(debugflag); + init_detector(isControlServer); + ret = FORCE_UPDATE; + } +#endif +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + + +int power_chip(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"power chip failed\n"); + +#ifndef JUNGFRAUD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Power Chip) is not implemented for this detector\n"); + cprintf(RED, "%s", mess); +#else + + // receive arguments + int arg=-1; + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus && arg!=-1) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { +#ifdef VERBOSE + printf("Power chip to %d\n", arg); +#endif + retval=powerChip(arg); + +#ifdef VERBOSE + printf("Chip powered: %d\n",retval); +#endif + if (retval==arg || arg<0) { + ret=OK; + } else { + ret=FAIL; + sprintf(mess,"Powering chip failed, wrote %d but read %d\n", arg, retval); + cprintf(RED, "Warning: %s", mess); + } + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + +int set_activate(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"Activate/Deactivate failed\n"); + +#ifndef EIGERD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret=FAIL; + sprintf(mess,"Function (Set Activate) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int arg=-1; + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus && arg!=-1) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { +#ifdef VERBOSE + printf("Setting activate mode of detector to %d\n",arg); +#endif + retval=activate(arg); + if ((retval!=arg) && (arg!=-1)) { + ret=FAIL; + sprintf(mess,"Could not set activate mode to %d, is set to %d\n",arg, retval); + cprintf(RED, "Warning: %s", mess); + } + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } else + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + + + +int prepare_acquisition(int file_des) { + int ret=OK,ret1=OK; + int n=0; + strcpy(mess,"prepare acquisition failed\n"); + +#if !defined(GOTTHARDD) && !defined(EIGERD) + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Prepare Acquisition) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { + ret = prepareAcquisition(); + if (ret == FAIL) + cprintf(RED, "Warning: %s", mess); + } +#endif + if(ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + +int cleanup_acquisition(int file_des) { + int ret=OK,ret1=OK; + int n=0; + strcpy(mess,"prepare acquisition failed\n"); + +#ifndef GOTTHARDD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (Cleanup Acquisition) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // execute action + if (differentClients && lockStatus) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else {//to be implemented when used here + ret = FAIL; + sprintf(mess,"Function (Cleanup Acquisition) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); + } +#endif + if(ret==OK && differentClients) + ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + + // return ok / fail + return ret; +} + + diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_funcs.h b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_funcs.h new file mode 100755 index 000000000..bae48f17c --- /dev/null +++ b/slsDetectorSoftware/mythen3DetectorServer/mythen3Server_funcs.h @@ -0,0 +1,94 @@ +#ifndef SERVER_FUNCS_H +#define SERVER_FUNCS_H + +#include "sls_receiver_defs.h" +#include + +// initialization functions +int printSocketReadError(); +void basictests(int); +void init_detector(int); +// void init_detector(int,int); +int decode_function(int); +const char* getFunctionName(enum detFuncs func); +void function_table(); +int M_nofunc(int); + +// functions called by client +int exec_command(int); +int get_error(int); +int get_detector_type(int); +int set_number_of_modules(int); +int get_max_number_of_modules(int); +int set_external_signal_flag(int); +int set_external_communication_mode(int); +int get_id(int); +int digital_test(int); +int analog_test(int); +int enable_analog_out(int); +int calibration_pulse(int); +int set_dac(int); +int get_adc(int); +int write_register(int); +int read_register(int); +int write_memory(int); +int read_memory(int); +int set_channel(int); +int get_channel(int); +int set_all_channels(int); +int set_chip(int); +int get_chip(int); +int set_all_chips(int); +int set_module(int); +int get_module(int); +int set_all_modules(int); +int set_settings(int); +int get_threshold_energy(int); +int set_threshold_energy(int); +int start_acquisition(int); +int stop_acquisition(int); +int start_readout(int); +int get_run_status(int); +int start_and_read_all(int); +int read_frame(int); +int read_all(int); +int set_timer(int); +int get_time_left(int); +int set_dynamic_range(int); +int set_readout_flags(int); +int set_roi(int); +int set_speed(int); +int execute_trimming(int); +int exit_server(int); +int lock_server(int); +int get_last_client_ip(int); +int set_port(int); +int update_client(int); +int send_update(int); +int configure_mac(int); +int load_image(int); +int set_master(int); +int set_synchronization(int); +int read_counter_block(int); +int reset_counter_block(int); +int calibrate_pedestal(int); +int enable_ten_giga(int); +int set_all_trimbits(int); +int set_ctb_pattern(int); +int write_adc_register(int); +int set_counter_bit(int); +int pulse_pixel(int); +int pulse_pixel_and_move(int); +int pulse_chip(int); +int set_rate_correct(int); +int get_rate_correct(int); +int set_network_parameter(int); +int program_fpga(int); +int reset_fpga(int); +int power_chip(int); +int set_activate(int); +int prepare_acquisition(int); +int cleanup_acquisition(int); + + +#endif