moduleid made into dec not hex

This commit is contained in:
maliakal_d 2021-10-05 13:23:09 +02:00
parent fb94ddec74
commit 7d927a794e
9 changed files with 10 additions and 44 deletions

View File

@ -1 +1 @@
0xbeb001
001

View File

@ -1 +1 @@
0xbeb001
031

View File

@ -292,7 +292,7 @@ int getModuleId(int *ret, char *mess) {
}
void setModuleId(int modid) {
LOG(logINFOBLUE, ("Setting module id in fpga: 0x%x\n", modid))
LOG(logINFOBLUE, ("Setting module id in fpga: %d\n", modid))
bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) & ~MOD_ID_MSK);
bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) | ((modid << MOD_ID_OFST) & MOD_ID_MSK));
}

View File

@ -287,7 +287,7 @@ int getModuleId(int *ret, char *mess) {
}
void setModuleId(int modid) {
LOG(logINFOBLUE, ("Setting module id in fpga: 0x%x\n", modid))
LOG(logINFOBLUE, ("Setting module id in fpga: %d\n", modid))
bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) & ~MOD_ID_MSK);
bus_w(MOD_ID_REG,
bus_r(MOD_ID_REG) | ((modid << MOD_ID_OFST) & MOD_ID_MSK));

View File

@ -32,7 +32,6 @@ void validate64(int *ret, char *mess, int64_t arg, int64_t retval,
char *modename, enum numberMode nummode);
int getModuleIdInFile(int *ret, char *mess, char *fileName);
int setModuleIdInFile(char *mess, int arg, char *fileName);
int verifyChecksumFromBuffer(char *mess, char *clientChecksum, char *buffer,
ssize_t bytes);
int verifyChecksumFromFile(char *mess, char *clientChecksum, char *fname);

View File

@ -120,7 +120,7 @@ int getModuleIdInFile(int *ret, char *mess, char *fileName) {
LOG(logERROR, ("%s\n\n", mess));
return -1;
}
LOG(logDEBUG1, ("Reading det id file %s\n", fileName));
LOG(logINFOBLUE, ("Reading det id file %s\n", fileName));
// read line
const size_t len = 256;
@ -134,7 +134,7 @@ int getModuleIdInFile(int *ret, char *mess, char *fileName) {
}
// read id
int retval = 0;
if (sscanf(line, "%x", &retval) != 1) {
if (sscanf(line, "%u", &retval) != 1) {
*ret = FAIL;
sprintf(mess,
"Could not scan det id from on-board server "
@ -143,43 +143,10 @@ int getModuleIdInFile(int *ret, char *mess, char *fileName) {
LOG(logERROR, ("%s\n\n", mess));
return -1;
}
LOG(logINFOBLUE, ("Module Id: 0x%x (File)\n", retval));
LOG(logINFOBLUE, ("Module Id: %d (File)\n", retval));
return retval;
}
int setModuleIdInFile(char *mess, int arg, char *fileName) {
LOG(logINFOBLUE, ("Setting Module Id: 0x%x (File)\n", arg));
const int fileNameSize = 128;
char fname[fileNameSize];
if (getAbsPath(fname, fileNameSize, fileName) == FAIL) {
strcpy(mess, "Could not find detid file\n");
LOG(logERROR, (mess));
return FAIL;
}
// open id file
FILE *fd = fopen(fname, "r");
if (fd == NULL) {
strcpy(mess, "Could not find detid file\n");
LOG(logERROR, (mess));
return FAIL;
}
LOG(logDEBUG1, ("Writing det id to file %s\n", fileName));
// write id
const size_t len = 256;
char line[len];
memset(line, 0, len);
sprintf(line, "%x", arg);
if (EOF == fputs(line, fd)) {
strcpy(mess, "Could not write to detid file\n");
LOG(logERROR, (mess));
return FAIL;
}
return OK;
}
int verifyChecksumFromBuffer(char *mess, char *clientChecksum, char *buffer,
ssize_t bytes) {
LOG(logINFO, ("\tVerifying Checksum...\n"));

View File

@ -1206,7 +1206,7 @@ class CmdProxy {
"\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench]"
"Serial number of detector.");
GET_COMMAND_HEX(
GET_COMMAND(
moduleid, getModuleId,
"\n\t[Gotthard2][Eiger][Mythen3] 16 bit value (ideally unique) "
"that is streamed out in the UDP header of the detector. Picked up from a file on the module.");