From: hadaq Date: Thu, 11 Nov 2010 02:42:26 +0000 (+0000) Subject: code housekeeping has caused major errors (as always), have fixed them X-Git-Tag: v6.0~176 X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=431dafc047733e3dc9abc8937a5548c044ca65b9;p=trbnettools.git code housekeeping has caused major errors (as always), have fixed them --- diff --git a/libtrbnet/trbnet.c b/libtrbnet/trbnet.c index 76dfd94..bb346e1 100644 --- a/libtrbnet/trbnet.c +++ b/libtrbnet/trbnet.c @@ -1,4 +1,4 @@ -const char trbnet_version[] = "$Revision: 2.93 $"; +const char trbnet_version[] = "$Revision: 2.94 $"; #include #include @@ -133,7 +133,7 @@ const char trbnet_version[] = "$Revision: 2.93 $"; /* ---------------------------------------------------------------------- */ -/* Used for blocking Signals SIGINT and SIGTERM */ +/* Used for blocking Signals */ static sigset_t blockSet; static sigset_t blockSetOld; @@ -283,7 +283,7 @@ static inline void com_reset_FPGA() clrbitsPC(0x30000); usleep(100); - // Reset FifoToggleBit + /* Reset FifoToggleBit */ fifoToggleBit = 0; } @@ -450,7 +450,7 @@ static int trb_init_transfer(uint8_t channel) return -1; } - /* Check receiver FIFO empty*/ + /* Check receiver FIFO empty */ read32_from_FPGA(CHANNEL_N_RECEIVER_FIFO_STATUS | ((channel * 2 + 1) << 4), &tmp); if ((tmp & MASK_FIFO_EMPTY) == 0) { @@ -475,6 +475,7 @@ enum FIFO_READ_MODE { FIFO_MODE_REGTIME_READ, FIFO_MODE_REG_READ_MEM, FIFO_MODE_REGTIME_READ_MEM, + FIFO_MODE_REG_WRITE, FIFO_MODE_IPU_DATA, FIFO_MODE_UID, FIFO_MODE_SET_ADDRESS @@ -854,6 +855,20 @@ static int trb_fifo_read(uint8_t channel, } break; + case FIFO_MODE_REG_WRITE: + switch (headerType) { + case HEADER_HDR: + case HEADER_DAT: + case HEADER_TRM: + break; + + default: + fifo_flush(channel); + trb_errno = TRB_FIFO_INVALID_HEADER; + return -1; + } + break; + case FIFO_MODE_IPU_DATA: { unsigned int i; @@ -964,7 +979,7 @@ static int trb_fifo_read(uint8_t channel, trb_errno = TRB_INVALID_PKG_NUMBER; return -1; } - + switch (headerType) { case HEADER_HDR: break; @@ -1090,9 +1105,9 @@ static int lockPorts(int masterLock) static int unlockPorts(int masterLock) { struct sembuf sops = { - 0, /* sem_num: We only use one track */ + 0, /* sem_num: We only use one track */ 1, /* sem_op: increment semaphore by 1, i.e. unlock it */ - SEM_UNDO /* */ + SEM_UNDO /* sem_flg: remove lock if process gets killed */ }; if ((master_lock == 1) && (masterLock == 0)) { @@ -1512,7 +1527,7 @@ int trb_register_write(uint16_t trb_address, fprintf(stderr, "CMD_REGISTER_WRITE started.\n"); } - status = trb_fifo_read(3, FIFO_MODE_TERM_ONLY, NULL, 0); + status = trb_fifo_read(3, FIFO_MODE_REG_WRITE, NULL, 0); if (unlockPorts(0) == -1) return -1; @@ -1580,7 +1595,7 @@ int trb_register_write_mem(uint16_t trb_address, fprintf(stderr, "CMD_REGISTER_WRITE_MEM started %d.\n", len); } - status = trb_fifo_read(3, FIFO_MODE_TERM_ONLY, NULL, 0); + status = trb_fifo_read(3, FIFO_MODE_REG_WRITE, NULL, 0); } if (unlockPorts(0) == -1) return -1; @@ -1975,7 +1990,7 @@ int trb_register_modify(uint16_t trb_address, return -1; } - /* Now set bits on all endpoints */ + /* Now set bits on all endpoints */ /* check, whether all registers are the same */ singleWrite = 1; value = data[1]; @@ -2023,4 +2038,3 @@ int trb_register_modify(uint16_t trb_address, return 0; } -