formatting

This commit is contained in:
maliakal_d 2022-11-18 14:26:58 +01:00
parent 2dcf4a7144
commit f6241f7a5e
5 changed files with 209 additions and 255 deletions

View File

@ -1,20 +1,17 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <sys/utsname.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <math.h>
#include <fcntl.h>
#include <math.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
@ -37,10 +34,13 @@ int main(int argc, char *argv[]) {
bit[1] = 8;
// for (iarg=0; iarg<argc; iarg++) printf("%d %s\n",iarg, argv[iarg]);
if (argc<2) printf("Error: usage is %s fname [dr off b0 b1 bn]\n");
if (argc < 2)
printf("Error: usage is %s fname [dr off b0 b1 bn]\n");
if (argc>2) dr=atoi(argv[2]);
if (argc>3) off=atoi(argv[3]);
if (argc > 2)
dr = atoi(argv[2]);
if (argc > 3)
off = atoi(argv[3]);
if (argc > 4) {
for (ib = 0; ib < 64; ib++) {
if (argc > 4 + ib) {
@ -48,7 +48,6 @@ int main(int argc, char *argv[]) {
nb++;
}
}
}
idr = 0;
@ -56,7 +55,6 @@ int main(int argc, char *argv[]) {
val[ib] = 0;
}
fdin = fopen(argv[1], "rb");
if (fdin == NULL) {
printf("Cannot open input file %s for reading\n", argv[1]);
@ -65,11 +63,13 @@ int main(int argc, char *argv[]) {
while (fread((void *)&word, 8, 1, fdin)) {
// printf("%llx\n",word);
if (ioff<off) ioff++;
if (ioff < off)
ioff++;
else {
for (ib = 0; ib < nb; ib++) {
if (word&(1<<bit[ib])) val[ib]|=(1<<idr);
if (word & (1 << bit[ib]))
val[ib] |= (1 << idr);
}
idr++;
if (idr == dr) {
@ -87,9 +87,7 @@ int main(int argc, char *argv[]) {
}
fprintf(stdout, "\n");
}
}
}
if (idr != 0) {
fprintf(stdout, "%d\t", iw++);

View File

@ -3,41 +3,40 @@
/****************************************************************************
usage to generate a patter test.pat from test.p
gcc -DINFILE="\"test.p\"" -DOUTFILE="\"test.pat\"" -o test.exe generator.c ; ./test.exe ; rm test.exe
gcc -DINFILE="\"test.p\"" -DOUTFILE="\"test.pat\"" -o test.exe generator.c ;
./test.exe ; rm test.exe
*************************************************************************/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <sys/utsname.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <math.h>
#include <fcntl.h>
#include <math.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <unistd.h>
#define MAXLOOPS 6
#define MAXTIMERS 6
#define MAXWORDS 8191
uint64_t pat = 0;
uint64_t iopat = 0;
uint64_t clkpat = 0;
unsigned iaddr = 0;
unsigned waitaddr[MAXTIMERS]={MAXWORDS,MAXWORDS,MAXWORDS, MAXWORDS, MAXWORDS, MAXWORDS};
unsigned startloopaddr[MAXLOOPS]={MAXWORDS,MAXWORDS,MAXWORDS, MAXWORDS, MAXWORDS, MAXWORDS};
unsigned stoploopaddr[MAXLOOPS]={MAXWORDS,MAXWORDS,MAXWORDS, MAXWORDS, MAXWORDS, MAXWORDS};
unsigned waitaddr[MAXTIMERS] = {MAXWORDS, MAXWORDS, MAXWORDS,
MAXWORDS, MAXWORDS, MAXWORDS};
unsigned startloopaddr[MAXLOOPS] = {MAXWORDS, MAXWORDS, MAXWORDS,
MAXWORDS, MAXWORDS, MAXWORDS};
unsigned stoploopaddr[MAXLOOPS] = {MAXWORDS, MAXWORDS, MAXWORDS,
MAXWORDS, MAXWORDS, MAXWORDS};
unsigned start = 0, stop = 0;
uint64_t waittime[MAXTIMERS] = {0, 0, 0, 0, 0, 0};
unsigned nloop[MAXLOOPS] = {0, 0, 0, 0, 0, 0};
@ -48,125 +47,93 @@ FILE *fd, *fd1;
uint64_t PAT[MAXWORDS];
int iopat_enable = 0;
int i, ii, iii, j, jj, jjj, pixx, pixy, memx, memy, muxout, memclk, colclk,
rowclk, muxclk, memcol, memrow, loopcounter;
int i,ii,iii,j,jj,jjj,pixx,pixy,memx,memy,muxout,memclk,colclk,rowclk,muxclk,memcol,memrow,loopcounter;
void setstart() { start = iaddr; }
void setstart()
{
start=iaddr;
}
void setstop() { stop = iaddr; }
void setstop()
{
stop=iaddr;
}
void setinput(int bit)
{
void setinput(int bit) {
uint64_t mask = 1;
mask = mask << bit;
iopat &= ~mask;
iopat_enable = 1;
}
void setoutput(int bit)
{
void setoutput(int bit) {
uint64_t mask = 1;
mask = mask << bit;
iopat |= mask;
iopat_enable = 1;
}
void clearbit(int bit)
{
void clearbit(int bit) {
uint64_t mask = 1;
mask = mask << bit;
pat &= ~mask;
}
void setbit(int bit)
{
void setbit(int bit) {
uint64_t mask = 1;
mask = mask << bit;
pat |= mask;
}
int checkbit(int bit)
{
int checkbit(int bit) {
uint64_t mask = 1;
mask = mask << bit;
return (pat & mask) >> bit;
}
void setstartloop(int iloop)
{
if (iloop>=0 && iloop<MAXLOOPS)
{
void setstartloop(int iloop) {
if (iloop >= 0 && iloop < MAXLOOPS) {
startloopaddr[iloop] = iaddr;
}
}
void setstoploop(int iloop)
{
if (iloop>=0 && iloop<MAXLOOPS)
{
void setstoploop(int iloop) {
if (iloop >= 0 && iloop < MAXLOOPS) {
stoploopaddr[iloop] = iaddr;
}
}
void setnloop(int iloop, int n)
{
if (iloop>=0 && iloop<MAXLOOPS)
{
void setnloop(int iloop, int n) {
if (iloop >= 0 && iloop < MAXLOOPS) {
nloop[iloop] = n;
}
}
void setwaitpoint(int iloop)
{
if (iloop>=0 && iloop<MAXTIMERS)
{
void setwaitpoint(int iloop) {
if (iloop >= 0 && iloop < MAXTIMERS) {
waitaddr[iloop] = iaddr;
}
}
void setwaittime(int iloop, uint64_t t)
{
if (iloop>=0 && iloop<MAXTIMERS)
{
void setwaittime(int iloop, uint64_t t) {
if (iloop >= 0 && iloop < MAXTIMERS) {
waittime[iloop] = t;
}
}
void pw()
{
if (iaddr<MAXWORDS)
{
void pw() {
if (iaddr < MAXWORDS) {
PAT[iaddr] = pat;
}
fprintf(fd, "patword 0x%04x 0x%016llx\n", iaddr, pat);
iaddr++;
if (iaddr>=MAXWORDS)
{
printf("ERROR: too many word in the pattern (%d instead of %d)!",iaddr, MAXWORDS);
if (iaddr >= MAXWORDS) {
printf("ERROR: too many word in the pattern (%d instead of %d)!", iaddr,
MAXWORDS);
}
}
int parseCommand(int clk, int cmdbit, int cmd, int length)
{
int parseCommand(int clk, int cmdbit, int cmd, int length) {
int ibit;
clearbit(clk);
for (ibit=0; ibit<length; ibit++)
{
if (cmd&(1>>ibit))
{
for (ibit = 0; ibit < length; ibit++) {
if (cmd & (1 >> ibit)) {
setbit(cmdbit);
}
else
{
} else {
clearbit(cmdbit);
}
pw();
@ -177,8 +144,6 @@ int parseCommand(int clk, int cmdbit, int cmd, int length)
}
};
int main() {
int iloop = 0;
fd = fopen(OUTFILE, "w");
@ -186,28 +151,24 @@ int main() {
fprintf(fd, "patlimits 0x%04x 0x%04x\n", start, stop);
if (iopat_enable == 1)
{
if (iopat_enable == 1) {
fprintf(fd, "patioctrl 0x%016llx\n", iopat);
}
for (iloop=0; iloop<MAXLOOPS; iloop++)
{
if ( (startloopaddr[iloop] != MAXWORDS) && (stoploopaddr[iloop] != MAXWORDS) )
{
fprintf(fd,"patloop %d 0x%04x 0x%04x\n",iloop, startloopaddr[iloop], stoploopaddr[iloop]);
if (stoploopaddr[iloop]<= startloopaddr[iloop])
{
for (iloop = 0; iloop < MAXLOOPS; iloop++) {
if ((startloopaddr[iloop] != MAXWORDS) &&
(stoploopaddr[iloop] != MAXWORDS)) {
fprintf(fd, "patloop %d 0x%04x 0x%04x\n", iloop,
startloopaddr[iloop], stoploopaddr[iloop]);
if (stoploopaddr[iloop] <= startloopaddr[iloop]) {
nloop[iloop] = 0;
}
fprintf(fd, "patnloop %d %u\n", iloop, nloop[iloop]);
}
}
for (iloop=0; iloop<MAXTIMERS; iloop++)
{
if (waitaddr[iloop] != MAXWORDS)
{
for (iloop = 0; iloop < MAXTIMERS; iloop++) {
if (waitaddr[iloop] != MAXWORDS) {
fprintf(fd, "patwait %d 0x%04x\n", iloop, waitaddr[iloop]);
fprintf(fd, "patwaittime %d %llu\n", iloop, waittime[iloop]);
}

View File

@ -2461,7 +2461,6 @@ int startStateMachine() {
Feb_Control_Get_Counter_Bit()));
Feb_Control_PrepareForAcquisition();
LOG(logINFO, ("Acquisition started bit toggled\n"));
int ret = OK, prev_flag;
// get the DAQ toggle bit

View File

@ -159,8 +159,7 @@ int sharedMemory_initialize() {
return FAIL;
}
if (pthread_mutex_init(&(shm->lockAcqFlag), &lockAcqFlagAttribute) !=
0) {
if (pthread_mutex_init(&(shm->lockAcqFlag), &lockAcqFlagAttribute) != 0) {
LOG(logERROR, ("Failed to initialize pthread_mutex_t lockAcqFlag for "
"shared memory\n"));
return FAIL;
@ -293,7 +292,5 @@ void sharedMemory_unlockLocalLink() {
void sharedMemory_lockAcqFlag() { pthread_mutex_lock(&(shm->lockAcqFlag)); }
void sharedMemory_unlockAcqFlag() {
pthread_mutex_unlock(&(shm->lockAcqFlag));
}
void sharedMemory_unlockAcqFlag() { pthread_mutex_unlock(&(shm->lockAcqFlag)); }
#endif

View File

@ -14,7 +14,6 @@ namespace sls {
#define gettid() syscall(SYS_gettid)
#endif
Arping::Arping() {}
Arping::~Arping() {