From a9a9a8978821b08663e6a461da427aa492fd00bf Mon Sep 17 00:00:00 2001 From: Ludwig Maier Date: Tue, 6 Aug 2013 21:21:40 +0200 Subject: [PATCH] Makefile remove deprecated RCS calls, trbflash improved debugging --- libtrbnet/Makefile | 2 - libtrbnet/trbflash.c | 97 ++++++++++++++---------- libtrbnet/trbnet.c | 17 ++--- pexor/kernel-module/100-pexor-udev.rules | 1 + trbnetd/server/Makefile | 2 - trbrich/Makefile | 2 - 6 files changed, 65 insertions(+), 56 deletions(-) create mode 100644 pexor/kernel-module/100-pexor-udev.rules diff --git a/libtrbnet/Makefile b/libtrbnet/Makefile index 01ce38c..9712375 100644 --- a/libtrbnet/Makefile +++ b/libtrbnet/Makefile @@ -87,13 +87,11 @@ all: $(LIB_TARGETS) $(TARGETS) .PHONY: clean clean: rm -f *.o core core.* - rcsclean .PHONY: distclean distclean: clean rm -f $(TARGETS) $(LIB_TARGETS) find . -type l -exec rm {} \; - rcsclean -u .PHONY: depend depend: diff --git a/libtrbnet/trbflash.c b/libtrbnet/trbflash.c index b505943..5d55728 100644 --- a/libtrbnet/trbflash.c +++ b/libtrbnet/trbflash.c @@ -344,14 +344,17 @@ static int writeSetupRegister(uint16_t trb_address, uint8_t value) do { if ((status = trb_register_write(trb_address, SetupReg, (uint32_t) (value << 24))) == -1) { - fprintf(logFile, "Error > writeSetupRegister: TRBNet %s\n", - trb_strerror()); + fprintf(logFile, + "Error line %d > writeSetupRegister: TRBNet %s\n", + __LINE__, trb_strerror()); return -1; } /* Check timeout */ if (ctr >= timeout) { - fprintf(logFile, "Error > writeSetupRegister: timeout\n"); + fprintf(logFile, + "Error line %d > __LINE__ writeSetupRegister: timeout\n", + __LINE__); return -1; } ctr++; @@ -361,8 +364,8 @@ static int writeSetupRegister(uint16_t trb_address, uint8_t value) if (trb_term.status_channel != 0) { fprintf(logFile, - "Error > writeSetupRegister: invalid Status returned %s\n", - trb_strerror()); + "Error line %d > writeSetupRegister: invalid Status returned %s\n", + __LINE__, trb_strerror()); return -1; } @@ -381,21 +384,22 @@ static int readCtrlRegister(uint16_t trb_address, do { if ((status = trb_register_read(trb_address, CtrlReg, trbBuffer, TRB_BUFFER_SIZE)) == -1) { - fprintf(logFile, "Error > readCtrlRegister: TRBNet %s\n", - trb_strerror()); + fprintf(logFile, "Error line %d > readCtrlRegister: TRBNet %s\n", + __LINE__, trb_strerror()); return -1; } /* Check timeout */ if (ctr >= timeout) { - fprintf(logFile, "Error > readCtrlRegister: timeout\n"); + fprintf(logFile, "Error line %d > readCtrlRegister: timeout\n", __LINE__); return -1; } ctr++; } while (trb_term.status_channel != 0); if (status <= 0) { - fprintf(logFile, "Error > readCtrlRegister: %s\n", trb_strerror()); + fprintf(logFile, "Error line %d > readCtrlRegister: %s\n", + __LINE__, trb_strerror()); return -1; } @@ -417,14 +421,15 @@ static int writeCtrlRegister(uint16_t trb_address, uint32_t value) /* Wait until NoMoreData is withdrawn */ do { if ((status = trb_register_write(trb_address, CtrlReg, value)) == -1) { - fprintf(logFile, "Error > writeCtrlRegister: TRBNet %s\n", - trb_strerror()); + fprintf(logFile, "Error line %d > writeCtrlRegister: TRBNet %s\n", + __LINE__, trb_strerror()); return -1; } /* Check timeout */ if (ctr >= timeout) { - fprintf(logFile, "Error writeCtrlRegister, timeout\n"); + fprintf(logFile, + "Error line %d > Error writeCtrlRegister, timeout\n", __LINE__); return -1; } ctr++; @@ -464,7 +469,9 @@ static int checkStatus(uint16_t trb_address) if ((status = trb_register_read(trb_address, BlockRam, trbBuffer, TRB_BUFFER_SIZE)) == -1) { - fprintf(logFile, "Error > checkStatus: TRBNet %s\n", trb_strerror()); + fprintf(logFile, + "Error line %d > checkStatus: TRBNet %s\n", + __LINE__, trb_strerror()); return -1; } @@ -478,8 +485,10 @@ static int checkStatus(uint16_t trb_address) (flashParamRef.manId == 0x00471f)) { /* Check EPE Bit (ADCM and SHOWER) */ if (((trbBuffer[i + 1] >> 5) & 0x01) == 1) { - fprintf(logFile, "Error > checkStatus: Erase or program error on " - "EndPoint 0x%04x\n", trbBuffer[i] & 0xffff); + fprintf(logFile, + "Error line %d > checkStatus: Erase or program error on " + "EndPoint 0x%04x\n", + __LINE__, trbBuffer[i] & 0xffff); return -1; /* Fatal Error */ } } @@ -497,17 +506,20 @@ static int writeStatusRegister(uint16_t trb_address, uint8_t value) /* Enable writing */ if (sendCommand(trb_address, 0x06 << 24, 0) == -1) { - fprintf(logFile, "Error > writeStatusRegister: write enable\n"); + fprintf(logFile, + "Error line %d > writeStatusRegister: write enable\n", __LINE__); return -1; } if (trb_register_write(trb_address, BlockRam, (uint32_t) value) == -1) { - fprintf(logFile, "Error > writeStatusRegister: TRBNet %s\n", - trb_strerror()); + fprintf(logFile, + "Error line %d > writeStatusRegister: TRBNet %s\n", + __LINE__, trb_strerror()); return -1; } if (sendCommand(trb_address, 0x01 << 24, 0) == -1) { - fprintf(logFile, "Error > writeStatusRegister: sendCommand\n"); + fprintf(logFile, + "Error line %d > writeStatusRegister: sendCommand\n", __LINE__); return -1; } @@ -516,7 +528,8 @@ static int writeStatusRegister(uint16_t trb_address, uint8_t value) } if (status != 0) { - fprintf(logFile, "Error > writeStatusRegister: invalid status\n"); + fprintf(logFile, + "Error line %d > writeStatusRegister: invalid status\n", __LINE__); return -1; } @@ -536,8 +549,9 @@ static int initTransfer(uint16_t trb_address) if ((status = trb_register_read(trb_address, HardwareId, trbBuffer, TRB_BUFFER_SIZE)) == -1) { - fprintf(logFile, "Error > initTransfer, read HardwareIds: TRBNet %s\n", - trb_strerror()); + fprintf(logFile, + "Error line %d > initTransfer, read HardwareIds: TRBNet %s\n", + __LINE__, trb_strerror()); return -1; } @@ -591,8 +605,8 @@ static int initTransfer(uint16_t trb_address) if ((status = trb_register_read(trb_address, BlockRam, trbBuffer, TRB_BUFFER_SIZE)) == -1) { - fprintf(logFile, "Error > initTransfer, read ManIds: TRBNet %s\n", - trb_strerror()); + fprintf(logFile, "Error line %d > initTransfer, read ManIds: TRBNet %s\n", + __LINE__, trb_strerror()); return -1; } @@ -663,7 +677,8 @@ static int readPage(uint16_t trb_address, uint32_t pageNumber, if ((status = trb_register_read_mem(trb_address, BlockRam, 0, size, trbBuffer, TRB_BUFFER_SIZE)) == -1) { - fprintf(logFile, "Error > readPage: TRBNet %s\n", trb_strerror()); + fprintf(logFile, "Error line %d > readPage: TRBNet %s\n", + __LINE__, trb_strerror()); return -1; } @@ -682,8 +697,8 @@ static int readPage(uint16_t trb_address, uint32_t pageNumber, if (len != size) { fprintf(logFile, - "Error > readPage: Invalid len %d returned by endpoint 0x%04x\n", - len, address); + "Error line %d > readPage: Invalid len %d returned by " + "endpoint 0x%04x\n", __LINE__, len, address); } /* read one page */ @@ -731,20 +746,21 @@ static int writePage(uint16_t trb_address, uint32_t pageNumber, if ((status = trb_register_write_mem(trb_address, BlockRam, 0, trbBuffer, size)) == -1) { - fprintf(logFile, "Error > writePage: TRBNet %s\n", trb_strerror()); + fprintf(logFile, "Error line %d > writePage: TRBNet %s\n", + __LINE__, trb_strerror()); return -1; } /* Enable writing */ if (sendCommand(trb_address, 0x06 << 24, 0) == -1) { - fprintf(logFile, "Error > writePage: write enable\n"); + fprintf(logFile, "Error line %d > writePage: write enable\n", __LINE__); return -1; } /* Write page */ trbcmd = (0x02 << 24) | ((pageNumber * PAGE_SIZE) & 0xffffff); if (sendCommand(trb_address, trbcmd, numBytes - 1) == -1) { - fprintf(logFile, "Error > writePage: write page\n"); + fprintf(logFile, "Error line %d > writePage: write page\n", __LINE__); return -1; } @@ -754,7 +770,7 @@ static int writePage(uint16_t trb_address, uint32_t pageNumber, } if (status != 0) { - fprintf(logFile, "Error > pageWrite: invalid status\n"); + fprintf(logFile, "Error line %d > pageWrite: invalid status\n", __LINE__); return -1; } @@ -968,7 +984,7 @@ static int programImageBuffer(uint16_t trb_address, error = -1; errorCtr++; fprintf(logFile, - "verify failed page #%d, byte #%d " + "Error > verify failed page #%d, byte #%d " "(exp: 0x%02x rec: 0x%02x), EndPoint: 0x%04x\n", page, c, imageBuffer[page * PAGE_SIZE + c], @@ -997,7 +1013,7 @@ static int programImageBuffer(uint16_t trb_address, error = -1; errorCtr++; fprintf(logFile, - "verify failed InfoPage, byte #%d " + "Error > verify failed InfoPage, byte #%d " "(exp: 0x%02x rec: 0x%02x), EndPoint: 0x%04x\n", c, imageBuffer[(NUM_PAGES - 1) * PAGE_SIZE + c], @@ -1068,7 +1084,8 @@ static int readImageFile(const char *imageFileName) if (imageSize > (PAGE_SIZE * NUM_PAGES)) { fprintf(logFile, - "Error > readImageFile: Imagefile '%s' is too large (%d bytes)\n", + "Error > readImageFile: Imagefile '%s' is too large" + " (%d bytes)\n", imageFileName, imageSize); return -1; } @@ -1137,8 +1154,9 @@ static int createInfoPage(const char *fileName, const char *userString) } if (stat(fileName, &statBuf) == -1) { - fprintf(logFile, "Error > prepareInfoPage: statCall failed: %s\n", - strerror(errno)); + fprintf(logFile, + "Error line %d > prepareInfoPage: statCall failed: %s\n", + __LINE__, strerror(errno)); return -1; } snprintf(buffer + 0, 63, "NAME: %s", basename((char *)fileName)); @@ -1160,7 +1178,8 @@ static int openLog() /* Open LogFile */ logFile = fopen(logFileName, "w+"); if (logFile == NULL) { - fprintf(stderr, "Could not open logFile %s: %s\n", + fprintf(stderr, + "Error > Could not open logFile %s: %s\n", logFileName, strerror(errno)); return -1; } @@ -1179,8 +1198,8 @@ static int selectMdcFlashRom(uint16_t trb_address, uint8_t number) /* Select MDC-FlashRom */ if (trb_register_write(trb_address, MDCFlashRomSelect, (uint32_t) number) == -1) { - fprintf(logFile, "\nError > selcetMdcFlashRom: TRBNet %s\n", - trb_strerror()); + fprintf(logFile, "\nError line %d > selectMdcFlashRom: TRBNet %s\n", + __LINE__, trb_strerror()); return -1; } diff --git a/libtrbnet/trbnet.c b/libtrbnet/trbnet.c index 06c5b10..37e7d33 100644 --- a/libtrbnet/trbnet.c +++ b/libtrbnet/trbnet.c @@ -63,7 +63,7 @@ static const struct timespec tv = { .tv_nsec = 0 }; static uint16_t trb3_port = 25000; -uint16_t sender_address = 0x5555; +uint16_t sender_address = 0x4455; #endif @@ -1465,13 +1465,9 @@ static int unlockPorts(int masterLock) return 0; } - +#ifndef TRB3 static int init_semaphore() { -#ifdef TRB3 - return 0; -#else - /* Set signal mask to block ALL signals */ sigfillset(&blockSet); sigemptyset(&blockSetOld); @@ -1502,8 +1498,8 @@ static int init_semaphore() } return 0; -#endif } +#endif static int trb_register_modify(uint16_t trb_address, uint16_t reg_address, @@ -1686,6 +1682,9 @@ int init_ports() void close_ports() { /* Close FileHandler */ + if (trb3_sockfd >= 0) { + close(trb3_sockfd); + } return; } @@ -1723,11 +1722,7 @@ int init_ports() trb3_addr.sin_port = htons(trb3_port); trb3_addr.sin_addr = *((struct in_addr*)host->h_addr); memset(&(trb3_addr.sin_zero), 0, 8); - - /* Init semaphore and signal handling */ - if (init_semaphore() == -1) return -1; - return 0; } diff --git a/pexor/kernel-module/100-pexor-udev.rules b/pexor/kernel-module/100-pexor-udev.rules new file mode 100644 index 0000000..a8fa22f --- /dev/null +++ b/pexor/kernel-module/100-pexor-udev.rules @@ -0,0 +1 @@ +KERNEL=="pexor-*", NAME="%k", MODE="0666", OPTIONS="last_rule" diff --git a/trbnetd/server/Makefile b/trbnetd/server/Makefile index 5fb5d13..967b7ca 100644 --- a/trbnetd/server/Makefile +++ b/trbnetd/server/Makefile @@ -87,13 +87,11 @@ all: $(LIB_TARGETS) $(TARGETS) .PHONY: clean clean: rm -f *.o core core.* - rcsclean .PHONY: distclean distclean: clean rm -f $(TARGETS) $(LIB_TARGETS) find . -type l -exec rm {} \; - rcsclean -u .PHONY: cleanrpc cleanrpc: diff --git a/trbrich/Makefile b/trbrich/Makefile index e70d401..afdfae9 100644 --- a/trbrich/Makefile +++ b/trbrich/Makefile @@ -81,12 +81,10 @@ all: $(LIB_TARGETS) $(TARGETS) .PHONY: clean clean: rm -f *.o core core.* - rcsclean .PHONY: distclean distclean: clean rm -f $(TARGETS) $(LIB_TARGETS) - rcsclean -u .PHONY: depend depend: -- 2.43.0