mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-21 09:08:00 +02:00
binaries in, std=gnu99, for loop variable declaration inside for loop
This commit is contained in:
@ -219,8 +219,7 @@ void AD7689_Configure() {
|
||||
LOG(logINFO,
|
||||
("\tConfiguring %d x due to invalid conversions from power up\n",
|
||||
AD7689_NUM_INVALID_CONVERSIONS));
|
||||
int i = 0;
|
||||
for (i = 0; i < AD7689_NUM_INVALID_CONVERSIONS; ++i) {
|
||||
for (int i = 0; i < AD7689_NUM_INVALID_CONVERSIONS; ++i) {
|
||||
AD7689_Set(
|
||||
// read back
|
||||
AD7689_CFG_RB_MSK |
|
||||
|
@ -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));
|
||||
{
|
||||
LOG(logDEBUG2, ("\t[values: \n"));
|
||||
int i;
|
||||
for (i = 0; i < length; ++i) {
|
||||
for (int i = 0; i < length; ++i) {
|
||||
LOG(logDEBUG2, ("\t%d: 0x%02hhx\n", i, buffer[i]));
|
||||
}
|
||||
LOG(logDEBUG2, ("\t]\n"));
|
||||
|
@ -234,10 +234,8 @@ uint32_t I2C_Read(uint32_t devId, uint32_t addr) {
|
||||
int level = bus_r(I2C_Rx_Data_Fifo_Level_Reg);
|
||||
LOG(logDEBUG2, (" level:%d\n", level));
|
||||
|
||||
int iloop = level - 1;
|
||||
|
||||
// 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 =
|
||||
bus_r(I2C_Rx_Data_Fifo_Reg) & I2C_RX_DATA_FIFO_RXDATA_MSK;
|
||||
LOG(logDEBUG2, (" byte nr %d:0x%x\n", iloop, byte));
|
||||
|
@ -116,7 +116,6 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
|
||||
|
||||
int nchip = LTC2620_Ndac / LTC2620_NUMCHANNELS;
|
||||
uint32_t valw = 0;
|
||||
int ichip = 0;
|
||||
|
||||
LOG(logDEBUG2, ("(Daisy) desired chip index:%d, nchip:%d, dac ch:%d, "
|
||||
"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
|
||||
if (chipIndex < 0) {
|
||||
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));
|
||||
LTC2620_SendDaisyData(&valw, codata);
|
||||
}
|
||||
@ -146,7 +145,7 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
|
||||
else {
|
||||
// send nothing to subsequent ichips (daisy chain) (if any chips after
|
||||
// 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));
|
||||
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
|
||||
// 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));
|
||||
LTC2620_SendDaisyData(&valw, LTC2620_DAC_CMD_NO_OPRTN_VAL);
|
||||
}
|
||||
|
@ -83,8 +83,7 @@ void sendDataToSPI(uint32_t *valw, uint32_t addr, uint32_t val,
|
||||
"clkmask:0x%x digmask:0x%x digofst:%d\n",
|
||||
*valw, addr, val, numbitstosend, clkmask, digoutmask, digofset));
|
||||
|
||||
int i = 0;
|
||||
for (i = 0; i < numbitstosend; ++i) {
|
||||
for (int i = 0; i < numbitstosend; ++i) {
|
||||
|
||||
// clk down
|
||||
(*valw) &= ~clkmask;
|
||||
@ -112,9 +111,7 @@ uint32_t receiveDataFromSPI(uint32_t *valw, uint32_t addr, int numbitstoreceive,
|
||||
*valw, addr, numbitstoreceive, clkmask, readaddr));
|
||||
|
||||
uint32_t retval = 0;
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < numbitstoreceive; ++i) {
|
||||
for (int i = 0; i < numbitstoreceive; ++i) {
|
||||
|
||||
// clk down
|
||||
(*valw) &= ~clkmask;
|
||||
|
@ -121,7 +121,6 @@ int bindSocket(unsigned short int port_number) {
|
||||
}
|
||||
|
||||
int acceptConnection(int socketDescriptor) {
|
||||
int j;
|
||||
struct sockaddr_in addressC;
|
||||
int file_des = -1;
|
||||
struct timeval tv;
|
||||
@ -159,7 +158,7 @@ int acceptConnection(int socketDescriptor) {
|
||||
("%s select returned!\n", (isControlServer ? "control" : "stop")));
|
||||
|
||||
// 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
|
||||
if (FD_ISSET(j, &tempset)) {
|
||||
@ -264,11 +263,10 @@ void exitServer(int socketDescriptor) {
|
||||
}
|
||||
|
||||
void swapData(void *val, int length, intType itype) {
|
||||
int i;
|
||||
int16_t *c = (int16_t *)val;
|
||||
int32_t *a = (int32_t *)val;
|
||||
int64_t *b = (int64_t *)val;
|
||||
for (i = 0; length > 0; i++) {
|
||||
for (int i = 0; length > 0; i++) {
|
||||
switch (itype) {
|
||||
case INT16:
|
||||
c[i] = ((c[i] & 0x00FF) << 8) | ((c[i] & 0xFF00) >> 8);
|
||||
|
@ -89,8 +89,7 @@ int mapCSP0(void) {
|
||||
u_int32_t **cspbases[2] = {&csp0base, &csp1base};
|
||||
char names[2][10] = {"csp0base", "csp1base"};
|
||||
|
||||
int i = 0;
|
||||
for (i = 0; i < 2; ++i) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
// if not mapped
|
||||
if (*cspbases[i] == 0) {
|
||||
LOG(logINFO, ("Mapping memory for %s\n", names[i]));
|
||||
|
@ -60,46 +60,43 @@ int main(int argc, char *argv[]) {
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
// circumvent the basic tests
|
||||
{
|
||||
int i;
|
||||
for (i = 1; i < argc; ++i) {
|
||||
if (!strcasecmp(argv[i], "-stopserver")) {
|
||||
LOG(logINFO, ("Detected stop server\n"));
|
||||
isControlServer = 0;
|
||||
} else if (!strcasecmp(argv[i], "-devel")) {
|
||||
LOG(logINFO, ("Detected developer mode\n"));
|
||||
debugflag = 1;
|
||||
} else if (!strcasecmp(argv[i], "-nomodule")) {
|
||||
LOG(logINFO, ("Detected No Module mode\n"));
|
||||
checkModuleFlag = 0;
|
||||
} else if (!strcasecmp(argv[i], "-port")) {
|
||||
if ((i + 1) >= argc) {
|
||||
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));
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (!strcasecmp(argv[i], "-stopserver")) {
|
||||
LOG(logINFO, ("Detected stop server\n"));
|
||||
isControlServer = 0;
|
||||
} else if (!strcasecmp(argv[i], "-devel")) {
|
||||
LOG(logINFO, ("Detected developer mode\n"));
|
||||
debugflag = 1;
|
||||
} else if (!strcasecmp(argv[i], "-nomodule")) {
|
||||
LOG(logINFO, ("Detected No Module mode\n"));
|
||||
checkModuleFlag = 0;
|
||||
} else if (!strcasecmp(argv[i], "-port")) {
|
||||
if ((i + 1) >= argc) {
|
||||
LOG(logERROR, ("no port value given. Exiting.\n"));
|
||||
return -1;
|
||||
}
|
||||
#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));
|
||||
if (sscanf(argv[i + 1], "%d", &portno) == 0) {
|
||||
LOG(logERROR, ("cannot decode port value %s. Exiting.\n",
|
||||
argv[i + 1]));
|
||||
return -1;
|
||||
}
|
||||
#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
|
||||
@ -108,26 +105,23 @@ int main(int argc, char *argv[]) {
|
||||
// start stop server process
|
||||
char cmd[MAX_STR_LENGTH];
|
||||
memset(cmd, 0, MAX_STR_LENGTH);
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < argc; ++i) {
|
||||
if (!strcasecmp(argv[i], "-port")) {
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
if (i > 0) {
|
||||
strcat(cmd, " ");
|
||||
}
|
||||
strcat(cmd, argv[i]);
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
if (!strcasecmp(argv[i], "-port")) {
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
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);
|
||||
if (i > 0) {
|
||||
strcat(cmd, " ");
|
||||
}
|
||||
strcat(cmd, argv[i]);
|
||||
}
|
||||
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));
|
||||
#ifdef VIRTUAL
|
||||
// creating files for virtual servers to communicate with each other
|
||||
|
@ -346,8 +346,7 @@ void function_table() {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int iloop = 0;
|
||||
for (iloop = 0; iloop < NUM_DET_FUNCTIONS; ++iloop) {
|
||||
for (int iloop = 0; iloop < NUM_DET_FUNCTIONS; ++iloop) {
|
||||
LOG(logDEBUG3, ("function fnum=%d, (%s)\n", 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],
|
||||
&a[3], &a[4], &a[5]);
|
||||
udpDetails.srcmac = 0;
|
||||
int i;
|
||||
for (i = 0; i < 6; ++i) {
|
||||
for (int i = 0; i < 6; ++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],
|
||||
&a[2], &a[3], &a[4], &a[5]);
|
||||
udpDetails.srcmac2 = 0;
|
||||
int i;
|
||||
for (i = 0; i < 6; ++i) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
udpDetails.srcmac2 = (udpDetails.srcmac2 << 8) + a[i];
|
||||
}
|
||||
}
|
||||
@ -6460,8 +6457,7 @@ int set_veto_photon(int file_des) {
|
||||
numChannels, NCHAN);
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
int i = 0;
|
||||
for (i = 0; i < NCHAN; ++i) {
|
||||
for (int i = 0; i < NCHAN; ++i) {
|
||||
if (values[i] > ADU_MAX_VAL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
@ -6515,8 +6511,7 @@ int get_veto_photon(int file_des) {
|
||||
"same for all chips.\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
int i = 0;
|
||||
for (i = 0; i < NCHAN; ++i) {
|
||||
for (int i = 0; i < NCHAN; ++i) {
|
||||
LOG(logDEBUG1, ("%d:0x%x\n", i, retvals[i]));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user