Merge pull request #104 from slsdetectorgroup/gnu99

Gnu99
This commit is contained in:
Dhanya Thattil 2020-06-15 09:39:07 +02:00 committed by GitHub
commit 5a7451e29e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 620 additions and 849 deletions

View File

@ -8,7 +8,6 @@ if [ $# -eq 0 ]; then
) )
else else
declare -a det=("${1}") declare -a det=("${1}")
echo "got something"
fi fi
declare -a deterror=("OK" "OK" "OK" "OK" "OK" "OK") declare -a deterror=("OK" "OK" "OK" "OK" "OK" "OK")

View File

@ -5,7 +5,7 @@ support_lib = ../../slsSupportLib/include/
CROSS = bfin-uclinux- CROSS = bfin-uclinux-
CC = $(CROSS)gcc CC = $(CROSS)gcc
CFLAGS += -Wall -DCHIPTESTBOARDD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE CFLAGS += -Wall -std=gnu99 -DCHIPTESTBOARDD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
LDLIBS += -lm LDLIBS += -lm
PROGS = ctbDetectorServer PROGS = ctbDetectorServer
DESTDIR ?= bin DESTDIR ?= bin

View File

@ -237,8 +237,7 @@ int testFpga() {
volatile uint32_t val = 0, readval = 0; volatile uint32_t val = 0, readval = 0;
int times = 1000 * 1000; int times = 1000 * 1000;
int i = 0; for (int i = 0; i < times; ++i) {
for (i = 0; i < times; ++i) {
val = 0x5A5A5A5A - i; val = 0x5A5A5A5A - i;
bus_w(addr, val); bus_w(addr, val);
readval = bus_r(addr); readval = bus_r(addr);
@ -302,9 +301,8 @@ int testBus() {
volatile uint32_t val = 0, readval = 0; volatile uint32_t val = 0, readval = 0;
int times = 1000 * 1000; int times = 1000 * 1000;
int i = 0;
for (i = 0; i < times; ++i) { for (int i = 0; i < times; ++i) {
val += 0xbbbbb; val += 0xbbbbb;
bus_w(addr, val); bus_w(addr, val);
readval = bus_r(addr); readval = bus_r(addr);
@ -463,15 +461,14 @@ void setupDetector() {
analogDataPtr = 0; analogDataPtr = 0;
digitalDataPtr = 0; digitalDataPtr = 0;
{ {
int i = 0; for (int i = 0; i < NUM_CLOCKS; ++i) {
for (i = 0; i < NUM_CLOCKS; ++i) {
clkPhase[i] = 0; clkPhase[i] = 0;
} }
clkFrequency[RUN_CLK] = DEFAULT_RUN_CLK; clkFrequency[RUN_CLK] = DEFAULT_RUN_CLK;
clkFrequency[ADC_CLK] = DEFAULT_ADC_CLK; clkFrequency[ADC_CLK] = DEFAULT_ADC_CLK;
clkFrequency[SYNC_CLK] = DEFAULT_SYNC_CLK; clkFrequency[SYNC_CLK] = DEFAULT_SYNC_CLK;
clkFrequency[DBIT_CLK] = DEFAULT_DBIT_CLK; clkFrequency[DBIT_CLK] = DEFAULT_DBIT_CLK;
for (i = 0; i < NDAC; ++i) for (int i = 0; i < NDAC; ++i)
dacValues[i] = -1; dacValues[i] = -1;
} }
vLimit = DEFAULT_VLIMIT; vLimit = DEFAULT_VLIMIT;
@ -528,12 +525,9 @@ void setupDetector() {
// switch off dacs (power regulators most likely only sets to minimum (if // switch off dacs (power regulators most likely only sets to minimum (if
// power enable on)) // power enable on))
LOG(logINFOBLUE, ("Powering down all dacs\n")); LOG(logINFOBLUE, ("Powering down all dacs\n"));
{ for (int idac = 0; idac < NDAC; ++idac) {
int idac = 0; setDAC(idac, LTC2620_GetPowerDownValue(),
for (idac = 0; idac < NDAC; ++idac) { 0); // has to be before setvchip
setDAC(idac, LTC2620_GetPowerDownValue(),
0); // has to be before setvchip
}
} }
// power regulators // power regulators
@ -649,8 +643,7 @@ void updateDataBytes() {
if (adcEnableMask_1g == BIT32_MSK) if (adcEnableMask_1g == BIT32_MSK)
nachans = 32; nachans = 32;
else { else {
int ichan = 0; for (int ichan = 0; ichan < NCHAN_ANALOG; ++ichan) {
for (ichan = 0; ichan < NCHAN_ANALOG; ++ichan) {
if (adcEnableMask_1g & (1 << ichan)) if (adcEnableMask_1g & (1 << ichan))
++nachans; ++nachans;
} }
@ -735,8 +728,7 @@ void setADCEnableMask_10G(uint32_t mask) {
uint8_t actualMask = 0; uint8_t actualMask = 0;
if (mask != 0) { if (mask != 0) {
int ival = 0; int ival = 0;
int ich = 0; for (int ich = 0; ich < NCHAN_ANALOG; ich = ich + 4) {
for (ich = 0; ich < NCHAN_ANALOG; ich = ich + 4) {
if ((1 << ich) & mask) { if ((1 << ich) & mask) {
actualMask |= (1 << ival); actualMask |= (1 << ival);
} }
@ -766,13 +758,11 @@ uint32_t getADCEnableMask_10G() {
// convert 8 bit mask to 32 bit mask // convert 8 bit mask to 32 bit mask
uint32_t retval = 0; uint32_t retval = 0;
if (adcEnableMask_10g) { if (adcEnableMask_10g) {
int ival = 0; for (int ival = 0; ival < 8; ++ival) {
int iloop = 0;
for (ival = 0; ival < 8; ++ival) {
// if bit in 8 bit mask set // if bit in 8 bit mask set
if ((1 << ival) & adcEnableMask_10g) { if ((1 << ival) & adcEnableMask_10g) {
// set it for 4 bits in 32 bit mask // set it for 4 bits in 32 bit mask
for (iloop = 0; iloop < 4; ++iloop) { for (int iloop = 0; iloop < 4; ++iloop) {
retval |= (1 << (ival * 4 + iloop)); retval |= (1 << (ival * 4 + iloop));
} }
} }
@ -1196,9 +1186,8 @@ int getVChipToSet(enum DACINDEX ind, int val) {
// get maximum value of the adc values (minimum is 0) // get maximum value of the adc values (minimum is 0)
int max = 0; int max = 0;
int ipwr = 0;
// loop through the adcs // loop through the adcs
for (ipwr = 0; ipwr < NPWR - 1; ++ipwr) { for (int ipwr = 0; ipwr < NPWR - 1; ++ipwr) {
// get the dac values for each adc // get the dac values for each adc
int dacmV = getPower(getDACIndexFromADCIndex(ipwr)); int dacmV = getPower(getDACIndexFromADCIndex(ipwr));
@ -2310,18 +2299,14 @@ void *start_timer(void *arg) {
// Generate Data // Generate Data
char imageData[imageSize]; char imageData[imageSize];
memset(imageData, 0, imageSize); memset(imageData, 0, imageSize);
{ for (int i = 0; i < imageSize; i += sizeof(uint16_t)) {
int i = 0; *((uint16_t *)(imageData + i)) = i;
for (i = 0; i < imageSize; i += sizeof(uint16_t)) {
*((uint16_t *)(imageData + i)) = i;
}
} }
// Send data // Send data
{ {
int frameNr = 0;
// loop over number of frames // loop over number of frames
for (frameNr = 0; frameNr != numFrames; ++frameNr) { for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
// update the virtual stop from stop server // update the virtual stop from stop server
virtual_stop = ComVirtual_getStop(); virtual_stop = ComVirtual_getStop();
@ -2337,30 +2322,27 @@ void *start_timer(void *arg) {
int srcOffset = 0; int srcOffset = 0;
// loop packet // loop packet
{ for (int i = 0; i != packetsPerFrame; ++i) {
int i = 0;
for (i = 0; i != packetsPerFrame; ++i) {
char packetData[packetSize]; char packetData[packetSize];
memset(packetData, 0, packetSize); memset(packetData, 0, packetSize);
// set header // set header
sls_detector_header *header = sls_detector_header *header =
(sls_detector_header *)(packetData); (sls_detector_header *)(packetData);
header->detType = (uint16_t)myDetectorType; header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION - 1; header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = frameNr; header->frameNumber = frameNr;
header->packetNumber = i; header->packetNumber = i;
header->modId = 0; header->modId = 0;
header->row = detPos[X]; header->row = detPos[X];
header->column = detPos[Y]; header->column = detPos[Y];
// fill data // fill data
memcpy(packetData + sizeof(sls_detector_header), memcpy(packetData + sizeof(sls_detector_header),
imageData + srcOffset, dataSize); imageData + srcOffset, dataSize);
srcOffset += dataSize; srcOffset += dataSize;
sendUDPPacket(0, packetData, packetSize); sendUDPPacket(0, packetData, packetSize);
}
} }
LOG(logINFO, ("Sent frame: %d\n", frameNr)); LOG(logINFO, ("Sent frame: %d\n", frameNr));
clock_gettime(CLOCK_REALTIME, &end); clock_gettime(CLOCK_REALTIME, &end);
@ -2555,11 +2537,8 @@ void readSample(int ns) {
bus_w(addr, bus_r(addr) & (~DUMMY_ANLG_FIFO_RD_STRBE_MSK)); bus_w(addr, bus_r(addr) & (~DUMMY_ANLG_FIFO_RD_STRBE_MSK));
// wait for 1 us to latch different clocks of read and read strobe // wait for 1 us to latch different clocks of read and read strobe
{ for (int i = 0; i < WAIT_TIME_1US_FOR_LOOP_CNT; ++i)
int i = 0; ;
for (i = 0; i < WAIT_TIME_1US_FOR_LOOP_CNT; ++i)
;
}
if (!(ns % 1000)) { if (!(ns % 1000)) {
LOG(logDEBUG1, ("Reading sample ns:%d of %d AEmtpy:0x%x AFull:0x%x " LOG(logDEBUG1, ("Reading sample ns:%d of %d AEmtpy:0x%x AFull:0x%x "
@ -2569,8 +2548,7 @@ void readSample(int ns) {
} }
// loop through all channels // loop through all channels
int ich = 0; for (int ich = 0; ich < NCHAN_ANALOG; ++ich) {
for (ich = 0; ich < NCHAN_ANALOG; ++ich) {
// if channel is in enable mask // if channel is in enable mask
if ((1 << ich) & (adcEnableMask_1g)) { if ((1 << ich) & (adcEnableMask_1g)) {
@ -2604,11 +2582,8 @@ void readSample(int ns) {
bus_w(addr, bus_r(addr) & (~DUMMY_DGTL_FIFO_RD_STRBE_MSK)); bus_w(addr, bus_r(addr) & (~DUMMY_DGTL_FIFO_RD_STRBE_MSK));
// wait for 1 us to latch different clocks of read and read strobe // wait for 1 us to latch different clocks of read and read strobe
{ for (int i = 0; i < WAIT_TIME_1US_FOR_LOOP_CNT; ++i)
int i = 0; ;
for (i = 0; i < WAIT_TIME_1US_FOR_LOOP_CNT; ++i)
;
}
// wait as it is connected directly to fifo running on a different clock // wait as it is connected directly to fifo running on a different clock
if (!(ns % 1000)) { if (!(ns % 1000)) {
@ -2735,8 +2710,7 @@ void getNumberOfChannels(int *nchanx, int *nchany) {
if (mask == BIT32_MASK) { if (mask == BIT32_MASK) {
nachans = NCHAN_ANALOG; nachans = NCHAN_ANALOG;
} else { } else {
int ich = 0; for (int ich = 0; ich < NCHAN_ANALOG; ++ich) {
for (ich = 0; ich < NCHAN_ANALOG; ++ich) {
if ((mask & (1 << ich)) != 0U) if ((mask & (1 << ich)) != 0U)
++nachans; ++nachans;
} }

View File

@ -141,8 +141,7 @@ void Beb_Beb(int id) {
exit(1); exit(1);
LOG(logDEBUG1, ("Printing Beb infos:\n")); LOG(logDEBUG1, ("Printing Beb infos:\n"));
unsigned int i; for (unsigned int i = 1; i < bebInfoSize; i++)
for (i = 1; i < bebInfoSize; i++)
BebInfo_Print(&beb_infos[i]); BebInfo_Print(&beb_infos[i]);
Beb_bit_mode = 4; Beb_bit_mode = 4;
@ -749,11 +748,7 @@ void Beb_ResetFrameNumber() {
} }
} }
void Beb_ClearBebInfos() { void Beb_ClearBebInfos() { bebInfoSize = 0; }
// unsigned int i;
// for(i=0;i<bebInfoSize;i++) free(beb_infos[i]);
bebInfoSize = 0;
}
int Beb_InitBebInfos() { // file name at some point int Beb_InitBebInfos() { // file name at some point
Beb_ClearBebInfos(); Beb_ClearBebInfos();
@ -817,8 +812,8 @@ int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig,
} }
int Beb_CheckSourceStuffBebInfo() { int Beb_CheckSourceStuffBebInfo() {
unsigned int i; for (unsigned int i = 1; i < bebInfoSize;
for (i = 1; i < bebInfoSize; i++) { // header stuff always starts from 1 i++) { // header stuff always starts from 1
if (!Beb_SetHeaderData(BebInfo_GetBebNumber(&beb_infos[i]), 0, if (!Beb_SetHeaderData(BebInfo_GetBebNumber(&beb_infos[i]), 0,
"00:00:00:00:00:00", "10.0.0.1", 20000) || "00:00:00:00:00:00", "10.0.0.1", 20000) ||
!Beb_SetHeaderData(BebInfo_GetBebNumber(&beb_infos[i]), 1, !Beb_SetHeaderData(BebInfo_GetBebNumber(&beb_infos[i]), 1,
@ -833,10 +828,7 @@ int Beb_CheckSourceStuffBebInfo() {
} }
unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb) { unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb) {
/******************** if (!beb_numb) return for (unsigned int i = 1; i < bebInfoSize; i++)
* 0;******************************/
unsigned int i;
for (i = 1; i < bebInfoSize; i++)
if (beb_numb == BebInfo_GetBebNumber(&beb_infos[i])) { if (beb_numb == BebInfo_GetBebNumber(&beb_infos[i])) {
LOG(logDEBUG1, LOG(logDEBUG1,
("*****found beb index:%d, for beb number:%d\n", i, beb_numb)); ("*****found beb index:%d, for beb number:%d\n", i, beb_numb));
@ -870,14 +862,13 @@ int Beb_WriteTo(unsigned int index) {
} }
void Beb_SwapDataFun(int little_endian, unsigned int n, unsigned int *d) { void Beb_SwapDataFun(int little_endian, unsigned int n, unsigned int *d) {
unsigned int i;
if (little_endian) if (little_endian)
for (i = 0; i < n; i++) for (unsigned int i = 0; i < n; i++)
d[i] = (((d[i] & 0xff) << 24) | ((d[i] & 0xff00) << 8) | d[i] = (((d[i] & 0xff) << 24) | ((d[i] & 0xff00) << 8) |
((d[i] & 0xff0000) >> 8) | ((d[i] & 0xff0000) >> 8) |
((d[i] & 0xff000000) >> 24)); // little_endian ((d[i] & 0xff000000) >> 24)); // little_endian
else else
for (i = 0; i < n; i++) for (unsigned int i = 0; i < n; i++)
d[i] = (((d[i] & 0xffff) << 16) | ((d[i] & 0xffff0000) >> 16)); d[i] = (((d[i] & 0xffff) << 16) | ((d[i] & 0xffff0000) >> 16));
} }
@ -976,13 +967,9 @@ udp_header_type udp_header = {
unsigned int *base_ptr = (unsigned int *)&udp_header; unsigned int *base_ptr = (unsigned int *)&udp_header;
unsigned int num_words = (sizeof(struct udp_header_type) + 3) / 4; unsigned int num_words = (sizeof(struct udp_header_type) + 3) / 4;
// for(unsigned int i=0; i<num_words; i++) word_ptr[i] = base_ptr[i]; for (unsigned int i = 0; i < num_words; i++)
// for(unsigned int i=num_words; i<16; i++) word_ptr[i] = 0;
// return word_ptr;
unsigned int i;
for (i = 0; i < num_words; i++)
Beb_send_data[i + 2] = base_ptr[i]; Beb_send_data[i + 2] = base_ptr[i];
for (i = num_words; i < 16; i++) for (unsigned int i = num_words; i < 16; i++)
Beb_send_data[i + 2] = 0; Beb_send_data[i + 2] = 0;
return 1; return 1;
@ -1046,8 +1033,7 @@ void Beb_AdjustIPChecksum(struct udp_header_type *ip) {
// calc ip checksum // calc ip checksum
unsigned int ip_checksum = 0; unsigned int ip_checksum = 0;
unsigned int i; for (unsigned int i = 0; i < 10; i++) {
for (i = 0; i < 10; i++) {
ip_checksum += ((cptr[2 * i] << 8) + (cptr[2 * i + 1])); ip_checksum += ((cptr[2 * i] << 8) + (cptr[2 * i + 1]));
if (ip_checksum & 0x00010000) if (ip_checksum & 0x00010000)
ip_checksum = (ip_checksum + 1) & 0x0000ffff; ip_checksum = (ip_checksum + 1) & 0x0000ffff;
@ -1190,11 +1176,9 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig,
LOG(logERROR, ("Beb Request N Images FAIL\n")); LOG(logERROR, ("Beb Request N Images FAIL\n"));
return 0; return 0;
} else { } else {
{ for (int i = 0; i < 10; i++) {
int i; LOG(logDEBUG1,
for (i = 0; i < 10; i++) ("%X\n", Beb_Read32(csp0base, (LEFT_OFFSET + i * 4))));
LOG(logDEBUG1,
("%X\n", Beb_Read32(csp0base, (LEFT_OFFSET + i * 4))));
} }
// Generating commands // Generating commands
u_int32_t send_header_command = u_int32_t send_header_command =
@ -1203,13 +1187,11 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig,
u_int32_t send_frame_command = u_int32_t send_frame_command =
0x62000000 | (!test_just_send_out_packets_no_wait) << 27 | 0x62000000 | (!test_just_send_out_packets_no_wait) << 27 |
(ten_gig == 1) << 24 | packet_size << 14 | (npackets - 1); (ten_gig == 1) << 24 | packet_size << 14 | (npackets - 1);
{ for (int i = 0; i < 10; i++) {
int i; LOG(logDEBUG1,
for (i = 0; i < 10; i++) ("%X\n", Beb_Read32(csp0base, (LEFT_OFFSET + i * 4))));
LOG(logDEBUG1,
("%X\n", Beb_Read32(csp0base, (LEFT_OFFSET + i * 4))));
LOG(logDEBUG1, ("%d\n", in_two_requests));
} }
LOG(logDEBUG1, ("%d\n", in_two_requests));
//"0x20 << 8" is dst_number (0x00 for left, 0x20 for right) //"0x20 << 8" is dst_number (0x00 for left, 0x20 for right)
// Left // Left
Beb_Write32(csp0base, (LEFT_OFFSET + FIRST_CMD_PART1_OFFSET), 0); Beb_Write32(csp0base, (LEFT_OFFSET + FIRST_CMD_PART1_OFFSET), 0);
@ -1246,14 +1228,12 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig,
nimages * (2 + in_two_requests)); nimages * (2 + in_two_requests));
Beb_Write32(csp0base, (RIGHT_OFFSET + COMMAND_COUNTER_OFFSET), Beb_Write32(csp0base, (RIGHT_OFFSET + COMMAND_COUNTER_OFFSET),
nimages * (2 + in_two_requests)); nimages * (2 + in_two_requests));
{ for (int i = 0; i < 10; i++) {
int i; LOG(logDEBUG1,
for (i = 0; i < 10; i++) ("%X\n", Beb_Read32(csp0base,
LOG(logDEBUG1, (LEFT_OFFSET + i * 4)))); //*(ptrl+i));
("%X\n", Beb_Read32(csp0base,
(LEFT_OFFSET + i * 4)))); //*(ptrl+i));
LOG(logDEBUG1, ("%d\n", in_two_requests));
} }
LOG(logDEBUG1, ("%d\n", in_two_requests));
Beb_close(fd, csp0base); Beb_close(fd, csp0base);
LOG(logDEBUG1, ("----Beb_RequestNImages----\n")); LOG(logDEBUG1, ("----Beb_RequestNImages----\n"));
@ -1275,8 +1255,7 @@ int Beb_Test(unsigned int beb_number) {
return 0; return 0;
} }
unsigned int i; for (unsigned int i = 0; i < 64; i++) {
for (i = 0; i < 64; i++) {
if (!Beb_SetUpUDPHeader(beb_number, 0, i, "60:fb:42:f4:e3:d2", if (!Beb_SetUpUDPHeader(beb_number, 0, i, "60:fb:42:f4:e3:d2",
"129.129.205.186", 22000 + i)) { "129.129.205.186", 22000 + i)) {
LOG(logERROR, ("Error setting up header table....\n")); LOG(logERROR, ("Error setting up header table....\n"));
@ -1288,7 +1267,7 @@ int Beb_Test(unsigned int beb_number) {
// left_right, int ten_gig, unsigned int dst_number, unsigned int // left_right, int ten_gig, unsigned int dst_number, unsigned int
// npackets, unsigned int packet_size, int // npackets, unsigned int packet_size, int
// stop_read_when_fifo_empty=1); // stop_read_when_fifo_empty=1);
for (i = 0; i < 64; i++) { for (unsigned int i = 0; i < 64; i++) {
if (!Beb_SendMultiReadRequest(beb_number, i % 3 + 1, 0, i, 1, 0, 1)) { if (!Beb_SendMultiReadRequest(beb_number, i % 3 + 1, 0, i, 1, 0, 1)) {
LOG(logERROR, ("Error requesting data....\n")); LOG(logERROR, ("Error requesting data....\n"));
return 0; return 0;

View File

@ -63,7 +63,6 @@ int Feb_Control_hv_fd = -1;
void Module_Module(struct Module *mod, unsigned int number, void Module_Module(struct Module *mod, unsigned int number,
unsigned int address_top) { unsigned int address_top) {
unsigned int i;
mod->module_number = number; mod->module_number = number;
mod->top_address_valid = 1; mod->top_address_valid = 1;
mod->top_left_address = 0x100 | (0xff & address_top); mod->top_left_address = 0x100 | (0xff & address_top);
@ -75,15 +74,14 @@ void Module_Module(struct Module *mod, unsigned int number,
mod->high_voltage = -1; mod->high_voltage = -1;
mod->top_dac = malloc(Module_ndacs * sizeof(int)); mod->top_dac = malloc(Module_ndacs * sizeof(int));
mod->bottom_dac = malloc(Module_ndacs * sizeof(int)); mod->bottom_dac = malloc(Module_ndacs * sizeof(int));
for (i = 0; i < Module_ndacs; i++) for (unsigned int i = 0; i < Module_ndacs; i++)
mod->top_dac[i] = mod->top_address_valid ? -1 : 0; mod->top_dac[i] = mod->top_address_valid ? -1 : 0;
for (i = 0; i < Module_ndacs; i++) for (unsigned int i = 0; i < Module_ndacs; i++)
mod->bottom_dac[i] = mod->bottom_address_valid ? -1 : 0; mod->bottom_dac[i] = mod->bottom_address_valid ? -1 : 0;
} }
void Module_ModuleBottom(struct Module *mod, unsigned int number, void Module_ModuleBottom(struct Module *mod, unsigned int number,
unsigned int address_bottom) { unsigned int address_bottom) {
unsigned int i;
mod->module_number = number; mod->module_number = number;
mod->top_address_valid = 0; mod->top_address_valid = 0;
mod->top_left_address = 0; mod->top_left_address = 0;
@ -94,20 +92,19 @@ void Module_ModuleBottom(struct Module *mod, unsigned int number,
mod->high_voltage = -1; mod->high_voltage = -1;
for (i = 0; i < 4; i++) for (unsigned int i = 0; i < 4; i++)
mod->idelay_top[i] = mod->idelay_bottom[i] = 0; mod->idelay_top[i] = mod->idelay_bottom[i] = 0;
mod->top_dac = malloc(Module_ndacs * sizeof(int)); mod->top_dac = malloc(Module_ndacs * sizeof(int));
mod->bottom_dac = malloc(Module_ndacs * sizeof(int)); mod->bottom_dac = malloc(Module_ndacs * sizeof(int));
for (i = 0; i < Module_ndacs; i++) for (unsigned int i = 0; i < Module_ndacs; i++)
mod->top_dac[i] = mod->top_address_valid ? -1 : 0; mod->top_dac[i] = mod->top_address_valid ? -1 : 0;
for (i = 0; i < Module_ndacs; i++) for (unsigned int i = 0; i < Module_ndacs; i++)
mod->bottom_dac[i] = mod->bottom_address_valid ? -1 : 0; mod->bottom_dac[i] = mod->bottom_address_valid ? -1 : 0;
} }
void Module_Module1(struct Module *mod, unsigned int number, void Module_Module1(struct Module *mod, unsigned int number,
unsigned int address_top, unsigned int address_bottom) { unsigned int address_top, unsigned int address_bottom) {
unsigned int i;
mod->module_number = number; mod->module_number = number;
mod->top_address_valid = 1; mod->top_address_valid = 1;
mod->top_left_address = 0x100 | (0xff & address_top); mod->top_left_address = 0x100 | (0xff & address_top);
@ -118,14 +115,14 @@ void Module_Module1(struct Module *mod, unsigned int number,
mod->high_voltage = -1; mod->high_voltage = -1;
for (i = 0; i < 4; i++) for (unsigned int i = 0; i < 4; i++)
mod->idelay_top[i] = mod->idelay_bottom[i] = 0; mod->idelay_top[i] = mod->idelay_bottom[i] = 0;
mod->top_dac = malloc(Module_ndacs * sizeof(int)); mod->top_dac = malloc(Module_ndacs * sizeof(int));
mod->bottom_dac = malloc(Module_ndacs * sizeof(int)); mod->bottom_dac = malloc(Module_ndacs * sizeof(int));
for (i = 0; i < Module_ndacs; i++) for (unsigned int i = 0; i < Module_ndacs; i++)
mod->top_dac[i] = mod->top_address_valid ? -1 : 0; mod->top_dac[i] = mod->top_address_valid ? -1 : 0;
for (i = 0; i < Module_ndacs; i++) for (unsigned int i = 0; i < Module_ndacs; i++)
mod->bottom_dac[i] = mod->bottom_address_valid ? -1 : 0; mod->bottom_dac[i] = mod->bottom_address_valid ? -1 : 0;
} }
@ -219,7 +216,6 @@ void Feb_Control_FebControl() {
} }
int Feb_Control_Init(int master, int top, int normal, int module_num) { int Feb_Control_Init(int master, int top, int normal, int module_num) {
unsigned int i;
Feb_Control_module_number = 0; Feb_Control_module_number = 0;
Feb_Control_current_index = 0; Feb_Control_current_index = 0;
Feb_control_master = master; Feb_control_master = master;
@ -241,7 +237,7 @@ int Feb_Control_Init(int master, int top, int normal, int module_num) {
unsigned int nfebs = 0; unsigned int nfebs = 0;
unsigned int *feb_list = malloc(moduleSize * 4 * sizeof(unsigned int)); unsigned int *feb_list = malloc(moduleSize * 4 * sizeof(unsigned int));
for (i = 1; i < moduleSize; i++) { for (unsigned int i = 1; i < moduleSize; i++) {
if (Module_TopAddressIsValid(&modules[i])) { if (Module_TopAddressIsValid(&modules[i])) {
feb_list[nfebs++] = Module_GetTopRightAddress(&modules[i]); feb_list[nfebs++] = Module_GetTopRightAddress(&modules[i]);
feb_list[nfebs++] = Module_GetTopLeftAddress(&modules[i]); feb_list[nfebs++] = Module_GetTopLeftAddress(&modules[i]);
@ -321,9 +317,8 @@ void Feb_Control_CloseSerialCommunication() {
} }
void Feb_Control_PrintModuleList() { void Feb_Control_PrintModuleList() {
unsigned int i;
LOG(logDEBUG1, ("Module list:\n")); LOG(logDEBUG1, ("Module list:\n"));
for (i = 0; i < moduleSize; i++) { for (unsigned int i = 0; i < moduleSize; i++) {
LOG(logDEBUG1, LOG(logDEBUG1,
("\t%d) %s modules: %d 0x%x %s\n", i, ("\t%d) %s modules: %d 0x%x %s\n", i,
((i == 0) ? "All " : ((i == 1) ? "Master" : " ")), ((i == 0) ? "All " : ((i == 1) ? "Master" : " ")),
@ -338,8 +333,7 @@ void Feb_Control_PrintModuleList() {
int Feb_Control_GetModuleIndex(unsigned int module_number, int Feb_Control_GetModuleIndex(unsigned int module_number,
unsigned int *module_index) { unsigned int *module_index) {
unsigned int i; for (unsigned int i = 0; i < moduleSize; i++) {
for (i = 0; i < moduleSize; i++) {
if (Module_GetModuleNumber(&modules[i]) == module_number) { if (Module_GetModuleNumber(&modules[i]) == module_number) {
*module_index = i; *module_index = i;
return 1; return 1;
@ -350,10 +344,9 @@ int Feb_Control_GetModuleIndex(unsigned int module_number,
} }
int Feb_Control_CheckModuleAddresses(struct Module *m) { int Feb_Control_CheckModuleAddresses(struct Module *m) {
unsigned int i;
int found_t = 0; int found_t = 0;
int found_b = 0; int found_b = 0;
for (i = 0; i < moduleSize; i++) { for (unsigned int i = 0; i < moduleSize; i++) {
if ((Module_TopAddressIsValid(m) && if ((Module_TopAddressIsValid(m) &&
Module_GetTopBaseAddress(&modules[i]) && Module_GetTopBaseAddress(&modules[i]) &&
Module_GetTopBaseAddress(m) == Module_GetTopBaseAddress(m) ==
@ -408,8 +401,7 @@ int Feb_Control_AddModule1(unsigned int module_number, int top_enable,
LOG(logINFO, ("\tRemoving previous assignment of module number %d.\n", LOG(logINFO, ("\tRemoving previous assignment of module number %d.\n",
module_number)); module_number));
// free(modules[pre_module_index]); // free(modules[pre_module_index]);
int i; for (int i = pre_module_index; i < moduleSize - 1; i++)
for (i = pre_module_index; i < moduleSize - 1; i++)
modules[i] = modules[i + 1]; modules[i] = modules[i + 1];
moduleSize--; moduleSize--;
parameters_ok = 0; parameters_ok = 0;
@ -460,13 +452,12 @@ Module_ModuleBottom(m,module_number,top_address);*/
int Feb_Control_CheckSetup(int master) { int Feb_Control_CheckSetup(int master) {
LOG(logDEBUG1, ("Checking Set up\n")); LOG(logDEBUG1, ("Checking Set up\n"));
unsigned int i, j; unsigned int i;
int ok = 1; int ok = 1;
/*for(i=0;i<moduleSize;i++) {*/
i = Feb_Control_current_index; i = Feb_Control_current_index;
for (j = 0; j < 4; j++) { for (unsigned int j = 0; j < 4; j++) {
if (Module_GetTopIDelay(&modules[i], j) < 0) { if (Module_GetTopIDelay(&modules[i], j) < 0) {
LOG(logERROR, ("module %d's idelay top number %d not set.\n", LOG(logERROR, ("module %d's idelay top number %d not set.\n",
Module_GetModuleNumber(&modules[i]), j)); Module_GetModuleNumber(&modules[i]), j));
@ -484,7 +475,7 @@ int Feb_Control_CheckSetup(int master) {
Module_GetModuleNumber(&modules[i]))); Module_GetModuleNumber(&modules[i])));
ok = 0; ok = 0;
} }
for (j = 0; j < Module_ndacs; j++) { for (unsigned int j = 0; j < Module_ndacs; j++) {
if (Module_GetTopDACValue(&modules[i], j) < 0) { if (Module_GetTopDACValue(&modules[i], j) < 0) {
LOG(logERROR, LOG(logERROR,
("module %d's top \"%s\" dac is not set.\n", ("module %d's top \"%s\" dac is not set.\n",
@ -511,8 +502,7 @@ unsigned int Feb_Control_GetNModules() {
unsigned int Feb_Control_GetNHalfModules() { unsigned int Feb_Control_GetNHalfModules() {
unsigned int n_half_modules = 0; unsigned int n_half_modules = 0;
unsigned int i; for (unsigned int i = 1; i < moduleSize; i++) {
for (i = 1; i < moduleSize; i++) {
if (Module_TopAddressIsValid(&modules[i])) if (Module_TopAddressIsValid(&modules[i]))
n_half_modules++; n_half_modules++;
if (Module_BottomAddressIsValid(&modules[i])) if (Module_BottomAddressIsValid(&modules[i]))
@ -536,7 +526,6 @@ int Feb_Control_SetIDelays(unsigned int module_num, unsigned int ndelay_units) {
int Feb_Control_SetIDelays1( int Feb_Control_SetIDelays1(
unsigned int module_num, unsigned int chip_pos, unsigned int module_num, unsigned int chip_pos,
unsigned int ndelay_units) { // chip_pos 0=ll,1=lr,0=rl,1=rr unsigned int ndelay_units) { // chip_pos 0=ll,1=lr,0=rl,1=rr
unsigned int i;
// currently set same for top and bottom // currently set same for top and bottom
if (chip_pos > 3) { if (chip_pos > 3) {
LOG(logERROR, ("SetIDelay chip_pos %d doesn't exist.\n", chip_pos)); LOG(logERROR, ("SetIDelay chip_pos %d doesn't exist.\n", chip_pos));
@ -560,10 +549,10 @@ int Feb_Control_SetIDelays1(
Module_SetTopIDelay(&modules[module_index], chip_pos, Module_SetTopIDelay(&modules[module_index], chip_pos,
ndelay_units); ndelay_units);
else { else {
for (i = 0; i < moduleSize; i++) for (unsigned int i = 0; i < moduleSize; i++)
Module_SetTopIDelay(&modules[i], chip_pos, Module_SetTopIDelay(&modules[i], chip_pos,
ndelay_units); ndelay_units);
for (i = 0; i < moduleSize; i++) for (unsigned int i = 0; i < moduleSize; i++)
Module_SetBottomIDelay(&modules[i], chip_pos, Module_SetBottomIDelay(&modules[i], chip_pos,
ndelay_units); ndelay_units);
} }
@ -582,10 +571,10 @@ int Feb_Control_SetIDelays1(
Module_SetBottomIDelay(&modules[module_index], chip_pos, Module_SetBottomIDelay(&modules[module_index], chip_pos,
ndelay_units); ndelay_units);
else { else {
for (i = 0; i < moduleSize; i++) for (unsigned int i = 0; i < moduleSize; i++)
Module_SetTopIDelay(&modules[i], chip_pos, Module_SetTopIDelay(&modules[i], chip_pos,
ndelay_units); ndelay_units);
for (i = 0; i < moduleSize; i++) for (unsigned int i = 0; i < moduleSize; i++)
Module_SetBottomIDelay(&modules[i], chip_pos, Module_SetBottomIDelay(&modules[i], chip_pos,
ndelay_units); ndelay_units);
} }
@ -605,7 +594,7 @@ int Feb_Control_SetIDelays1(
Module_SetTopIDelay(&modules[module_index], chip_pos, Module_SetTopIDelay(&modules[module_index], chip_pos,
ndelay_units); ndelay_units);
else else
for (i = 0; i < moduleSize; i++) for (unsigned int i = 0; i < moduleSize; i++)
Module_SetTopIDelay(&modules[i], chip_pos, Module_SetTopIDelay(&modules[i], chip_pos,
ndelay_units); ndelay_units);
} else { } else {
@ -623,7 +612,7 @@ int Feb_Control_SetIDelays1(
Module_SetBottomIDelay(&modules[module_index], chip_pos, Module_SetBottomIDelay(&modules[module_index], chip_pos,
ndelay_units); ndelay_units);
else else
for (i = 0; i < moduleSize; i++) for (unsigned int i = 0; i < moduleSize; i++)
Module_SetBottomIDelay(&modules[i], chip_pos, Module_SetBottomIDelay(&modules[i], chip_pos,
ndelay_units); ndelay_units);
} else { } else {
@ -930,7 +919,6 @@ int Feb_Control_DecodeDACString(char *dac_str, unsigned int *module_index,
} }
int Feb_Control_SetDAC(char *dac_str, int value, int is_a_voltage_mv) { int Feb_Control_SetDAC(char *dac_str, int value, int is_a_voltage_mv) {
unsigned int i;
unsigned int module_index, dac_ch; unsigned int module_index, dac_ch;
int top, bottom; int top, bottom;
if (!Feb_Control_DecodeDACString(dac_str, &module_index, &top, &bottom, if (!Feb_Control_DecodeDACString(dac_str, &module_index, &top, &bottom,
@ -958,7 +946,7 @@ int Feb_Control_SetDAC(char *dac_str, int value, int is_a_voltage_mv) {
if (module_index != 0) if (module_index != 0)
Module_SetTopDACValue(&modules[module_index], dac_ch, v); Module_SetTopDACValue(&modules[module_index], dac_ch, v);
else else
for (i = 0; i < moduleSize; i++) for (unsigned int i = 0; i < moduleSize; i++)
Module_SetTopDACValue(&modules[i], dac_ch, v); Module_SetTopDACValue(&modules[i], dac_ch, v);
} }
@ -970,7 +958,7 @@ int Feb_Control_SetDAC(char *dac_str, int value, int is_a_voltage_mv) {
if (module_index != 0) if (module_index != 0)
Module_SetBottomDACValue(&modules[module_index], dac_ch, v); Module_SetBottomDACValue(&modules[module_index], dac_ch, v);
else else
for (i = 0; i < moduleSize; i++) for (unsigned int i = 0; i < moduleSize; i++)
Module_SetBottomDACValue(&modules[i], dac_ch, v); Module_SetBottomDACValue(&modules[i], dac_ch, v);
} }
@ -1004,8 +992,7 @@ int Feb_Control_GetDACName(unsigned int dac_num, char *s) {
} }
int Feb_Control_GetDACNumber(char *s, unsigned int *n) { int Feb_Control_GetDACNumber(char *s, unsigned int *n) {
unsigned int i; for (unsigned int i = 0; i < Module_ndacs; i++) {
for (i = 0; i < Module_ndacs; i++) {
if (!strcmp(Module_dac_names[i], s)) { if (!strcmp(Module_dac_names[i], s)) {
*n = i; *n = i;
return 1; return 1;
@ -1051,10 +1038,6 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits,
int top) { int top) {
LOG(logINFO, ("Setting Trimbits\n")); LOG(logINFO, ("Setting Trimbits\n"));
// for (int iy=10000;iy<20020;++iy)//263681
// for (int iy=263670;iy<263680;++iy)//263681
// LOG(logINFO, ("%d:%c\t\t",iy,trimbits[iy]));
unsigned int trimbits_to_load_l[1024]; unsigned int trimbits_to_load_l[1024];
unsigned int trimbits_to_load_r[1024]; unsigned int trimbits_to_load_r[1024];
@ -1067,8 +1050,7 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits,
if (Feb_Control_Reset() == STATUS_ERROR) { if (Feb_Control_Reset() == STATUS_ERROR) {
LOG(logERROR, ("could not reset DAQ.\n")); LOG(logERROR, ("could not reset DAQ.\n"));
} }
int l_r; for (int l_r = 0; l_r < 2; l_r++) { // l_r loop
for (l_r = 0; l_r < 2; l_r++) { // l_r loop
unsigned int disable_chip_mask = unsigned int disable_chip_mask =
l_r ? DAQ_CS_BAR_LEFT : DAQ_CS_BAR_RIGHT; l_r ? DAQ_CS_BAR_LEFT : DAQ_CS_BAR_RIGHT;
if (Feb_Control_activated) { if (Feb_Control_activated) {
@ -1085,8 +1067,7 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits,
} }
} }
int row_set; for (int row_set = 0; row_set < 16; row_set++) { // 16 rows at a time
for (row_set = 0; row_set < 16; row_set++) { // 16 rows at a time
if (row_set == 0) { if (row_set == 0) {
if (!Feb_Control_SetCommandRegister( if (!Feb_Control_SetCommandRegister(
DAQ_RESET_COMPLETELY | DAQ_SEND_A_TOKEN_IN | DAQ_RESET_COMPLETELY | DAQ_SEND_A_TOKEN_IN |
@ -1104,11 +1085,9 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits,
} }
} }
int row; for (int row = 0; row < 16; row++) { // row loop
for (row = 0; row < 16; row++) { // row loop
int offset = 2 * 32 * row; int offset = 2 * 32 * row;
int sc; for (int sc = 0; sc < 32; sc++) { // supercolumn loop sc
for (sc = 0; sc < 32; sc++) { // supercolumn loop sc
int super_column_start_position_l = int super_column_start_position_l =
1030 * row + l_r * 258 + sc * 8; 1030 * row + l_r * 258 + sc * 8;
int super_column_start_position_r = int super_column_start_position_r =
@ -1125,8 +1104,7 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits,
trimbits_to_load_r[offset + chip_sc] = 0; trimbits_to_load_r[offset + chip_sc] = 0;
trimbits_to_load_l[offset + chip_sc + 32] = 0; trimbits_to_load_l[offset + chip_sc + 32] = 0;
trimbits_to_load_r[offset + chip_sc + 32] = 0; trimbits_to_load_r[offset + chip_sc + 32] = 0;
int i; for (int i = 0; i < 8; i++) { // column loop i
for (i = 0; i < 8; i++) { // column loop i
if (top == 1) { if (top == 1) {
trimbits_to_load_l[offset + chip_sc] |= trimbits_to_load_l[offset + chip_sc] |=
@ -1865,8 +1843,7 @@ int Feb_Control_StartAcquisition() {
static unsigned int reg_nums[20]; static unsigned int reg_nums[20];
static unsigned int reg_vals[20]; static unsigned int reg_vals[20];
int i; for (int i = 0; i < 14; i++) {
for (i = 0; i < 14; i++) {
reg_nums[i] = DAQ_REG_CTRL; reg_nums[i] = DAQ_REG_CTRL;
reg_vals[i] = 0; reg_vals[i] = 0;
} }
@ -1888,8 +1865,7 @@ int Feb_Control_StopAcquisition() { return Feb_Control_Reset(); }
int Feb_Control_SaveAllTrimbitsTo(int value, int top) { int Feb_Control_SaveAllTrimbitsTo(int value, int top) {
unsigned int chanregs[Feb_Control_trimbit_size]; unsigned int chanregs[Feb_Control_trimbit_size];
int i; for (int i = 0; i < Feb_Control_trimbit_size; i++)
for (i = 0; i < Feb_Control_trimbit_size; i++)
chanregs[i] = value; chanregs[i] = value;
return Feb_Control_SetTrimbits(0, chanregs, top); return Feb_Control_SetTrimbits(0, chanregs, top);
} }
@ -1902,7 +1878,6 @@ int Feb_Control_Pulse_Pixel(int npulses, int x, int y) {
// this function is not designed for speed // this function is not designed for speed
int pulse_multiple = 0; // has to be 0 or 1 int pulse_multiple = 0; // has to be 0 or 1
int i;
if (x < 0) { if (x < 0) {
x = -x; x = -x;
@ -1939,7 +1914,7 @@ int Feb_Control_Pulse_Pixel(int npulses, int x, int y) {
if (!pulse_multiple) if (!pulse_multiple)
serial_in = 0; serial_in = 0;
for (i = 0; i < x / 8; i++) for (int i = 0; i < x / 8; i++)
Feb_Control_Shift32InSerialIn(serial_in); Feb_Control_Shift32InSerialIn(serial_in);
Feb_Control_SendTokenIn(); Feb_Control_SendTokenIn();
@ -2015,7 +1990,6 @@ int Feb_Control_ClockRowClock(unsigned int ntimes) {
} }
int Feb_Control_PulseChip(int npulses) { int Feb_Control_PulseChip(int npulses) {
int i;
int on = 1; int on = 1;
if (npulses == -1) { if (npulses == -1) {
@ -2030,7 +2004,7 @@ int Feb_Control_PulseChip(int npulses) {
Feb_Control_SetStaticBits(); // toggle the enable 2x times Feb_Control_SetStaticBits(); // toggle the enable 2x times
Feb_Control_ResetChipCompletely(); Feb_Control_ResetChipCompletely();
for (i = 0; i < npulses; i++) { for (int i = 0; i < npulses; i++) {
if (!Feb_Control_SetCommandRegister( if (!Feb_Control_SetCommandRegister(
DAQ_CHIP_CONTROLLER_SUPER_SLOW_SPEED | DAQ_RESET_PERIPHERY | DAQ_CHIP_CONTROLLER_SUPER_SLOW_SPEED | DAQ_RESET_PERIPHERY |
DAQ_RESET_COLUMN_SELECT)) { DAQ_RESET_COLUMN_SELECT)) {
@ -2092,8 +2066,7 @@ int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec) {
tau_in_sec, period_in_sec)); tau_in_sec, period_in_sec));
LOG(logINFO, ("\tCalculating table for tau of %lld ns.\n", tau_in_Nsec)); LOG(logINFO, ("\tCalculating table for tau of %lld ns.\n", tau_in_Nsec));
int i; for (int i = 0; i < np; i++) {
for (i = 0; i < np; i++) {
Feb_Control_rate_meas[i] = i * exp(-i / period_in_sec * tau_in_sec); Feb_Control_rate_meas[i] = i * exp(-i / period_in_sec * tau_in_sec);
if (Feb_Control_rate_meas[i] > ratemax) if (Feb_Control_rate_meas[i] > ratemax)
ratemax = Feb_Control_rate_meas[i]; ratemax = Feb_Control_rate_meas[i];
@ -2123,8 +2096,7 @@ int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec) {
Feb_Control_rate_correction_table[0] = Feb_Control_rate_correction_table[0] =
(((int)(m[0] + 0.5) & 0xf) << 14) | ((int)(b0[0] + 0.5) & 0x3fff); (((int)(m[0] + 0.5) & 0xf) << 14) | ((int)(b0[0] + 0.5) & 0x3fff);
int b = 0; for (int b = 1; b < 1024; b++) {
for (b = 1; b < 1024; b++) {
if (m[b - 1] < 15) { if (m[b - 1] < 15) {
double s = 0, sx = 0, sy = 0, sxx = 0, sxy = 0; double s = 0, sx = 0, sy = 0, sxx = 0, sxy = 0;
for (;; next_i++) { for (;; next_i++) {
@ -2278,9 +2250,8 @@ void Feb_Control_SetRateCorrectionVariable(int activate_rate_correction) {
} }
int Feb_Control_PrintCorrectedValues() { int Feb_Control_PrintCorrectedValues() {
int i;
int delta, slope, base, lsb, corr; int delta, slope, base, lsb, corr;
for (i = 0; i < 4096; i++) { for (int i = 0; i < 4096; i++) {
lsb = i & 3; lsb = i & 3;
base = Feb_Control_rate_correction_table[i >> 2] & 0x3fff; base = Feb_Control_rate_correction_table[i >> 2] & 0x3fff;
slope = ((Feb_Control_rate_correction_table[i >> 2] & 0x3c000) >> 14); slope = ((Feb_Control_rate_correction_table[i >> 2] & 0x3c000) >> 14);
@ -2400,8 +2371,7 @@ int Feb_Control_SetInterruptSubframe(int val) {
? Module_GetTopLeftAddress(&modules[1]) ? Module_GetTopLeftAddress(&modules[1])
: Module_GetBottomLeftAddress(&modules[1]); : Module_GetBottomLeftAddress(&modules[1]);
int iloop = 0; for (int iloop = 0; iloop < 2; ++iloop) {
for (iloop = 0; iloop < 2; ++iloop) {
// get previous value to keep it // get previous value to keep it
if (!Feb_Interface_ReadRegister(addr[iloop], offset, &regVal)) { if (!Feb_Interface_ReadRegister(addr[iloop], offset, &regVal)) {
LOG(logERROR, ("Could not read %s %s interrupt subframe\n", isTop, LOG(logERROR, ("Could not read %s %s interrupt subframe\n", isTop,
@ -2438,8 +2408,7 @@ int Feb_Control_GetInterruptSubframe() {
: Module_GetBottomLeftAddress(&modules[1]); : Module_GetBottomLeftAddress(&modules[1]);
uint32_t value[2] = {0, 0}; uint32_t value[2] = {0, 0};
int iloop = 0; for (int iloop = 0; iloop < 2; ++iloop) {
for (iloop = 0; iloop < 2; ++iloop) {
if (!Feb_Interface_ReadRegister(addr[iloop], offset, &regVal)) { if (!Feb_Interface_ReadRegister(addr[iloop], offset, &regVal)) {
LOG(logERROR, ("Could not read back %s %s interrupt subframe\n", LOG(logERROR, ("Could not read back %s %s interrupt subframe\n",
isTop, side[iloop])); isTop, side[iloop]));
@ -2469,8 +2438,7 @@ int Feb_Control_SetTop(enum TOPINDEX ind, int left, int right) {
addr[1] = Module_GetTopRightAddress(&modules[1]); addr[1] = Module_GetTopRightAddress(&modules[1]);
} }
char *top_names[] = {TOP_NAMES}; char *top_names[] = {TOP_NAMES};
int i = 0; for (int i = 0; i < 2; ++i) {
for (i = 0; i < 2; ++i) {
if (addr[i] == 0) { if (addr[i] == 0) {
continue; continue;
} }
@ -2518,8 +2486,7 @@ int Feb_Control_SetMaster(enum MASTERINDEX ind) {
addr[0] = Module_GetTopLeftAddress(&modules[1]); addr[0] = Module_GetTopLeftAddress(&modules[1]);
addr[1] = Module_GetTopRightAddress(&modules[1]); addr[1] = Module_GetTopRightAddress(&modules[1]);
char *master_names[] = {MASTER_NAMES}; char *master_names[] = {MASTER_NAMES};
int i = 0; for (int i = 0; i < 2; ++i) {
for (i = 0; i < 2; ++i) {
uint32_t value = 0; uint32_t value = 0;
if (!Feb_Interface_ReadRegister(addr[i], offset, &value)) { if (!Feb_Interface_ReadRegister(addr[i], offset, &value)) {
LOG(logERROR, ("Could not read %s Feb reg to set Master flag\n", LOG(logERROR, ("Could not read %s Feb reg to set Master flag\n",
@ -2617,8 +2584,7 @@ int Feb_Control_WriteRegister(uint32_t offset, uint32_t data) {
actualOffset = offset - 0x100; actualOffset = offset - 0x100;
} }
int iloop = 0; for (int iloop = 0; iloop < 2; ++iloop) {
for (iloop = 0; iloop < 2; ++iloop) {
if (run[iloop]) { if (run[iloop]) {
LOG(logINFO, ("Writing 0x%x to %s %s 0x%x\n", data, isTop, LOG(logINFO, ("Writing 0x%x to %s %s 0x%x\n", data, isTop,
side[iloop], actualOffset)); side[iloop], actualOffset));
@ -2666,8 +2632,7 @@ int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval) {
actualOffset = offset - 0x100; actualOffset = offset - 0x100;
} }
int iloop = 0; for (int iloop = 0; iloop < 2; ++iloop) {
for (iloop = 0; iloop < 2; ++iloop) {
if (run[iloop]) { if (run[iloop]) {
if (!Feb_Interface_ReadRegister(addr[iloop], actualOffset, if (!Feb_Interface_ReadRegister(addr[iloop], actualOffset,
&value[iloop])) { &value[iloop])) {

View File

@ -42,12 +42,11 @@ void Feb_Interface_FebInterface() {
} }
void Feb_Interface_SendCompleteList(unsigned int n, unsigned int *list) { void Feb_Interface_SendCompleteList(unsigned int n, unsigned int *list) {
unsigned int i;
if (Feb_Interface_feb_numb) if (Feb_Interface_feb_numb)
free(Feb_Interface_feb_numb); free(Feb_Interface_feb_numb);
Feb_Interface_nfebs = n; Feb_Interface_nfebs = n;
Feb_Interface_feb_numb = malloc(n * sizeof(unsigned int)); Feb_Interface_feb_numb = malloc(n * sizeof(unsigned int));
for (i = 0; i < n; i++) for (unsigned int i = 0; i < n; i++)
Feb_Interface_feb_numb[i] = list[i]; Feb_Interface_feb_numb[i] = list[i];
} }
@ -72,7 +71,6 @@ int Feb_Interface_WriteTo(unsigned int ch) {
} }
int Feb_Interface_ReadFrom(unsigned int ch, unsigned int ntrys) { int Feb_Interface_ReadFrom(unsigned int ch, unsigned int ntrys) {
unsigned int t;
if (ch >= 0xfff) if (ch >= 0xfff)
return 0; return 0;
@ -81,7 +79,7 @@ int Feb_Interface_ReadFrom(unsigned int ch, unsigned int ntrys) {
usleep(20); usleep(20);
Feb_Interface_recv_ndata = -1; Feb_Interface_recv_ndata = -1;
for (t = 0; t < ntrys; t++) { for (unsigned int t = 0; t < ntrys; t++) {
if ((Feb_Interface_recv_ndata = if ((Feb_Interface_recv_ndata =
Local_Read(ll, Feb_Interface_recv_buffer_size * 4, Local_Read(ll, Feb_Interface_recv_buffer_size * 4,
Feb_Interface_recv_data_raw) / Feb_Interface_recv_data_raw) /
@ -102,9 +100,8 @@ int Feb_Interface_SetByteOrder() {
Feb_Interface_send_ndata = 2; Feb_Interface_send_ndata = 2;
Feb_Interface_send_data[0] = 0; Feb_Interface_send_data[0] = 0;
Feb_Interface_send_data[1] = 0; Feb_Interface_send_data[1] = 0;
unsigned int i;
unsigned int dst = 0xff; unsigned int dst = 0xff;
for (i = 0; i < Feb_Interface_nfebs; i++) for (unsigned int i = 0; i < Feb_Interface_nfebs; i++)
dst = (dst | Feb_Interface_feb_numb[i]); dst = (dst | Feb_Interface_feb_numb[i]);
int passed = Feb_Interface_WriteTo(dst); int passed = Feb_Interface_WriteTo(dst);
@ -119,8 +116,6 @@ int Feb_Interface_ReadRegister(unsigned int sub_num, unsigned int reg_num,
int Feb_Interface_ReadRegisters(unsigned int sub_num, unsigned int nreads, int Feb_Interface_ReadRegisters(unsigned int sub_num, unsigned int nreads,
unsigned int *reg_nums, unsigned int *reg_nums,
unsigned int *values_read) { unsigned int *values_read) {
// here cout<<"Reading Register ...."<<endl;
unsigned int i;
nreads &= 0x3ff; nreads &= 0x3ff;
if (!nreads || nreads > Feb_Interface_send_buffer_size - 2) if (!nreads || nreads > Feb_Interface_send_buffer_size - 2)
return 0; return 0;
@ -128,7 +123,7 @@ int Feb_Interface_ReadRegisters(unsigned int sub_num, unsigned int nreads,
Feb_Interface_send_ndata = nreads + 2; Feb_Interface_send_ndata = nreads + 2;
Feb_Interface_send_data[0] = 0x20000000 | nreads << 14; Feb_Interface_send_data[0] = 0x20000000 | nreads << 14;
for (i = 0; i < nreads; i++) for (unsigned int i = 0; i < nreads; i++)
Feb_Interface_send_data[i + 1] = reg_nums[i]; Feb_Interface_send_data[i + 1] = reg_nums[i];
Feb_Interface_send_data[nreads + 1] = 0; Feb_Interface_send_data[nreads + 1] = 0;
@ -137,7 +132,7 @@ int Feb_Interface_ReadRegisters(unsigned int sub_num, unsigned int nreads,
Feb_Interface_recv_ndata != (int)(nreads + 2)) Feb_Interface_recv_ndata != (int)(nreads + 2))
return 0; return 0;
for (i = 0; i < nreads; i++) for (unsigned int i = 0; i < nreads; i++)
values_read[i] = Feb_Interface_recv_data[i + 1]; values_read[i] = Feb_Interface_recv_data[i + 1];
return 1; return 1;
@ -154,7 +149,6 @@ int Feb_Interface_WriteRegisters(unsigned int sub_num, unsigned int nwrites,
unsigned int *reg_nums, unsigned int *values, unsigned int *reg_nums, unsigned int *values,
int *wait_ons, int *wait_ons,
unsigned int *wait_on_addresses) { unsigned int *wait_on_addresses) {
unsigned int i;
nwrites &= 0x3ff; // 10 bits nwrites &= 0x3ff; // 10 bits
if (!nwrites || 2 * nwrites > Feb_Interface_send_buffer_size - 2) if (!nwrites || 2 * nwrites > Feb_Interface_send_buffer_size - 2)
return 0; return 0;
@ -165,13 +159,13 @@ int Feb_Interface_WriteRegisters(unsigned int sub_num, unsigned int nwrites,
Feb_Interface_send_data[0] = 0x80000000 | nwrites << 14; Feb_Interface_send_data[0] = 0x80000000 | nwrites << 14;
Feb_Interface_send_data[2 * nwrites + 1] = 0; Feb_Interface_send_data[2 * nwrites + 1] = 0;
for (i = 0; i < nwrites; i++) for (unsigned int i = 0; i < nwrites; i++)
Feb_Interface_send_data[2 * i + 1] = 0x3fff & reg_nums[i]; Feb_Interface_send_data[2 * i + 1] = 0x3fff & reg_nums[i];
for (i = 0; i < nwrites; i++) for (unsigned int i = 0; i < nwrites; i++)
Feb_Interface_send_data[2 * i + 2] = values[i]; Feb_Interface_send_data[2 * i + 2] = values[i];
// wait on busy data(28), address of busy flag data(27 downto 14) // wait on busy data(28), address of busy flag data(27 downto 14)
if (wait_ons && wait_on_addresses) if (wait_ons && wait_on_addresses)
for (i = 0; i < nwrites; i++) for (unsigned int i = 0; i < nwrites; i++)
Feb_Interface_send_data[2 * i + 1] |= Feb_Interface_send_data[2 * i + 1] |=
(wait_ons[i] << 28 | (0x3fff & wait_on_addresses[i]) << 14); (wait_ons[i] << 28 | (0x3fff & wait_on_addresses[i]) << 14);
@ -211,7 +205,6 @@ int Feb_Interface_WriteMemory(unsigned int sub_num, unsigned int mem_num,
unsigned int start_address, unsigned int nwrites, unsigned int start_address, unsigned int nwrites,
unsigned int *values) { unsigned int *values) {
// -1 means write to all // -1 means write to all
unsigned int i;
mem_num &= 0x3f; mem_num &= 0x3f;
start_address &= 0x3fff; start_address &= 0x3fff;
nwrites &= 0x3ff; nwrites &= 0x3ff;
@ -226,7 +219,7 @@ int Feb_Interface_WriteMemory(unsigned int sub_num, unsigned int mem_num,
start_address; // cmd -> write to memory, nwrites, mem number, start start_address; // cmd -> write to memory, nwrites, mem number, start
// address // address
Feb_Interface_send_data[nwrites + 1] = 0; Feb_Interface_send_data[nwrites + 1] = 0;
for (i = 0; i < nwrites; i++) for (unsigned int i = 0; i < nwrites; i++)
Feb_Interface_send_data[i + 1] = values[i]; Feb_Interface_send_data[i + 1] = values[i];
if (!Feb_Interface_WriteTo(sub_num)) if (!Feb_Interface_WriteTo(sub_num))

View File

@ -81,7 +81,6 @@ int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
// note: buffer must be word (4 byte) aligned // note: buffer must be word (4 byte) aligned
// frame_len in byte // frame_len in byte
int vacancy = 0; int vacancy = 0;
int i;
int words_send = 0; int words_send = 0;
int last_word; int last_word;
unsigned int *word_ptr; unsigned int *word_ptr;
@ -96,7 +95,7 @@ int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
LOG(logDEBUG1, ("LL Write - Len: %2d - If: %X - Data: ", buffer_len, LOG(logDEBUG1, ("LL Write - Len: %2d - If: %X - Data: ", buffer_len,
ll->ll_fifo_base)); ll->ll_fifo_base));
for (i = 0; i < buffer_len / 4; i++) for (int i = 0; i < buffer_len / 4; i++)
LOG(logDEBUG1, ("%.8X ", *(((unsigned *)buffer) + i))); LOG(logDEBUG1, ("%.8X ", *(((unsigned *)buffer) + i)));
while (words_send <= last_word) { while (words_send <= last_word) {
@ -112,8 +111,8 @@ int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
} }
// Just to know: #define PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS 100 // Just to know: #define PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS 100
for (i = 0; ((i < PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS) && for (int i = 0; ((i < PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS) &&
(words_send <= last_word)); (words_send <= last_word));
i++) { i++) {
fifo_ctrl = 0; fifo_ctrl = 0;
if (words_send == 0) { if (words_send == 0) {

View File

@ -6,7 +6,7 @@ support_lib = ../../slsSupportLib/include/
BLACKFIN_CC = bfin-uclinux-gcc BLACKFIN_CC = bfin-uclinux-gcc
CROSS = powerpc-4xx-softfloat- CROSS = powerpc-4xx-softfloat-
CC = $(CROSS)gcc CC = $(CROSS)gcc
CFLAGS += -Wall -DEIGERD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE CFLAGS += -Wall -std=gnu99 -DEIGERD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
LDLIBS += -lm LDLIBS += -lm
PROGS = eigerDetectorServer PROGS = eigerDetectorServer
DESTDIR = bin DESTDIR = bin

View File

@ -639,8 +639,7 @@ void allocateDetectorStructureMemory() {
thisSettings = UNINITIALIZED; thisSettings = UNINITIALIZED;
// if trimval requested, should return -1 to acknowledge unknown // if trimval requested, should return -1 to acknowledge unknown
int ichan = 0; for (int ichan = 0; ichan < (detectorModules->nchan); ichan++) {
for (ichan = 0; ichan < (detectorModules->nchan); ichan++) {
*((detectorModules->chanregs) + ichan) = -1; *((detectorModules->chanregs) + ichan) = -1;
} }
} }
@ -651,9 +650,8 @@ void setupDetector() {
// set dacs // set dacs
LOG(logINFOBLUE, ("Setting Default Dac values\n")); LOG(logINFOBLUE, ("Setting Default Dac values\n"));
{ {
int i = 0;
const int defaultvals[NDAC] = DEFAULT_DAC_VALS; const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
for (i = 0; i < NDAC; ++i) { for (int i = 0; i < NDAC; ++i) {
setDAC((enum DACINDEX)i, defaultvals[i], 0); setDAC((enum DACINDEX)i, defaultvals[i], 0);
if ((detectorModules)->dacs[i] != defaultvals[i]) { if ((detectorModules)->dacs[i] != defaultvals[i]) {
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i, LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
@ -748,8 +746,7 @@ int setDynamicRange(int dr) {
#ifndef VIRTUAL #ifndef VIRTUAL
if (Feb_Control_SetDynamicRange(dr)) { if (Feb_Control_SetDynamicRange(dr)) {
on_dst = 0; on_dst = 0;
int i; for (int i = 0; i < 32; ++i)
for (i = 0; i < 32; i++)
dst_requested[i] = 0; // clear dst requested dst_requested[i] = 0; // clear dst requested
if (!Beb_SetUpTransferParameters(dr)) { if (!Beb_SetUpTransferParameters(dr)) {
LOG(logERROR, ("Could not set bit mode in the back end\n")); LOG(logERROR, ("Could not set bit mode in the back end\n"));
@ -829,8 +826,7 @@ void setNumFrames(int64_t val) {
if (Feb_Control_SetNExposures((unsigned int)val * eiger_ntriggers)) { if (Feb_Control_SetNExposures((unsigned int)val * eiger_ntriggers)) {
eiger_nexposures = val; eiger_nexposures = val;
on_dst = 0; on_dst = 0;
int i; for (int i = 0; i < 32; ++i)
for (i = 0; i < 32; i++)
dst_requested[i] = 0; // clear dst requested dst_requested[i] = 0; // clear dst requested
ndsts_in_use = 1; ndsts_in_use = 1;
nimages_per_request = eiger_nexposures * eiger_ntriggers; nimages_per_request = eiger_nexposures * eiger_ntriggers;
@ -851,8 +847,7 @@ void setNumTriggers(int64_t val) {
if (Feb_Control_SetNExposures((unsigned int)val * eiger_nexposures)) { if (Feb_Control_SetNExposures((unsigned int)val * eiger_nexposures)) {
eiger_ntriggers = val; eiger_ntriggers = val;
on_dst = 0; on_dst = 0;
int i; for (int i = 0; i < 32; ++i)
for (i = 0; i < 32; i++)
dst_requested[i] = 0; // clear dst requested dst_requested[i] = 0; // clear dst requested
nimages_per_request = eiger_nexposures * eiger_ntriggers; nimages_per_request = eiger_nexposures * eiger_ntriggers;
} }
@ -1021,18 +1016,14 @@ int setModule(sls_detector_module myMod, char *mess) {
} }
// dacs // dacs
{ for (int i = 0; i < NDAC; ++i) {
int i = 0; setDAC((enum DACINDEX)i, myMod.dacs[i], 0);
for (i = 0; i < NDAC; ++i) { if (myMod.dacs[i] != (detectorModules)->dacs[i]) {
setDAC((enum DACINDEX)i, myMod.dacs[i], 0); sprintf(mess, "Could not set module. Could not set dac %d\n", i);
if (myMod.dacs[i] != (detectorModules)->dacs[i]) { LOG(logERROR, (mess));
sprintf(mess, "Could not set module. Could not set dac %d\n", setSettings(UNDEFINED);
i); LOG(logERROR, ("Settings has been changed to undefined\n"));
LOG(logERROR, (mess)); return FAIL;
setSettings(UNDEFINED);
LOG(logERROR, ("Settings has been changed to undefined\n"));
return FAIL;
}
} }
} }
@ -1044,10 +1035,10 @@ int setModule(sls_detector_module myMod, char *mess) {
LOG(logINFO, ("Setting module with trimbits\n")); LOG(logINFO, ("Setting module with trimbits\n"));
// includ gap pixels // includ gap pixels
unsigned int tt[263680]; unsigned int tt[263680];
int iy, ichip, ix, ip = 0, ich = 0; int ip = 0, ich = 0;
for (iy = 0; iy < 256; ++iy) { for (int iy = 0; iy < 256; ++iy) {
for (ichip = 0; ichip < 4; ++ichip) { for (int ichip = 0; ichip < 4; ++ichip) {
for (ix = 0; ix < 256; ++ix) { for (int ix = 0; ix < 256; ++ix) {
tt[ip++] = myMod.chanregs[ich++]; tt[ip++] = myMod.chanregs[ich++];
} }
if (ichip < 3) { if (ichip < 3) {
@ -1121,10 +1112,10 @@ int getModule(sls_detector_module *myMod) {
tt = Feb_Control_GetTrimbits(); tt = Feb_Control_GetTrimbits();
// exclude gap pixels // exclude gap pixels
int iy, ichip, ix, ip = 0, ich = 0; int ip = 0, ich = 0;
for (iy = 0; iy < 256; ++iy) { for (int iy = 0; iy < 256; ++iy) {
for (ichip = 0; ichip < 4; ++ichip) { for (int ichip = 0; ichip < 4; ++ichip) {
for (ix = 0; ix < 256; ++iy) { for (int ix = 0; ix < 256; ++iy) {
myMod->chanregs[ich++] = tt[ip++]; myMod->chanregs[ich++] = tt[ip++];
} }
if (ichip < 3) { if (ichip < 3) {
@ -1432,37 +1423,32 @@ int configureMAC() {
if (!top) if (!top)
dst_port = dstport2; dst_port = dstport2;
int i = 0;
/* for(i=0;i<32;i++) { modified for Aldo*/
if (Beb_SetBebSrcHeaderInfos(beb_num, send_to_ten_gig, src_mac, src_ip, if (Beb_SetBebSrcHeaderInfos(beb_num, send_to_ten_gig, src_mac, src_ip,
srcport) && srcport) &&
Beb_SetUpUDPHeader(beb_num, send_to_ten_gig, header_number + i, dst_mac, Beb_SetUpUDPHeader(beb_num, send_to_ten_gig, header_number, dst_mac,
dst_ip, dst_port)) { dst_ip, dst_port)) {
LOG(logDEBUG1, ("\tset up left ok\n")); LOG(logDEBUG1, ("\tset up left ok\n"));
} else { } else {
return FAIL; return FAIL;
} }
/*}*/
header_number = 32; header_number = 32;
dst_port = dstport2; dst_port = dstport2;
if (!top) if (!top)
dst_port = dstport; dst_port = dstport;
/*for(i=0;i<32;i++) {*/ /** modified for Aldo*/
if (Beb_SetBebSrcHeaderInfos(beb_num, send_to_ten_gig, src_mac, src_ip, if (Beb_SetBebSrcHeaderInfos(beb_num, send_to_ten_gig, src_mac, src_ip,
srcport) && srcport) &&
Beb_SetUpUDPHeader(beb_num, send_to_ten_gig, header_number + i, dst_mac, Beb_SetUpUDPHeader(beb_num, send_to_ten_gig, header_number, dst_mac,
dst_ip, dst_port)) { dst_ip, dst_port)) {
LOG(logDEBUG1, (" set up right ok\n")); LOG(logDEBUG1, (" set up right ok\n"));
} else { } else {
return FAIL; return FAIL;
} }
/*}*/
on_dst = 0; on_dst = 0;
for (i = 0; i < 32; i++) for (int i = 0; i < 32; ++i)
dst_requested[i] = 0; // clear dst requested dst_requested[i] = 0; // clear dst requested
nimages_per_request = eiger_nexposures * eiger_ntriggers; nimages_per_request = eiger_nexposures * eiger_ntriggers;
#endif #endif
@ -1849,8 +1835,7 @@ int setAllTrimbits(int val) {
} }
#endif #endif
if (detectorModules) { if (detectorModules) {
int ichan; for (int ichan = 0; ichan < (detectorModules->nchan); ichan++) {
for (ichan = 0; ichan < (detectorModules->nchan); ichan++) {
*((detectorModules->chanregs) + ichan) = val; *((detectorModules->chanregs) + ichan) = val;
} }
} }
@ -1860,10 +1845,9 @@ int setAllTrimbits(int val) {
} }
int getAllTrimbits() { int getAllTrimbits() {
int ichan = 0;
int value = *((detectorModules->chanregs)); int value = *((detectorModules->chanregs));
if (detectorModules) { if (detectorModules) {
for (ichan = 0; ichan < (detectorModules->nchan); ichan++) { for (int ichan = 0; ichan < (detectorModules->nchan); ichan++) {
if (*((detectorModules->chanregs) + ichan) != value) { if (*((detectorModules->chanregs) + ichan) != value) {
value = -1; value = -1;
break; break;
@ -2094,10 +2078,9 @@ void *start_timer(void *arg) {
char imageData[databytes * 2]; char imageData[databytes * 2];
memset(imageData, 0, databytes * 2); memset(imageData, 0, databytes * 2);
{ {
int i = 0;
switch (dr) { switch (dr) {
case 4: case 4:
for (i = 0; i < ntotpixels / 2; ++i) { for (int i = 0; i < ntotpixels / 2; ++i) {
*((uint8_t *)(imageData + i)) = *((uint8_t *)(imageData + i)) =
eiger_virtual_test_mode eiger_virtual_test_mode
? 0xEE ? 0xEE
@ -2105,19 +2088,19 @@ void *start_timer(void *arg) {
} }
break; break;
case 8: case 8:
for (i = 0; i < ntotpixels; ++i) { for (int i = 0; i < ntotpixels; ++i) {
*((uint8_t *)(imageData + i)) = *((uint8_t *)(imageData + i)) =
eiger_virtual_test_mode ? 0xFE : (uint8_t)i; eiger_virtual_test_mode ? 0xFE : (uint8_t)i;
} }
break; break;
case 16: case 16:
for (i = 0; i < ntotpixels; ++i) { for (int i = 0; i < ntotpixels; ++i) {
*((uint16_t *)(imageData + i * sizeof(uint16_t))) = *((uint16_t *)(imageData + i * sizeof(uint16_t))) =
eiger_virtual_test_mode ? 0xFFE : (uint16_t)i; eiger_virtual_test_mode ? 0xFFE : (uint16_t)i;
} }
break; break;
case 32: case 32:
for (i = 0; i < ntotpixels; ++i) { for (int i = 0; i < ntotpixels; ++i) {
*((uint32_t *)(imageData + i * sizeof(uint32_t))) = *((uint32_t *)(imageData + i * sizeof(uint32_t))) =
eiger_virtual_test_mode ? 0xFFFFFE : (uint32_t)i; eiger_virtual_test_mode ? 0xFFFFFE : (uint32_t)i;
} }
@ -2132,8 +2115,7 @@ void *start_timer(void *arg) {
uint64_t frameNr = 0; uint64_t frameNr = 0;
getStartingFrameNumber(&frameNr); getStartingFrameNumber(&frameNr);
// loop over number of frames // loop over number of frames
int iframes = 0; for (int iframes = 0; iframes != numFrames; ++iframes) {
for (iframes = 0; iframes != numFrames; ++iframes) {
usleep(eiger_virtual_transmission_delay_frame); usleep(eiger_virtual_transmission_delay_frame);
@ -2154,76 +2136,72 @@ void *start_timer(void *arg) {
int srcOffset2 = npixelsx; int srcOffset2 = npixelsx;
// loop packet // loop packet
{ for (int i = 0; i != numPacketsPerFrame; ++i) {
int i = 0; // set header
for (i = 0; i != numPacketsPerFrame; ++i) { char packetData[packetsize];
// set header memset(packetData, 0, packetsize);
char packetData[packetsize]; sls_detector_header *header =
memset(packetData, 0, packetsize); (sls_detector_header *)(packetData);
sls_detector_header *header = header->detType = (uint16_t)myDetectorType;
(sls_detector_header *)(packetData); header->version = SLS_DETECTOR_HEADER_VERSION;
header->detType = (uint16_t)myDetectorType; header->frameNumber = frameNr + iframes;
header->version = SLS_DETECTOR_HEADER_VERSION; header->packetNumber = i;
header->frameNumber = frameNr + iframes; header->row = row;
header->packetNumber = i; header->column = colLeft;
header->row = row;
header->column = colLeft;
char packetData2[packetsize]; char packetData2[packetsize];
memset(packetData2, 0, packetsize); memset(packetData2, 0, packetsize);
header = (sls_detector_header *)(packetData2); header = (sls_detector_header *)(packetData2);
header->detType = (uint16_t)myDetectorType; header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION; header->version = SLS_DETECTOR_HEADER_VERSION;
header->frameNumber = frameNr + iframes; header->frameNumber = frameNr + iframes;
header->packetNumber = i; header->packetNumber = i;
header->row = row; header->row = row;
header->column = colRight; header->column = colRight;
if (eiger_virtual_quad_mode) { if (eiger_virtual_quad_mode) {
header->row = 1; // right is next row header->row = 1; // right is next row
header->column = 0; // right same first column header->column = 0; // right same first column
} }
// fill data // fill data
int dstOffset = sizeof(sls_detector_header); int dstOffset = sizeof(sls_detector_header);
int dstOffset2 = sizeof(sls_detector_header); int dstOffset2 = sizeof(sls_detector_header);
{ {
int psize = 0; for (int psize = 0; psize < datasize; psize += npixelsx) {
for (psize = 0; psize < datasize; psize += npixelsx) {
if (dr == 32 && tgEnable == 0) { if (dr == 32 && tgEnable == 0) {
memcpy(packetData + dstOffset, memcpy(packetData + dstOffset,
imageData + srcOffset, npixelsx / 2); imageData + srcOffset, npixelsx / 2);
memcpy(packetData2 + dstOffset2, memcpy(packetData2 + dstOffset2,
imageData + srcOffset2, npixelsx / 2); imageData + srcOffset2, npixelsx / 2);
if (srcOffset % npixelsx == 0) { if (srcOffset % npixelsx == 0) {
srcOffset += npixelsx / 2; srcOffset += npixelsx / 2;
srcOffset2 += npixelsx / 2; srcOffset2 += npixelsx / 2;
}
// skip the other half (2 packets in 1 line for
// 32 bit)
else {
srcOffset += npixelsx;
srcOffset2 += npixelsx;
}
dstOffset += npixelsx / 2;
dstOffset2 += npixelsx / 2;
} else {
memcpy(packetData + dstOffset,
imageData + srcOffset, npixelsx);
memcpy(packetData2 + dstOffset2,
imageData + srcOffset2, npixelsx);
srcOffset += 2 * npixelsx;
srcOffset2 += 2 * npixelsx;
dstOffset += npixelsx;
dstOffset2 += npixelsx;
} }
// skip the other half (2 packets in 1 line for
// 32 bit)
else {
srcOffset += npixelsx;
srcOffset2 += npixelsx;
}
dstOffset += npixelsx / 2;
dstOffset2 += npixelsx / 2;
} else {
memcpy(packetData + dstOffset,
imageData + srcOffset, npixelsx);
memcpy(packetData2 + dstOffset2,
imageData + srcOffset2, npixelsx);
srcOffset += 2 * npixelsx;
srcOffset2 += 2 * npixelsx;
dstOffset += npixelsx;
dstOffset2 += npixelsx;
} }
} }
usleep(eiger_virtual_transmission_delay_left);
sendUDPPacket(0, packetData, packetsize);
usleep(eiger_virtual_transmission_delay_right);
sendUDPPacket(1, packetData2, packetsize);
} }
usleep(eiger_virtual_transmission_delay_left);
sendUDPPacket(0, packetData, packetsize);
usleep(eiger_virtual_transmission_delay_right);
sendUDPPacket(1, packetData2, packetsize);
} }
LOG(logINFO, ("Sent frame: %d\n", iframes)); LOG(logINFO, ("Sent frame: %d\n", iframes));
clock_gettime(CLOCK_REALTIME, &end); clock_gettime(CLOCK_REALTIME, &end);
@ -2309,10 +2287,6 @@ int startReadOut() {
if ((ret_val = (!Beb_RequestNImages(beb_num, send_to_ten_gig, on_dst, if ((ret_val = (!Beb_RequestNImages(beb_num, send_to_ten_gig, on_dst,
nimages_per_request, 0)))) nimages_per_request, 0))))
break; break;
// for(i=0;i<nimages_per_request;i++)
// if ((ret_val =
//(!Beb_RequestNImages(beb_num,send_to_ten_gig,on_dst,1,0))))
// break;
dst_requested[on_dst++] = 0; dst_requested[on_dst++] = 0;
on_dst %= ndsts_in_use; on_dst %= ndsts_in_use;
@ -2407,10 +2381,6 @@ void readFrame(int *ret, char *mess) {
/* common */ /* common */
int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) { int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
int idac, ichan;
int ret = OK;
LOG(logDEBUG1, ("Copying module\n")); LOG(logDEBUG1, ("Copying module\n"));
if (srcMod->serialnumber >= 0) { if (srcMod->serialnumber >= 0) {
@ -2445,19 +2415,19 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
LOG(logDEBUG1, ("Copying register %x (%x)\n", destMod->reg, srcMod->reg)); LOG(logDEBUG1, ("Copying register %x (%x)\n", destMod->reg, srcMod->reg));
if (destMod->nchan != 0) { if (destMod->nchan != 0) {
for (ichan = 0; ichan < (srcMod->nchan); ichan++) { for (int ichan = 0; ichan < (srcMod->nchan); ichan++) {
if (*((srcMod->chanregs) + ichan) >= 0) if (*((srcMod->chanregs) + ichan) >= 0)
*((destMod->chanregs) + ichan) = *((srcMod->chanregs) + ichan); *((destMod->chanregs) + ichan) = *((srcMod->chanregs) + ichan);
} }
} else } else
LOG(logINFO, ("Not Copying trimbits\n")); LOG(logINFO, ("Not Copying trimbits\n"));
for (idac = 0; idac < (srcMod->ndac); idac++) { for (int idac = 0; idac < (srcMod->ndac); idac++) {
if (*((srcMod->dacs) + idac) >= 0) { if (*((srcMod->dacs) + idac) >= 0) {
*((destMod->dacs) + idac) = *((srcMod->dacs) + idac); *((destMod->dacs) + idac) = *((srcMod->dacs) + idac);
} }
} }
return ret; return OK;
} }
int calculateDataBytes() { int calculateDataBytes() {

View File

@ -5,7 +5,7 @@ support_lib = ../../slsSupportLib/include/
CROSS = nios2-buildroot-linux-gnu- CROSS = nios2-buildroot-linux-gnu-
CC = $(CROSS)gcc CC = $(CROSS)gcc
CFLAGS += -Wall -DGOTTHARD2D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE CFLAGS += -Wall -std=gnu99 -DGOTTHARD2D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
LDLIBS += -lm LDLIBS += -lm
PROGS = gotthard2DetectorServer PROGS = gotthard2DetectorServer
DESTDIR ?= bin DESTDIR ?= bin

View File

@ -1848,8 +1848,7 @@ int setVetoPhoton(int chipIndex, int gainIndex, int *values) {
int offset = padding; // bit offset for commandbytes int offset = padding; // bit offset for commandbytes
for (int ich = 0; ich < NCHAN; ++ich) { for (int ich = 0; ich < NCHAN; ++ich) {
// loop through all bits in a value // loop through all bits in a value
int iBit = 0; for (int iBit = 0; iBit < lenDataBitsPerchannel; ++iBit) {
for (iBit = 0; iBit < lenDataBitsPerchannel; ++iBit) {
commandBytes[offset++] = commandBytes[offset++] =
((values[ich] >> (lenDataBitsPerchannel - 1 - iBit)) & 0x1); ((values[ich] >> (lenDataBitsPerchannel - 1 - iBit)) & 0x1);
} }

View File

@ -5,7 +5,7 @@ support_lib = ../../slsSupportLib/include/
CROSS = bfin-uclinux- CROSS = bfin-uclinux-
CC = $(CROSS)gcc CC = $(CROSS)gcc
CFLAGS += -Wall -DGOTTHARDD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE CFLAGS += -Wall -std=gnu99 -DGOTTHARDD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
LDLIBS += -lm LDLIBS += -lm
PROGS = gotthardDetectorServer PROGS = gotthardDetectorServer
DESTDIR ?= bin DESTDIR ?= bin

View File

@ -167,8 +167,7 @@ int testFpga() {
u_int32_t addr = DUMMY_REG; u_int32_t addr = DUMMY_REG;
volatile u_int32_t val = 0, readval = 0; volatile u_int32_t val = 0, readval = 0;
int times = 1000 * 1000; int times = 1000 * 1000;
int i = 0; for (int i = 0; i < times; ++i) {
for (i = 0; i < times; ++i) {
val = 0x5A5A5A5A - i; val = 0x5A5A5A5A - i;
bus_w(addr, val); bus_w(addr, val);
readval = bus_r(addr); readval = bus_r(addr);
@ -226,9 +225,8 @@ int testBus() {
u_int32_t addr = DUMMY_REG; u_int32_t addr = DUMMY_REG;
volatile u_int32_t val = 0, readval = 0; volatile u_int32_t val = 0, readval = 0;
int times = 1000 * 1000; int times = 1000 * 1000;
int i = 0;
for (i = 0; i < times; ++i) { for (int i = 0; i < times; ++i) {
val += 0xbbbbb; val += 0xbbbbb;
bus_w(addr, val); bus_w(addr, val);
readval = bus_r(addr); readval = bus_r(addr);
@ -436,14 +434,11 @@ void setupDetector() {
int setDefaultDacs() { int setDefaultDacs() {
int ret = OK; int ret = OK;
LOG(logINFOBLUE, ("Setting Default Dac values\n")); LOG(logINFOBLUE, ("Setting Default Dac values\n"));
{ const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
int i = 0; for (int i = 0; i < NDAC; ++i) {
const int defaultvals[NDAC] = DEFAULT_DAC_VALS; // if not already default, set it to default
for (i = 0; i < NDAC; ++i) { if (dacValues[i] != defaultvals[i]) {
// if not already default, set it to default setDAC((enum DACINDEX)i, defaultvals[i], 0);
if (dacValues[i] != defaultvals[i]) {
setDAC((enum DACINDEX)i, defaultvals[i], 0);
}
} }
} }
return ret; return ret;
@ -477,8 +472,7 @@ void setPhaseShiftOnce() {
detectorFirstServer = 1; detectorFirstServer = 1;
LOG(logINFO, LOG(logINFO,
("Implementing the first phase shift of %d\n", phaseShift)); ("Implementing the first phase shift of %d\n", phaseShift));
int times = 0; for (int times = 1; times < phaseShift; ++times) {
for (times = 1; times < phaseShift; ++times) {
bus_w(addr, (INT_RSTN_MSK | ENT_RSTN_MSK | SW1_MSK | bus_w(addr, (INT_RSTN_MSK | ENT_RSTN_MSK | SW1_MSK |
PHS_STP_MSK)); // 0x1821 PHS_STP_MSK)); // 0x1821
bus_w(addr, (INT_RSTN_MSK | ENT_RSTN_MSK | bus_w(addr, (INT_RSTN_MSK | ENT_RSTN_MSK |
@ -495,8 +489,7 @@ void setPhaseShift(int numphaseshift) {
volatile u_int32_t val = bus_r(addr); volatile u_int32_t val = bus_r(addr);
LOG(logDEBUG1, ("Multipurpose reg: 0x%x\n", val)); LOG(logDEBUG1, ("Multipurpose reg: 0x%x\n", val));
int times = 0; for (int times = 1; times < numphaseshift; ++times) {
for (times = 1; times < numphaseshift; ++times) {
bus_w(addr, val | PHS_STP_MSK); bus_w(addr, val | PHS_STP_MSK);
bus_w(addr, val & (~PHS_STP_MSK)); bus_w(addr, val & (~PHS_STP_MSK));
} }
@ -947,23 +940,19 @@ int setModule(sls_detector_module myMod, char *mess) {
setSettings((enum detectorSettings)myMod.reg); setSettings((enum detectorSettings)myMod.reg);
// set dac values // set dac values
{ for (int i = 0; i < NDAC; ++i)
int i = 0; setDAC((enum DACINDEX)i, myMod.dacs[i], 0);
for (i = 0; i < NDAC; ++i)
setDAC((enum DACINDEX)i, myMod.dacs[i], 0);
}
return OK; return OK;
} }
int getModule(sls_detector_module *myMod) { int getModule(sls_detector_module *myMod) {
int idac = 0; for (int idac = 0; idac < NDAC; ++idac) {
for (idac = 0; idac < NDAC; ++idac) {
if (dacValues[idac] >= 0) if (dacValues[idac] >= 0)
*((myMod->dacs) + idac) = dacValues[idac]; *((myMod->dacs) + idac) = dacValues[idac];
} }
// check if all of them are not initialized // check if all of them are not initialized
int initialized = 0; int initialized = 0;
for (idac = 0; idac < NDAC; ++idac) { for (int idac = 0; idac < NDAC; ++idac) {
if (dacValues[idac] >= 0) if (dacValues[idac] >= 0)
initialized = 1; initialized = 1;
} }
@ -1112,27 +1101,23 @@ int getADC(enum ADCINDEX ind) {
// high clk low cs // high clk low cs
bus_w(addr, (TEMP_SPI_IN_T1_CLK_MSK | TEMP_SPI_IN_T2_CLK_MSK)); bus_w(addr, (TEMP_SPI_IN_T1_CLK_MSK | TEMP_SPI_IN_T2_CLK_MSK));
{ for (int i = 0; i < reads; ++i) {
int i = 0;
for (i = 0; i < reads; ++i) {
int j = 0; // low clk low cs
// low clk low cs for (int j = 0; j < repeats; ++j)
for (j = 0; j < repeats; ++j) bus_w(addr, 0x0);
bus_w(addr, 0x0); // high clk low cs
// high clk low cs for (int j = 0; j < repeats; ++j)
for (j = 0; j < repeats; ++j) bus_w(addr, (TEMP_SPI_IN_T1_CLK_MSK | TEMP_SPI_IN_T2_CLK_MSK));
bus_w(addr, (TEMP_SPI_IN_T1_CLK_MSK | TEMP_SPI_IN_T2_CLK_MSK));
// only the first time // only the first time
if (i <= 10) { if (i <= 10) {
if (ind == TEMP_ADC) if (ind == TEMP_ADC)
value = (value << 1) + value =
(bus_r(addrout) & TEMP_SPI_OUT_T1_DT_MSK); (value << 1) + (bus_r(addrout) & TEMP_SPI_OUT_T1_DT_MSK);
else else
value = (value << 1) + value =
(bus_r(addrout) & TEMP_SPI_OUT_T2_DT_MSK); (value << 1) + (bus_r(addrout) & TEMP_SPI_OUT_T2_DT_MSK);
}
} }
} }
@ -1603,22 +1588,18 @@ void *start_timer(void *arg) {
// Generate Data // Generate Data
char imageData[imageSize]; char imageData[imageSize];
memset(imageData, 0, imageSize); memset(imageData, 0, imageSize);
{ if (adcConfigured == -1) {
int i = 0; *((uint32_t *)(imageData)) = 0xCACACACA;
if (adcConfigured == -1) { }
*((uint32_t *)(imageData)) = 0xCACACACA; for (int i = sizeof(uint32_t); i < imageSize; i += sizeof(uint16_t)) {
} *((uint16_t *)(imageData + i)) = (uint16_t)i;
for (i = sizeof(uint32_t); i < imageSize; i += sizeof(uint16_t)) {
*((uint16_t *)(imageData + i)) = (uint16_t)i;
}
} }
// Send data // Send data
{ {
int frameNr = 0;
uint16_t frameHeaderNr = 2; uint16_t frameHeaderNr = 2;
// loop over number of frames // loop over number of frames
for (frameNr = 0; frameNr != numFrames; ++frameNr) { for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
// update the virtual stop from stop server // update the virtual stop from stop server
virtual_stop = ComVirtual_getStop(); virtual_stop = ComVirtual_getStop();
@ -1634,22 +1615,19 @@ void *start_timer(void *arg) {
int srcOffset = 0; int srcOffset = 0;
// loop packet // loop packet
{ for (int i = 0; i != packetsPerFrame; ++i) {
int i = 0;
for (i = 0; i != packetsPerFrame; ++i) {
char packetData[packetSize]; char packetData[packetSize];
memset(packetData, 0, packetSize); memset(packetData, 0, packetSize);
// set header // set header
*((uint16_t *)(packetData)) = frameHeaderNr; *((uint16_t *)(packetData)) = frameHeaderNr;
++frameHeaderNr; ++frameHeaderNr;
// fill data // fill data
memcpy(packetData + 4, imageData + srcOffset, dataSize); memcpy(packetData + 4, imageData + srcOffset, dataSize);
srcOffset += dataSize; srcOffset += dataSize;
sendUDPPacket(0, packetData, packetSize); sendUDPPacket(0, packetData, packetSize);
}
} }
LOG(logINFO, ("Sent frame: %d\n", frameNr)); LOG(logINFO, ("Sent frame: %d\n", frameNr));
clock_gettime(CLOCK_REALTIME, &end); clock_gettime(CLOCK_REALTIME, &end);
@ -1768,8 +1746,7 @@ enum runStatus getRunStatus() {
} else { } else {
LOG(logINFORED, LOG(logINFORED,
("Status: Unknown Status: 0x%x. Trying again.\n", retval)); ("Status: Unknown Status: 0x%x. Trying again.\n", retval));
int iloop = 0; for (int iloop = 0; iloop < 10; ++iloop) {
for (iloop = 0; iloop < 10; ++iloop) {
usleep(1000 * 1000); usleep(1000 * 1000);
if (runState(logDEBUG1) != retval) if (runState(logDEBUG1) != retval)
return getRunStatus(); return getRunStatus();

View File

@ -5,7 +5,7 @@ support_lib = ../../slsSupportLib/include/
CROSS = bfin-uclinux- CROSS = bfin-uclinux-
CC = $(CROSS)gcc CC = $(CROSS)gcc
CFLAGS += -Wall -DJUNGFRAUD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE CFLAGS += -Wall -std=gnu99 -DJUNGFRAUD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
LDLIBS += -lm LDLIBS += -lm
PROGS = jungfrauDetectorServer PROGS = jungfrauDetectorServer
DESTDIR ?= bin DESTDIR ?= bin

View File

@ -210,9 +210,8 @@ int testBus() {
int ret = OK; int ret = OK;
u_int32_t addr = SET_TRIGGER_DELAY_LSB_REG; u_int32_t addr = SET_TRIGGER_DELAY_LSB_REG;
u_int32_t times = 1000 * 1000; u_int32_t times = 1000 * 1000;
u_int32_t i = 0;
for (i = 0; i < times; ++i) { for (u_int32_t i = 0; i < times; ++i) {
bus_w(addr, i * 100); bus_w(addr, i * 100);
if (i * 100 != bus_r(addr)) { if (i * 100 != bus_r(addr)) {
LOG(logERROR, LOG(logERROR,
@ -376,11 +375,8 @@ void initStopServer() {
void setupDetector() { void setupDetector() {
LOG(logINFO, ("This Server is for 1 Jungfrau module (500k)\n")); LOG(logINFO, ("This Server is for 1 Jungfrau module (500k)\n"));
{ for (int i = 0; i < NUM_CLOCKS; ++i) {
int i = 0; clkPhase[i] = 0;
for (i = 0; i < NUM_CLOCKS; ++i) {
clkPhase[i] = 0;
}
} }
#ifdef VIRTUAL #ifdef VIRTUAL
virtual_status = 0; virtual_status = 0;
@ -462,14 +458,11 @@ void setupDetector() {
int setDefaultDacs() { int setDefaultDacs() {
int ret = OK; int ret = OK;
LOG(logINFOBLUE, ("Setting Default Dac values\n")); LOG(logINFOBLUE, ("Setting Default Dac values\n"));
{ const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
int i = 0; for (int i = 0; i < NDAC; ++i) {
const int defaultvals[NDAC] = DEFAULT_DAC_VALS; // if not already default, set it to default
for (i = 0; i < NDAC; ++i) { if (dacValues[i] != defaultvals[i]) {
// if not already default, set it to default setDAC((enum DACINDEX)i, defaultvals[i], 0);
if (dacValues[i] != defaultvals[i]) {
setDAC((enum DACINDEX)i, defaultvals[i], 0);
}
} }
} }
return ret; return ret;
@ -747,23 +740,19 @@ int setModule(sls_detector_module myMod, char *mess) {
setSettings((enum detectorSettings)myMod.reg); setSettings((enum detectorSettings)myMod.reg);
// set dac values // set dac values
{ for (int i = 0; i < NDAC; ++i)
int i = 0; setDAC((enum DACINDEX)i, myMod.dacs[i], 0);
for (i = 0; i < NDAC; ++i)
setDAC((enum DACINDEX)i, myMod.dacs[i], 0);
}
return OK; return OK;
} }
int getModule(sls_detector_module *myMod) { int getModule(sls_detector_module *myMod) {
int idac = 0; for (int idac = 0; idac < NDAC; ++idac) {
for (idac = 0; idac < NDAC; ++idac) {
if (dacValues[idac] >= 0) if (dacValues[idac] >= 0)
*((myMod->dacs) + idac) = dacValues[idac]; *((myMod->dacs) + idac) = dacValues[idac];
} }
// check if all of them are not initialized // check if all of them are not initialized
int initialized = 0; int initialized = 0;
for (idac = 0; idac < NDAC; ++idac) { for (int idac = 0; idac < NDAC; ++idac) {
if (dacValues[idac] >= 0) if (dacValues[idac] >= 0)
initialized = 1; initialized = 1;
} }
@ -1753,22 +1742,18 @@ void *start_timer(void *arg) {
// Generate data // Generate data
char imageData[DATA_BYTES]; char imageData[DATA_BYTES];
memset(imageData, 0, DATA_BYTES); memset(imageData, 0, DATA_BYTES);
{ for (int i = 0; i < npixels; ++i) {
int i = 0; // avoiding gain also being divided when gappixels enabled in call
for (i = 0; i < npixels; ++i) { // back
// avoiding gain also being divided when gappixels enabled in call *((uint16_t *)(imageData + i * sizeof(uint16_t))) =
// back virtual_image_test_mode ? 0x0FFE : (uint16_t)i;
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
virtual_image_test_mode ? 0x0FFE : (uint16_t)i;
}
} }
// Send data // Send data
{ {
uint64_t frameNr = 0; uint64_t frameNr = 0;
getStartingFrameNumber(&frameNr); getStartingFrameNumber(&frameNr);
int iframes = 0; for (int iframes = 0; iframes != numFrames; ++iframes) {
for (iframes = 0; iframes != numFrames; ++iframes) {
usleep(transmissionDelayUs); usleep(transmissionDelayUs);
@ -1788,49 +1773,46 @@ void *start_timer(void *arg) {
int srcOffset = 0; int srcOffset = 0;
int srcOffset2 = DATA_BYTES / 2; int srcOffset2 = DATA_BYTES / 2;
// loop packet // loop packet
{ for (int i = 0; i != packetsPerFrame; ++i) {
int i = 0; // set header
for (i = 0; i != packetsPerFrame; ++i) { char packetData[packetsize];
// set header memset(packetData, 0, packetsize);
char packetData[packetsize]; sls_detector_header *header =
memset(packetData, 0, packetsize); (sls_detector_header *)(packetData);
sls_detector_header *header = header->detType = (uint16_t)myDetectorType;
(sls_detector_header *)(packetData); header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = frameNr + iframes;
header->packetNumber = i;
header->modId = 0;
header->row = detPos[2];
header->column = detPos[3];
// fill data
memcpy(packetData + sizeof(sls_detector_header),
imageData + srcOffset, dataSize);
srcOffset += dataSize;
sendUDPPacket(0, packetData, packetsize);
// second interface
char packetData2[packetsize];
memset(packetData2, 0, packetsize);
if (numInterfaces == 2) {
header = (sls_detector_header *)(packetData2);
header->detType = (uint16_t)myDetectorType; header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION - 1; header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = frameNr + iframes; header->frameNumber = frameNr + iframes;
header->packetNumber = i; header->packetNumber = i;
header->modId = 0; header->modId = 0;
header->row = detPos[2]; header->row = detPos[0];
header->column = detPos[3]; header->column = detPos[1];
// fill data // fill data
memcpy(packetData + sizeof(sls_detector_header), memcpy(packetData2 + sizeof(sls_detector_header),
imageData + srcOffset, dataSize); imageData + srcOffset2, dataSize);
srcOffset += dataSize; srcOffset2 += dataSize;
sendUDPPacket(0, packetData, packetsize); sendUDPPacket(1, packetData2, packetsize);
// second interface
char packetData2[packetsize];
memset(packetData2, 0, packetsize);
if (numInterfaces == 2) {
header = (sls_detector_header *)(packetData2);
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = frameNr + iframes;
header->packetNumber = i;
header->modId = 0;
header->row = detPos[0];
header->column = detPos[1];
// fill data
memcpy(packetData2 + sizeof(sls_detector_header),
imageData + srcOffset2, dataSize);
srcOffset2 += dataSize;
sendUDPPacket(1, packetData2, packetsize);
}
} }
} }
LOG(logINFO, ("Sent frame: %d\n", iframes)); LOG(logINFO, ("Sent frame: %d\n", iframes));

View File

@ -5,7 +5,7 @@ support_lib = ../../slsSupportLib/include/
CROSS = bfin-uclinux- CROSS = bfin-uclinux-
CC = $(CROSS)gcc CC = $(CROSS)gcc
CFLAGS += -Wall -DMOENCHD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE CFLAGS += -Wall -std=gnu99 -DMOENCHD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
LDLIBS += -lm LDLIBS += -lm
PROGS = moenchDetectorServer PROGS = moenchDetectorServer
DESTDIR ?= bin DESTDIR ?= bin

View File

@ -233,8 +233,7 @@ int testFpga() {
volatile uint32_t val = 0, readval = 0; volatile uint32_t val = 0, readval = 0;
int times = 1000 * 1000; int times = 1000 * 1000;
int i = 0; for (int i = 0; i < times; ++i) {
for (i = 0; i < times; ++i) {
val = 0x5A5A5A5A - i; val = 0x5A5A5A5A - i;
bus_w(addr, val); bus_w(addr, val);
readval = bus_r(addr); readval = bus_r(addr);
@ -298,9 +297,8 @@ int testBus() {
volatile uint32_t val = 0, readval = 0; volatile uint32_t val = 0, readval = 0;
int times = 1000 * 1000; int times = 1000 * 1000;
int i = 0;
for (i = 0; i < times; ++i) { for (int i = 0; i < times; ++i) {
val += 0xbbbbb; val += 0xbbbbb;
bus_w(addr, val); bus_w(addr, val);
readval = bus_r(addr); readval = bus_r(addr);
@ -458,33 +456,30 @@ void setupDetector() {
} }
analogDataPtr = 0; analogDataPtr = 0;
digitalDataPtr = 0; digitalDataPtr = 0;
{ for (int i = 0; i < NUM_CLOCKS; ++i) {
int i = 0; clkPhase[i] = 0;
for (i = 0; i < NUM_CLOCKS; ++i) {
clkPhase[i] = 0;
}
clkFrequency[RUN_CLK] = DEFAULT_RUN_CLK_AT_STARTUP;
clkFrequency[ADC_CLK] = DEFAULT_ADC_CLK_AT_STARTUP;
clkFrequency[SYNC_CLK] = DEFAULT_SYNC_CLK_AT_STARTUP;
clkFrequency[DBIT_CLK] = DEFAULT_DBIT_CLK_AT_STARTUP;
// default adc phase in deg
/*
{
int phase_shifts = 0;
ConvertToDifferentRange(0, 359, 0, getMaxPhase(ADC_CLK) - 1,
DEFAULT_ADC_PHASE_DEG, &phase_shifts); clkPhase[ADC_CLK] =
phase_shifts;
}
LOG(logINFO, ("Default Run clk: %d MHz\n",
clkFrequency[RUN_CLK])); LOG(logINFO, ("Default Adc clk: %d MHz\n",
clkFrequency[ADC_CLK])); LOG(logINFO, ("Default Sync clk: %d MHz\n",
clkFrequency[SYNC_CLK])); LOG(logINFO, ("Default Dbit clk: %d MHz\n",
clkFrequency[DBIT_CLK])); LOG(logINFO, ("Default Adc Phase: %d (%d
deg)\n", clkPhase[ADC_CLK], getPhase(ADC_CLK, 1)));
*/
for (i = 0; i < NDAC; ++i)
dacValues[i] = -1;
} }
clkFrequency[RUN_CLK] = DEFAULT_RUN_CLK_AT_STARTUP;
clkFrequency[ADC_CLK] = DEFAULT_ADC_CLK_AT_STARTUP;
clkFrequency[SYNC_CLK] = DEFAULT_SYNC_CLK_AT_STARTUP;
clkFrequency[DBIT_CLK] = DEFAULT_DBIT_CLK_AT_STARTUP;
// default adc phase in deg
/*
{
int phase_shifts = 0;
ConvertToDifferentRange(0, 359, 0, getMaxPhase(ADC_CLK) - 1,
DEFAULT_ADC_PHASE_DEG, &phase_shifts); clkPhase[ADC_CLK] =
phase_shifts;
}
LOG(logINFO, ("Default Run clk: %d MHz\n",
clkFrequency[RUN_CLK])); LOG(logINFO, ("Default Adc clk: %d MHz\n",
clkFrequency[ADC_CLK])); LOG(logINFO, ("Default Sync clk: %d MHz\n",
clkFrequency[SYNC_CLK])); LOG(logINFO, ("Default Dbit clk: %d MHz\n",
clkFrequency[DBIT_CLK])); LOG(logINFO, ("Default Adc Phase: %d (%d
deg)\n", clkPhase[ADC_CLK], getPhase(ADC_CLK, 1)));
*/
for (int i = 0; i < NDAC; ++i)
dacValues[i] = -1;
vLimit = DEFAULT_VLIMIT; vLimit = DEFAULT_VLIMIT;
highvoltage = 0; highvoltage = 0;
adcEnableMask_1g = 0; adcEnableMask_1g = 0;
@ -610,8 +605,7 @@ void updateDataBytes() {
if (adcEnableMask_1g == BIT32_MSK) if (adcEnableMask_1g == BIT32_MSK)
nchans = 32; nchans = 32;
else { else {
int ichan = 0; for (int ichan = 0; ichan < NCHAN; ++ichan) {
for (ichan = 0; ichan < NCHAN; ++ichan) {
if (adcEnableMask_1g & (1 << ichan)) if (adcEnableMask_1g & (1 << ichan))
++nchans; ++nchans;
} }
@ -625,14 +619,11 @@ void updateDataBytes() {
int setDefaultDacs() { int setDefaultDacs() {
int ret = OK; int ret = OK;
LOG(logINFOBLUE, ("Setting Default Dac values\n")); LOG(logINFOBLUE, ("Setting Default Dac values\n"));
{ const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
int i = 0; for (int i = 0; i < NDAC; ++i) {
const int defaultvals[NDAC] = DEFAULT_DAC_VALS; // if not already default, set it to default
for (i = 0; i < NDAC; ++i) { if (dacValues[i] != defaultvals[i]) {
// if not already default, set it to default setDAC((enum DACINDEX)i, defaultvals[i], 0);
if (dacValues[i] != defaultvals[i]) {
setDAC((enum DACINDEX)i, defaultvals[i], 0);
}
} }
} }
return ret; return ret;
@ -712,8 +703,7 @@ void setADCEnableMask_10G(uint32_t mask) {
uint8_t actualMask = 0; uint8_t actualMask = 0;
if (mask != 0) { if (mask != 0) {
int ival = 0; int ival = 0;
int ich = 0; for (int ich = 0; ich < NCHAN; ich = ich + 4) {
for (ich = 0; ich < NCHAN; ich = ich + 4) {
if ((1 << ich) & mask) { if ((1 << ich) & mask) {
actualMask |= (1 << ival); actualMask |= (1 << ival);
} }
@ -739,13 +729,11 @@ uint32_t getADCEnableMask_10G() {
// convert 8 bit mask to 32 bit mask // convert 8 bit mask to 32 bit mask
uint32_t retval = 0; uint32_t retval = 0;
if (adcEnableMask_10g) { if (adcEnableMask_10g) {
int ival = 0; for (int ival = 0; ival < 8; ++ival) {
int iloop = 0;
for (ival = 0; ival < 8; ++ival) {
// if bit in 8 bit mask set // if bit in 8 bit mask set
if ((1 << ival) & adcEnableMask_10g) { if ((1 << ival) & adcEnableMask_10g) {
// set it for 4 bits in 32 bit mask // set it for 4 bits in 32 bit mask
for (iloop = 0; iloop < 4; ++iloop) { for (int iloop = 0; iloop < 4; ++iloop) {
retval |= (1 << (ival * 4 + iloop)); retval |= (1 << (ival * 4 + iloop));
} }
} }
@ -1948,67 +1936,57 @@ void *start_timer(void *arg) {
// Generate Data // Generate Data
char imageData[imageSize]; char imageData[imageSize];
memset(imageData, 0, imageSize); memset(imageData, 0, imageSize);
{ for (int i = 0; i < imageSize; i += sizeof(uint16_t)) {
int i = 0; *((uint16_t *)(imageData + i)) = i;
for (i = 0; i < imageSize; i += sizeof(uint16_t)) {
*((uint16_t *)(imageData + i)) = i;
}
} }
// Send data // Send data
{ // loop over number of frames
int frameNr = 0; for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
// loop over number of frames
for (frameNr = 0; frameNr != numFrames; ++frameNr) {
// update the virtual stop from stop server // update the virtual stop from stop server
virtual_stop = ComVirtual_getStop(); virtual_stop = ComVirtual_getStop();
// check if virtual_stop is high // check if virtual_stop is high
if (virtual_stop == 1) { if (virtual_stop == 1) {
break; break;
} }
// sleep for exposure time // sleep for exposure time
struct timespec begin, end; struct timespec begin, end;
clock_gettime(CLOCK_REALTIME, &begin); clock_gettime(CLOCK_REALTIME, &begin);
usleep(expNs / 1000); usleep(expNs / 1000);
int srcOffset = 0; int srcOffset = 0;
// loop packet // loop packet
{ for (int i = 0; i != packetsPerFrame; ++i) {
int i = 0; // set header
for (i = 0; i != packetsPerFrame; ++i) { char packetData[packetSize];
// set header memset(packetData, 0, packetSize);
char packetData[packetSize]; sls_detector_header *header = (sls_detector_header *)(packetData);
memset(packetData, 0, packetSize); header->detType = (uint16_t)myDetectorType;
sls_detector_header *header = header->version = SLS_DETECTOR_HEADER_VERSION - 1;
(sls_detector_header *)(packetData); header->frameNumber = frameNr;
header->detType = (uint16_t)myDetectorType; header->packetNumber = i;
header->version = SLS_DETECTOR_HEADER_VERSION - 1; header->modId = 0;
header->frameNumber = frameNr; header->row = detPos[X];
header->packetNumber = i; header->column = detPos[Y];
header->modId = 0;
header->row = detPos[X];
header->column = detPos[Y];
// fill data // fill data
memcpy(packetData + sizeof(sls_detector_header), memcpy(packetData + sizeof(sls_detector_header),
imageData + srcOffset, dataSize); imageData + srcOffset, dataSize);
srcOffset += dataSize; srcOffset += dataSize;
sendUDPPacket(0, packetData, packetSize); sendUDPPacket(0, packetData, packetSize);
} }
} LOG(logINFO, ("Sent frame: %d\n", frameNr));
LOG(logINFO, ("Sent frame: %d\n", frameNr)); clock_gettime(CLOCK_REALTIME, &end);
clock_gettime(CLOCK_REALTIME, &end); int64_t timeNs =
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 + ((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec));
(end.tv_nsec - begin.tv_nsec));
// sleep for (period - exptime) // sleep for (period - exptime)
if (frameNr < numFrames) { // if there is a next frame if (frameNr < numFrames) { // if there is a next frame
if (periodNs > timeNs) { if (periodNs > timeNs) {
usleep((periodNs - timeNs) / 1000); usleep((periodNs - timeNs) / 1000);
}
} }
} }
} }
@ -2192,11 +2170,8 @@ void readSample(int ns) {
bus_w(addr, bus_r(addr) & (~DUMMY_ANLG_FIFO_RD_STRBE_MSK)); bus_w(addr, bus_r(addr) & (~DUMMY_ANLG_FIFO_RD_STRBE_MSK));
// wait for 1 us to latch different clocks of read and read strobe // wait for 1 us to latch different clocks of read and read strobe
{ for (int i = 0; i < WAIT_TIME_1US_FOR_LOOP_CNT; ++i)
int i = 0; ;
for (i = 0; i < WAIT_TIME_1US_FOR_LOOP_CNT; ++i)
;
}
if (!(ns % 1000)) { if (!(ns % 1000)) {
LOG(logDEBUG1, ("Reading sample ns:%d of %d AEmtpy:0x%x AFull:0x%x " LOG(logDEBUG1, ("Reading sample ns:%d of %d AEmtpy:0x%x AFull:0x%x "
@ -2206,8 +2181,7 @@ void readSample(int ns) {
} }
// loop through all channels // loop through all channels
int ich = 0; for (int ich = 0; ich < NCHAN; ++ich) {
for (ich = 0; ich < NCHAN; ++ich) {
// if channel is in enable mask // if channel is in enable mask
if ((1 << ich) & (adcEnableMask_1g)) { if ((1 << ich) & (adcEnableMask_1g)) {

View File

@ -5,7 +5,7 @@ support_lib = ../../slsSupportLib/include/
CROSS = nios2-buildroot-linux-gnu- CROSS = nios2-buildroot-linux-gnu-
CC = $(CROSS)gcc CC = $(CROSS)gcc
CFLAGS += -Wall -DMYTHEN3D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE CFLAGS += -Wall -std=gnu99 -DMYTHEN3D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
LDLIBS += -lm LDLIBS += -lm
PROGS = mythen3DetectorServer PROGS = mythen3DetectorServer
DESTDIR ?= bin DESTDIR ?= bin

View File

@ -219,8 +219,7 @@ void AD7689_Configure() {
LOG(logINFO, LOG(logINFO,
("\tConfiguring %d x due to invalid conversions from power up\n", ("\tConfiguring %d x due to invalid conversions from power up\n",
AD7689_NUM_INVALID_CONVERSIONS)); AD7689_NUM_INVALID_CONVERSIONS));
int i = 0; for (int i = 0; i < AD7689_NUM_INVALID_CONVERSIONS; ++i) {
for (i = 0; i < AD7689_NUM_INVALID_CONVERSIONS; ++i) {
AD7689_Set( AD7689_Set(
// read back // read back
AD7689_CFG_RB_MSK | AD7689_CFG_RB_MSK |

View File

@ -35,8 +35,7 @@ int ASIC_Driver_Set(int index, int length, char *buffer) {
("\t[chip index: %d, length: %d, fname: %s]\n", index, length, fname)); ("\t[chip index: %d, length: %d, fname: %s]\n", index, length, fname));
{ {
LOG(logDEBUG2, ("\t[values: \n")); LOG(logDEBUG2, ("\t[values: \n"));
int i; for (int i = 0; i < length; ++i) {
for (i = 0; i < length; ++i) {
LOG(logDEBUG2, ("\t%d: 0x%02hhx\n", i, buffer[i])); LOG(logDEBUG2, ("\t%d: 0x%02hhx\n", i, buffer[i]));
} }
LOG(logDEBUG2, ("\t]\n")); LOG(logDEBUG2, ("\t]\n"));

View File

@ -234,10 +234,8 @@ uint32_t I2C_Read(uint32_t devId, uint32_t addr) {
int level = bus_r(I2C_Rx_Data_Fifo_Level_Reg); int level = bus_r(I2C_Rx_Data_Fifo_Level_Reg);
LOG(logDEBUG2, (" level:%d\n", level)); LOG(logDEBUG2, (" level:%d\n", level));
int iloop = level - 1;
// level bytes to read, read 1 byte at a time // level bytes to read, read 1 byte at a time
for (iloop = level - 1; iloop >= 0; --iloop) { for (int iloop = level - 1; iloop >= 0; --iloop) {
u_int16_t byte = u_int16_t byte =
bus_r(I2C_Rx_Data_Fifo_Reg) & I2C_RX_DATA_FIFO_RXDATA_MSK; bus_r(I2C_Rx_Data_Fifo_Reg) & I2C_RX_DATA_FIFO_RXDATA_MSK;
LOG(logDEBUG2, (" byte nr %d:0x%x\n", iloop, byte)); LOG(logDEBUG2, (" byte nr %d:0x%x\n", iloop, byte));

View File

@ -116,7 +116,6 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
int nchip = LTC2620_Ndac / LTC2620_NUMCHANNELS; int nchip = LTC2620_Ndac / LTC2620_NUMCHANNELS;
uint32_t valw = 0; uint32_t valw = 0;
int ichip = 0;
LOG(logDEBUG2, ("(Daisy) desired chip index:%d, nchip:%d, dac ch:%d, " LOG(logDEBUG2, ("(Daisy) desired chip index:%d, nchip:%d, dac ch:%d, "
"val:%d, cmd:0x%x \n", "val:%d, cmd:0x%x \n",
@ -136,7 +135,7 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
// send same data to all // send same data to all
if (chipIndex < 0) { if (chipIndex < 0) {
LOG(logDEBUG2, ("Send same data to all\n")); LOG(logDEBUG2, ("Send same data to all\n"));
for (ichip = 0; ichip < nchip; ++ichip) { for (int ichip = 0; ichip < nchip; ++ichip) {
LOG(logDEBUG2, ("Send data (0x%x) to ichip %d\n", codata, ichip)); LOG(logDEBUG2, ("Send data (0x%x) to ichip %d\n", codata, ichip));
LTC2620_SendDaisyData(&valw, codata); LTC2620_SendDaisyData(&valw, codata);
} }
@ -146,7 +145,7 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
else { else {
// send nothing to subsequent ichips (daisy chain) (if any chips after // send nothing to subsequent ichips (daisy chain) (if any chips after
// desired chip) // desired chip)
for (ichip = chipIndex + 1; ichip < nchip; ++ichip) { for (int ichip = chipIndex + 1; ichip < nchip; ++ichip) {
LOG(logDEBUG2, ("Send nothing to ichip %d\n", ichip)); LOG(logDEBUG2, ("Send nothing to ichip %d\n", ichip));
LTC2620_SendDaisyData(&valw, LTC2620_DAC_CMD_NO_OPRTN_VAL); LTC2620_SendDaisyData(&valw, LTC2620_DAC_CMD_NO_OPRTN_VAL);
} }
@ -157,7 +156,7 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
// send nothing to preceding ichips (daisy chain) (if any chips in front // send nothing to preceding ichips (daisy chain) (if any chips in front
// of desired chip) // of desired chip)
for (ichip = 0; ichip < chipIndex; ++ichip) { for (int ichip = 0; ichip < chipIndex; ++ichip) {
LOG(logDEBUG2, ("Send nothing to ichip %d\n", ichip)); LOG(logDEBUG2, ("Send nothing to ichip %d\n", ichip));
LTC2620_SendDaisyData(&valw, LTC2620_DAC_CMD_NO_OPRTN_VAL); LTC2620_SendDaisyData(&valw, LTC2620_DAC_CMD_NO_OPRTN_VAL);
} }

View File

@ -83,8 +83,7 @@ void sendDataToSPI(uint32_t *valw, uint32_t addr, uint32_t val,
"clkmask:0x%x digmask:0x%x digofst:%d\n", "clkmask:0x%x digmask:0x%x digofst:%d\n",
*valw, addr, val, numbitstosend, clkmask, digoutmask, digofset)); *valw, addr, val, numbitstosend, clkmask, digoutmask, digofset));
int i = 0; for (int i = 0; i < numbitstosend; ++i) {
for (i = 0; i < numbitstosend; ++i) {
// clk down // clk down
(*valw) &= ~clkmask; (*valw) &= ~clkmask;
@ -112,9 +111,7 @@ uint32_t receiveDataFromSPI(uint32_t *valw, uint32_t addr, int numbitstoreceive,
*valw, addr, numbitstoreceive, clkmask, readaddr)); *valw, addr, numbitstoreceive, clkmask, readaddr));
uint32_t retval = 0; uint32_t retval = 0;
int i = 0; for (int i = 0; i < numbitstoreceive; ++i) {
for (i = 0; i < numbitstoreceive; ++i) {
// clk down // clk down
(*valw) &= ~clkmask; (*valw) &= ~clkmask;

View File

@ -121,7 +121,6 @@ int bindSocket(unsigned short int port_number) {
} }
int acceptConnection(int socketDescriptor) { int acceptConnection(int socketDescriptor) {
int j;
struct sockaddr_in addressC; struct sockaddr_in addressC;
int file_des = -1; int file_des = -1;
struct timeval tv; struct timeval tv;
@ -159,7 +158,7 @@ int acceptConnection(int socketDescriptor) {
("%s select returned!\n", (isControlServer ? "control" : "stop"))); ("%s select returned!\n", (isControlServer ? "control" : "stop")));
// loop through the file descriptor set // loop through the file descriptor set
for (j = 0; j < maxfd + 1; ++j) { for (int j = 0; j < maxfd + 1; ++j) {
// checks if file descriptor part of set // checks if file descriptor part of set
if (FD_ISSET(j, &tempset)) { if (FD_ISSET(j, &tempset)) {
@ -264,11 +263,10 @@ void exitServer(int socketDescriptor) {
} }
void swapData(void *val, int length, intType itype) { void swapData(void *val, int length, intType itype) {
int i;
int16_t *c = (int16_t *)val; int16_t *c = (int16_t *)val;
int32_t *a = (int32_t *)val; int32_t *a = (int32_t *)val;
int64_t *b = (int64_t *)val; int64_t *b = (int64_t *)val;
for (i = 0; length > 0; i++) { for (int i = 0; length > 0; i++) {
switch (itype) { switch (itype) {
case INT16: case INT16:
c[i] = ((c[i] & 0x00FF) << 8) | ((c[i] & 0xFF00) >> 8); c[i] = ((c[i] & 0x00FF) << 8) | ((c[i] & 0xFF00) >> 8);

View File

@ -89,8 +89,7 @@ int mapCSP0(void) {
u_int32_t **cspbases[2] = {&csp0base, &csp1base}; u_int32_t **cspbases[2] = {&csp0base, &csp1base};
char names[2][10] = {"csp0base", "csp1base"}; char names[2][10] = {"csp0base", "csp1base"};
int i = 0; for (int i = 0; i < 2; ++i) {
for (i = 0; i < 2; ++i) {
// if not mapped // if not mapped
if (*cspbases[i] == 0) { if (*cspbases[i] == 0) {
LOG(logINFO, ("Mapping memory for %s\n", names[i])); LOG(logINFO, ("Mapping memory for %s\n", names[i]));

View File

@ -60,46 +60,42 @@ int main(int argc, char *argv[]) {
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
// circumvent the basic tests // circumvent the basic tests
{ for (int i = 1; i < argc; ++i) {
int i; if (!strcasecmp(argv[i], "-stopserver")) {
for (i = 1; i < argc; ++i) { LOG(logINFO, ("Detected stop server\n"));
if (!strcasecmp(argv[i], "-stopserver")) { isControlServer = 0;
LOG(logINFO, ("Detected stop server\n")); } else if (!strcasecmp(argv[i], "-devel")) {
isControlServer = 0; LOG(logINFO, ("Detected developer mode\n"));
} else if (!strcasecmp(argv[i], "-devel")) { debugflag = 1;
LOG(logINFO, ("Detected developer mode\n")); } else if (!strcasecmp(argv[i], "-nomodule")) {
debugflag = 1; LOG(logINFO, ("Detected No Module mode\n"));
} else if (!strcasecmp(argv[i], "-nomodule")) { checkModuleFlag = 0;
LOG(logINFO, ("Detected No Module mode\n")); } else if (!strcasecmp(argv[i], "-port")) {
checkModuleFlag = 0; if ((i + 1) >= argc) {
} else if (!strcasecmp(argv[i], "-port")) { LOG(logERROR, ("no port value given. Exiting.\n"));
if ((i + 1) >= argc) { return -1;
LOG(logERROR, ("no port value given. Exiting.\n"));
return -1;
}
if (sscanf(argv[i + 1], "%d", &portno) == 0) {
LOG(logERROR, ("cannot decode port value %s. Exiting.\n",
argv[i + 1]));
return -1;
}
LOG(logINFO, ("Detected port: %d\n", portno));
} }
#ifdef GOTTHARDD if (sscanf(argv[i + 1], "%d", &portno) == 0) {
else if (!strcasecmp(argv[i], "-phaseshift")) { LOG(logERROR,
if ((i + 1) >= argc) { ("cannot decode port value %s. Exiting.\n", argv[i + 1]));
LOG(logERROR, ("no phase shift value given. Exiting.\n")); return -1;
return -1;
}
if (sscanf(argv[i + 1], "%d", &phaseShift) == 0) {
LOG(logERROR,
("cannot decode phase shift value %s. Exiting.\n",
argv[i + 1]));
return -1;
}
LOG(logINFO, ("Detected phase shift of %d\n", phaseShift));
} }
#endif LOG(logINFO, ("Detected port: %d\n", portno));
} }
#ifdef GOTTHARDD
else if (!strcasecmp(argv[i], "-phaseshift")) {
if ((i + 1) >= argc) {
LOG(logERROR, ("no phase shift value given. Exiting.\n"));
return -1;
}
if (sscanf(argv[i + 1], "%d", &phaseShift) == 0) {
LOG(logERROR, ("cannot decode phase shift value %s. Exiting.\n",
argv[i + 1]));
return -1;
}
LOG(logINFO, ("Detected phase shift of %d\n", phaseShift));
}
#endif
} }
// control server // control server
@ -108,26 +104,23 @@ int main(int argc, char *argv[]) {
// start stop server process // start stop server process
char cmd[MAX_STR_LENGTH]; char cmd[MAX_STR_LENGTH];
memset(cmd, 0, MAX_STR_LENGTH); memset(cmd, 0, MAX_STR_LENGTH);
{ for (int i = 0; i < argc; ++i) {
int i; if (!strcasecmp(argv[i], "-port")) {
for (i = 0; i < argc; ++i) { i += 2;
if (!strcasecmp(argv[i], "-port")) { continue;
i += 2;
continue;
}
if (i > 0) {
strcat(cmd, " ");
}
strcat(cmd, argv[i]);
} }
char temp[50]; if (i > 0) {
memset(temp, 0, sizeof(temp)); strcat(cmd, " ");
sprintf(temp, " -stopserver -port %d &", portno + 1); }
strcat(cmd, temp); strcat(cmd, argv[i]);
LOG(logDEBUG1, ("Command to start stop server:%s\n", cmd));
system(cmd);
} }
char temp[50];
memset(temp, 0, sizeof(temp));
sprintf(temp, " -stopserver -port %d &", portno + 1);
strcat(cmd, temp);
LOG(logDEBUG1, ("Command to start stop server:%s\n", cmd));
system(cmd);
LOG(logINFOBLUE, ("Control Server [%d]\n", portno)); LOG(logINFOBLUE, ("Control Server [%d]\n", portno));
#ifdef VIRTUAL #ifdef VIRTUAL
// creating files for virtual servers to communicate with each other // creating files for virtual servers to communicate with each other

View File

@ -346,8 +346,7 @@ void function_table() {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
int iloop = 0; for (int iloop = 0; iloop < NUM_DET_FUNCTIONS; ++iloop) {
for (iloop = 0; iloop < NUM_DET_FUNCTIONS; ++iloop) {
LOG(logDEBUG3, ("function fnum=%d, (%s)\n", iloop, LOG(logDEBUG3, ("function fnum=%d, (%s)\n", iloop,
getFunctionNameFromEnum((enum detFuncs)iloop))); getFunctionNameFromEnum((enum detFuncs)iloop)));
} }
@ -4861,8 +4860,7 @@ void calculate_and_set_position() {
sscanf(dmac, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &a[0], &a[1], &a[2], sscanf(dmac, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &a[0], &a[1], &a[2],
&a[3], &a[4], &a[5]); &a[3], &a[4], &a[5]);
udpDetails.srcmac = 0; udpDetails.srcmac = 0;
int i; for (int i = 0; i < 6; ++i) {
for (i = 0; i < 6; ++i) {
udpDetails.srcmac = (udpDetails.srcmac << 8) + a[i]; udpDetails.srcmac = (udpDetails.srcmac << 8) + a[i];
} }
} }
@ -4878,8 +4876,7 @@ void calculate_and_set_position() {
sscanf(dmac2, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &a[0], &a[1], sscanf(dmac2, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &a[0], &a[1],
&a[2], &a[3], &a[4], &a[5]); &a[2], &a[3], &a[4], &a[5]);
udpDetails.srcmac2 = 0; udpDetails.srcmac2 = 0;
int i; for (int i = 0; i < 6; ++i) {
for (i = 0; i < 6; ++i) {
udpDetails.srcmac2 = (udpDetails.srcmac2 << 8) + a[i]; udpDetails.srcmac2 = (udpDetails.srcmac2 << 8) + a[i];
} }
} }
@ -6460,8 +6457,7 @@ int set_veto_photon(int file_des) {
numChannels, NCHAN); numChannels, NCHAN);
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else { } else {
int i = 0; for (int i = 0; i < NCHAN; ++i) {
for (i = 0; i < NCHAN; ++i) {
if (values[i] > ADU_MAX_VAL) { if (values[i] > ADU_MAX_VAL) {
ret = FAIL; ret = FAIL;
sprintf(mess, sprintf(mess,
@ -6515,8 +6511,7 @@ int get_veto_photon(int file_des) {
"same for all chips.\n"); "same for all chips.\n");
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else { } else {
int i = 0; for (int i = 0; i < NCHAN; ++i) {
for (i = 0; i < NCHAN; ++i) {
LOG(logDEBUG1, ("%d:0x%x\n", i, retvals[i])); LOG(logDEBUG1, ("%d:0x%x\n", i, retvals[i]));
} }
} }

View File

@ -1,197 +1,184 @@
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/select.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <termios.h> #include <termios.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <signal.h>
#include <errno.h>
#define UART_DEVICE "/dev/ttyAL0" #define UART_DEVICE "/dev/ttyAL0"
#ifdef DEBUG #ifdef DEBUG
#define DEBUG_PRINT(fmt, args...) fprintf(stderr, "DEBUG: %s:%d:%s(): " fmt, \ #define DEBUG_PRINT(fmt, args...) \
__FILE__, __LINE__, __func__, ##args) fprintf(stderr, "DEBUG: %s:%d:%s(): " fmt, __FILE__, __LINE__, __func__, \
##args)
#else #else
#define DEBUG_PRINT(fmt, args...) /* Don't do anything in release builds */ #define DEBUG_PRINT(fmt, args...) /* Don't do anything in release builds */
#endif #endif
struct termios oldtio; struct termios oldtio;
int uart; int uart;
int update_files = 1; int update_files = 1;
void intHandler(int signo) void intHandler(int signo) {
{ DEBUG_PRINT("signo %d received\n", signo);
DEBUG_PRINT("signo %d received\n", signo); if (signo == SIGINT) {
if (signo == SIGINT) DEBUG_PRINT("SIGINT handling\n");
{ tcsetattr(uart, TCSANOW, &oldtio);
DEBUG_PRINT("SIGINT handling\n"); close(uart);
tcsetattr(uart,TCSANOW,&oldtio); exit(0);
close(uart); }
exit(0); if (signo == SIGUSR1) {
} DEBUG_PRINT("SIGUSR1 handling\n");
if (signo == SIGUSR1) update_files = 1;
{ }
DEBUG_PRINT("SIGUSR1 handling\n");
update_files = 1;
}
} }
void kill_servers() void kill_servers() {
{ system("killall gotthard2DetectorServer mythen3DetectorServer "
system("killall gotthard2DetectorServer mythen3DetectorServer gotthard2DetectorServer_developer mythen3DetectorServer_developer"); "gotthard2DetectorServer_developer mythen3DetectorServer_developer");
} }
void set_hv_zero() void set_hv_zero() {
{ FILE *hv;
FILE* hv; hv = fopen("/etc/devlinks/hvdac", "w");
hv = fopen("/etc/devlinks/hvdac", "w"); if (hv == NULL)
if (hv == NULL) fprintf(stderr, "Could not open hvdac file.\n");
fprintf(stderr, "Could not open hvdac file.\n"); else {
else fputc('0', hv);
{ fclose(hv);
fputc('0', hv); }
fclose(hv);
}
} }
void disable_chip_power() void disable_chip_power() {
{ unsigned *mem_ptr;
unsigned* mem_ptr; unsigned mem_val;
unsigned mem_val; unsigned mem_address = 0x18040000;
unsigned mem_address = 0x18040000; int mem_desc;
int mem_desc; mem_desc = open("/dev/mem", O_RDWR | O_SYNC, 0);
mem_desc = open("/dev/mem", O_RDWR | O_SYNC, 0); if (mem_desc == -1)
if (mem_desc == -1) fprintf(stderr, "Cannot open /dev/mem\n");
fprintf(stderr, "Cannot open /dev/mem\n"); else {
else mem_ptr =
{ (unsigned *)mmap(0, 0x1000, PROT_READ | PROT_WRITE,
mem_ptr = (unsigned *) mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, mem_desc, mem_address); MAP_FILE | MAP_SHARED, mem_desc, mem_address);
if (mem_ptr == MAP_FAILED) if (mem_ptr == MAP_FAILED)
fprintf(stderr, "Cannot map memory area\n"); fprintf(stderr, "Cannot map memory area\n");
else else {
{ mem_val = mem_ptr[0x84 / 4];
mem_val = mem_ptr[0x84/4]; mem_val = mem_val & 0x7FFFFFFF; // Removes top bit
mem_val = mem_val & 0x7FFFFFFF; // Removes top bit mem_ptr[0x84 / 4] = mem_val;
mem_ptr[0x84/4] = mem_val; munmap((unsigned *)mem_address, 0x1000);
munmap((unsigned*) mem_address, 0x1000); }
} close(mem_desc);
close(mem_desc); }
}
} }
void prepare_for_shutdown() void prepare_for_shutdown() {
{ kill_servers();
kill_servers(); set_hv_zero();
set_hv_zero(); disable_chip_power();
disable_chip_power(); system("sync");
system("sync"); return;
return;
} }
int uart_setup(struct termios* old_settings) int uart_setup(struct termios *old_settings) {
{ int desc;
int desc; struct termios newtio;
struct termios newtio; desc = open(UART_DEVICE, O_RDWR | O_NOCTTY);
desc = open(UART_DEVICE, O_RDWR | O_NOCTTY); if (desc < 0) {
if (desc < 0) { perror(UART_DEVICE); exit(-1); } perror(UART_DEVICE);
tcgetattr(desc, old_settings); exit(-1);
newtio.c_cflag = B9600 | CS8 | CLOCAL | CREAD; }
newtio.c_iflag = IGNPAR | IGNCR | IXANY; tcgetattr(desc, old_settings);
newtio.c_oflag = 0; newtio.c_cflag = B9600 | CS8 | CLOCAL | CREAD;
newtio.c_lflag = ICANON; newtio.c_iflag = IGNPAR | IGNCR | IXANY;
tcflush(desc, TCIFLUSH); newtio.c_oflag = 0;
tcsetattr(desc,TCSANOW,&newtio); newtio.c_lflag = ICANON;
return desc; tcflush(desc, TCIFLUSH);
tcsetattr(desc, TCSANOW, &newtio);
return desc;
} }
int get_boot_condition() int get_boot_condition() {
{ FILE *ru_trig_cond;
FILE* ru_trig_cond; char ru_trig_cond_content[10];
char ru_trig_cond_content[10]; int bytes_read;
int bytes_read;
ru_trig_cond = fopen("/sys/devices/platform/sopc@0/18000000.bridge/180000c0.remoteupdate/remote_update/trig_cond","r"); ru_trig_cond = fopen("/sys/devices/platform/sopc@0/18000000.bridge/"
if (ru_trig_cond == NULL) "180000c0.remoteupdate/remote_update/trig_cond",
fprintf(stderr, "Cannot read remote update status\n"); "r");
bytes_read = fread(ru_trig_cond_content, 1, 10, ru_trig_cond); if (ru_trig_cond == NULL)
if (bytes_read < 4) fprintf(stderr, "Cannot read remote update status\n");
fprintf(stderr, "Invalid file content\n"); bytes_read = fread(ru_trig_cond_content, 1, 10, ru_trig_cond);
return strtoul(ru_trig_cond_content, NULL, 0); if (bytes_read < 4)
fprintf(stderr, "Invalid file content\n");
return strtoul(ru_trig_cond_content, NULL, 0);
} }
void write_cmd_in_file(char* cmd, char* filename, int lines) void write_cmd_in_file(char *cmd, char *filename, int lines) {
{ int res, i;
int res,i; char buf[255];
char buf[255]; FILE *cmd_file;
FILE* cmd_file; cmd_file = fopen(filename, "w");
cmd_file = fopen(filename, "w"); write(uart, cmd, 1);
write(uart, cmd, 1); for (i = 0; i < lines; i++) {
for (i=0; i < lines; i++) res = read(uart, buf, 255);
{ fwrite(buf, 1, res, cmd_file);
res = read(uart, buf, 255); }
fwrite(buf, 1, res, cmd_file); fclose(cmd_file);
}
fclose(cmd_file);
} }
int main(int argc, char *argv[]) {
char buf[255];
fd_set readfs;
int maxfd;
int res;
char factory_image_detected_cmd = 'f';
char get_voltage_cmd = 'u';
char get_versions_cmd = 'v';
char get_eventlog_cmd = 'e';
int main(int argc, char* argv[]) uart = uart_setup(&oldtio);
{ signal(SIGINT, intHandler);
char buf[255]; signal(SIGUSR1, intHandler);
fd_set readfs;
int maxfd;
int res;
char factory_image_detected_cmd = 'f';
char get_voltage_cmd = 'u';
char get_versions_cmd = 'v';
char get_eventlog_cmd = 'e';
uart = uart_setup(&oldtio); maxfd = uart + 1;
signal(SIGINT, intHandler);
signal(SIGUSR1, intHandler);
maxfd = uart+1; if (get_boot_condition() != 4)
write(uart, &factory_image_detected_cmd, 1);
if (get_boot_condition() != 4) while (1) {
write(uart, &factory_image_detected_cmd, 1); if (update_files == 1) {
DEBUG_PRINT("Updating files...\n");
write_cmd_in_file(&get_voltage_cmd, "/tmp/uc_voltage", 1);
write_cmd_in_file(&get_versions_cmd, "/tmp/uc_versions", 2);
write_cmd_in_file(&get_eventlog_cmd, "/tmp/uc_eventlog", 16);
update_files = 0;
}
FD_SET(uart, &readfs);
res = select(maxfd, &readfs, NULL, NULL, NULL);
if ((res == -1) && (errno == EINTR)) // If SIGUSR1 occured
continue;
if (FD_ISSET(uart, &readfs)) {
res = read(uart, buf, 255);
buf[res] = 0;
DEBUG_PRINT("-->%s:%d<--", buf, res);
if ((buf[0] == 'S') && (res < 5)) {
prepare_for_shutdown();
exit(0);
}
}
usleep(1000);
}
// Should never get here
tcsetattr(uart, TCSANOW, &oldtio);
while (1) return 0;
{
if (update_files == 1)
{
DEBUG_PRINT("Updating files...\n");
write_cmd_in_file(&get_voltage_cmd, "/tmp/uc_voltage", 1);
write_cmd_in_file(&get_versions_cmd, "/tmp/uc_versions", 2);
write_cmd_in_file(&get_eventlog_cmd, "/tmp/uc_eventlog", 16);
update_files = 0;
}
FD_SET(uart, &readfs);
res = select(maxfd, &readfs, NULL, NULL, NULL);
if ((res == -1) && (errno == EINTR)) // If SIGUSR1 occured
continue;
if (FD_ISSET(uart,&readfs))
{
res = read(uart, buf, 255);
buf[res] = 0;
DEBUG_PRINT("-->%s:%d<--", buf, res);
if ((buf[0] == 'S') && (res < 5))
{
prepare_for_shutdown();
exit(0);
}
}
usleep(1000);
}
// Should never get here
tcsetattr(uart,TCSANOW,&oldtio);
return 0;
} }

View File

@ -153,15 +153,16 @@ void BinaryFile::CreateMasterFile(bool masterFileWriteEnable,
// create master file // create master file
if (!(*overWriteEnable)) { if (!(*overWriteEnable)) {
if (nullptr == (masterfd = fopen((const char *)masterFileName.c_str(), if (nullptr == (masterfd = fopen(
"wx"))) { (const char *)masterFileName.c_str(), "wx"))) {
masterfd = nullptr; masterfd = nullptr;
throw sls::RuntimeError("Could not create binary master file " throw sls::RuntimeError("Could not create binary master file "
"(without overwrite enable) " + "(without overwrite enable) " +
masterFileName); masterFileName);
} }
} else if (nullptr == (masterfd = fopen( } else if (nullptr ==
(const char *)masterFileName.c_str(), "w"))) { (masterfd =
fopen((const char *)masterFileName.c_str(), "w"))) {
masterfd = nullptr; masterfd = nullptr;
throw sls::RuntimeError("Could not create binary master file " throw sls::RuntimeError("Could not create binary master file "
"(with overwrite enable) " + "(with overwrite enable) " +

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "TypeTraits.h"
#include "ToString.h" #include "ToString.h"
#include "TypeTraits.h"
#include <array> #include <array>
#include <cassert> #include <cassert>
#include <iostream> #include <iostream>
@ -189,7 +189,4 @@ std::ostream &operator<<(std::ostream &os,
return os << ToString(c); return os << ToString(c);
} }
} // namespace sls } // namespace sls

View File

@ -264,10 +264,10 @@ ToString(const T &obj) {
} }
template <typename T> template <typename T>
std::vector<T> StringTo(const std::vector<std::string>& strings){ std::vector<T> StringTo(const std::vector<std::string> &strings) {
std::vector<T> result; std::vector<T> result;
result.reserve(strings.size()); result.reserve(strings.size());
for (const auto& s : strings) for (const auto &s : strings)
result.push_back(StringTo<T>(s)); result.push_back(StringTo<T>(s));
return result; return result;
} }

View File

@ -3,10 +3,10 @@
#define APILIB 0x200409 #define APILIB 0x200409
#define APIRECEIVER 0x200409 #define APIRECEIVER 0x200409
#define APIGUI 0x200409 #define APIGUI 0x200409
#define APICTB 0x200609 #define APICTB 0x200610
#define APIGOTTHARD 0x200609 #define APIGOTTHARD 0x200610
#define APIGOTTHARD2 0x200609 #define APIJUNGFRAU 0x200610
#define APIJUNGFRAU 0x200609 #define APIMYTHEN3 0x200610
#define APIMYTHEN3 0x200609 #define APIMOENCH 0x200610
#define APIMOENCH 0x200608 #define APIGOTTHARD2 0x200610
#define APIEIGER 0x200609 #define APIEIGER 0x200615

View File

@ -3,8 +3,8 @@
#include "catch.hpp" #include "catch.hpp"
#include <array> #include <array>
#include <vector>
#include <sstream> #include <sstream>
#include <vector>
using sls::StaticVector; using sls::StaticVector;
TEST_CASE("StaticVector is a container") { TEST_CASE("StaticVector is a container") {

View File

@ -31,7 +31,6 @@ TEST_CASE("copy a long string") {
} }
#endif #endif
TEST_CASE("split a string with end delimiter") { TEST_CASE("split a string with end delimiter") {
std::string s("abra+kadabra+"); std::string s("abra+kadabra+");
auto r = sls::split(s, '+'); auto r = sls::split(s, '+');
@ -49,7 +48,6 @@ TEST_CASE("split a string without end delimiter") {
REQUIRE(r[2] == "filibom"); REQUIRE(r[2] == "filibom");
} }
TEST_CASE("Remove char from string") { TEST_CASE("Remove char from string") {
char str[] = "sometest"; char str[] = "sometest";
sls::removeChar(str, 'e'); sls::removeChar(str, 'e');