formatting

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

View File

@ -3,41 +3,40 @@
/**************************************************************************** /****************************************************************************
usage to generate a patter test.pat from test.p 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 <errno.h>
#include <math.h>
#include <fcntl.h> #include <fcntl.h>
#include <math.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <unistd.h> #include <unistd.h>
#define MAXLOOPS 6 #define MAXLOOPS 6
#define MAXTIMERS 6 #define MAXTIMERS 6
#define MAXWORDS 8191 #define MAXWORDS 8191
uint64_t pat = 0; uint64_t pat = 0;
uint64_t iopat = 0; uint64_t iopat = 0;
uint64_t clkpat = 0; uint64_t clkpat = 0;
unsigned iaddr = 0; unsigned iaddr = 0;
unsigned waitaddr[MAXTIMERS]={MAXWORDS,MAXWORDS,MAXWORDS, MAXWORDS, MAXWORDS, MAXWORDS}; unsigned waitaddr[MAXTIMERS] = {MAXWORDS, MAXWORDS, MAXWORDS,
unsigned startloopaddr[MAXLOOPS]={MAXWORDS,MAXWORDS,MAXWORDS, MAXWORDS, MAXWORDS, MAXWORDS}; MAXWORDS, MAXWORDS, MAXWORDS};
unsigned stoploopaddr[MAXLOOPS]={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; unsigned start = 0, stop = 0;
uint64_t waittime[MAXTIMERS] = {0, 0, 0, 0, 0, 0}; uint64_t waittime[MAXTIMERS] = {0, 0, 0, 0, 0, 0};
unsigned nloop[MAXLOOPS] = {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]; uint64_t PAT[MAXWORDS];
int iopat_enable = 0; 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() void setstop() { stop = iaddr; }
{
start=iaddr;
}
void setstop() void setinput(int bit) {
{
stop=iaddr;
}
void setinput(int bit)
{
uint64_t mask = 1; uint64_t mask = 1;
mask = mask << bit; mask = mask << bit;
iopat &= ~mask; iopat &= ~mask;
iopat_enable = 1; iopat_enable = 1;
} }
void setoutput(int bit) void setoutput(int bit) {
{
uint64_t mask = 1; uint64_t mask = 1;
mask = mask << bit; mask = mask << bit;
iopat |= mask; iopat |= mask;
iopat_enable = 1; iopat_enable = 1;
} }
void clearbit(int bit) void clearbit(int bit) {
{
uint64_t mask = 1; uint64_t mask = 1;
mask = mask << bit; mask = mask << bit;
pat &= ~mask; pat &= ~mask;
} }
void setbit(int bit) void setbit(int bit) {
{
uint64_t mask = 1; uint64_t mask = 1;
mask = mask << bit; mask = mask << bit;
pat |= mask; pat |= mask;
} }
int checkbit(int bit) int checkbit(int bit) {
{
uint64_t mask = 1; uint64_t mask = 1;
mask = mask << bit; mask = mask << bit;
return (pat & mask) >> bit; return (pat & mask) >> bit;
} }
void setstartloop(int iloop) void setstartloop(int iloop) {
{ if (iloop >= 0 && iloop < MAXLOOPS) {
if (iloop>=0 && iloop<MAXLOOPS)
{
startloopaddr[iloop] = iaddr; startloopaddr[iloop] = iaddr;
} }
} }
void setstoploop(int iloop) {
void setstoploop(int iloop) if (iloop >= 0 && iloop < MAXLOOPS) {
{
if (iloop>=0 && iloop<MAXLOOPS)
{
stoploopaddr[iloop] = iaddr; stoploopaddr[iloop] = iaddr;
} }
} }
void setnloop(int iloop, int n) {
void setnloop(int iloop, int n) if (iloop >= 0 && iloop < MAXLOOPS) {
{
if (iloop>=0 && iloop<MAXLOOPS)
{
nloop[iloop] = n; nloop[iloop] = n;
} }
} }
void setwaitpoint(int iloop) void setwaitpoint(int iloop) {
{ if (iloop >= 0 && iloop < MAXTIMERS) {
if (iloop>=0 && iloop<MAXTIMERS)
{
waitaddr[iloop] = iaddr; waitaddr[iloop] = iaddr;
} }
} }
void setwaittime(int iloop, uint64_t t) {
void setwaittime(int iloop, uint64_t t) if (iloop >= 0 && iloop < MAXTIMERS) {
{
if (iloop>=0 && iloop<MAXTIMERS)
{
waittime[iloop] = t; waittime[iloop] = t;
} }
} }
void pw() {
void pw() if (iaddr < MAXWORDS) {
{
if (iaddr<MAXWORDS)
{
PAT[iaddr] = pat; PAT[iaddr] = pat;
} }
fprintf(fd, "patword 0x%04x 0x%016llx\n", iaddr, pat); fprintf(fd, "patword 0x%04x 0x%016llx\n", iaddr, pat);
iaddr++; iaddr++;
if (iaddr>=MAXWORDS) if (iaddr >= MAXWORDS) {
{ printf("ERROR: too many word in the pattern (%d instead of %d)!", iaddr,
printf("ERROR: too many word in the pattern (%d instead of %d)!",iaddr, MAXWORDS); MAXWORDS);
} }
} }
int parseCommand(int clk, int cmdbit, int cmd, int length) int parseCommand(int clk, int cmdbit, int cmd, int length) {
{
int ibit; int ibit;
clearbit(clk); clearbit(clk);
for (ibit=0; ibit<length; ibit++) for (ibit = 0; ibit < length; ibit++) {
{ if (cmd & (1 >> ibit)) {
if (cmd&(1>>ibit))
{
setbit(cmdbit); setbit(cmdbit);
} } else {
else
{
clearbit(cmdbit); clearbit(cmdbit);
} }
pw(); pw();
@ -177,8 +144,6 @@ int parseCommand(int clk, int cmdbit, int cmd, int length)
} }
}; };
int main() { int main() {
int iloop = 0; int iloop = 0;
fd = fopen(OUTFILE, "w"); fd = fopen(OUTFILE, "w");
@ -186,28 +151,24 @@ int main() {
fprintf(fd, "patlimits 0x%04x 0x%04x\n", start, stop); 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); fprintf(fd, "patioctrl 0x%016llx\n", iopat);
} }
for (iloop=0; iloop<MAXLOOPS; iloop++) for (iloop = 0; iloop < MAXLOOPS; iloop++) {
{ if ((startloopaddr[iloop] != MAXWORDS) &&
if ( (startloopaddr[iloop] != MAXWORDS) && (stoploopaddr[iloop] != MAXWORDS) ) (stoploopaddr[iloop] != MAXWORDS)) {
{ fprintf(fd, "patloop %d 0x%04x 0x%04x\n", iloop,
fprintf(fd,"patloop %d 0x%04x 0x%04x\n",iloop, startloopaddr[iloop], stoploopaddr[iloop]); startloopaddr[iloop], stoploopaddr[iloop]);
if (stoploopaddr[iloop]<= startloopaddr[iloop]) if (stoploopaddr[iloop] <= startloopaddr[iloop]) {
{
nloop[iloop] = 0; nloop[iloop] = 0;
} }
fprintf(fd, "patnloop %d %u\n", iloop, nloop[iloop]); fprintf(fd, "patnloop %d %u\n", iloop, nloop[iloop]);
} }
} }
for (iloop=0; iloop<MAXTIMERS; iloop++) for (iloop = 0; iloop < MAXTIMERS; iloop++) {
{ if (waitaddr[iloop] != MAXWORDS) {
if (waitaddr[iloop] != MAXWORDS)
{
fprintf(fd, "patwait %d 0x%04x\n", iloop, waitaddr[iloop]); fprintf(fd, "patwait %d 0x%04x\n", iloop, waitaddr[iloop]);
fprintf(fd, "patwaittime %d %llu\n", iloop, waittime[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_Get_Counter_Bit()));
Feb_Control_PrepareForAcquisition(); Feb_Control_PrepareForAcquisition();
LOG(logINFO, ("Acquisition started bit toggled\n")); LOG(logINFO, ("Acquisition started bit toggled\n"));
int ret = OK, prev_flag; int ret = OK, prev_flag;
// get the DAQ toggle bit // get the DAQ toggle bit

View File

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

View File

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