-const char trbnet_version[] = "$Revision: 4.21 $ Local";
+const char trbnet_version[] = "$Revision: 4.22 $ Local";
#include <stdlib.h>
#include <signal.h>
/* Semaphore handling */
static int semid = -1;
-/* static const key_t sem_key = 0x545242;*/
-static const key_t sem_key = 0x545245;
+#if defined TRB3
+static const key_t sem_key = 0x747262;
+#else
+static const key_t sem_key = 0x545242;
+#endif
unsigned int trb_debug = 0;
#ifdef TRB3
-static int sendTrbPackage(size_t size)
+static int getUDPPackage()
{
int status;
int i;
- /* Adjust endianess ... */
- for (i = 0; i < size; i++) {
- if (trb_debug > 2) {
- fprintf(stderr, "%d 0x%04x\n", i, udpBuffer[i]);
- }
- udpBuffer[i] = htons(udpBuffer[i]);
- }
-
- if (send(trb3_sockfd, (void*)udpBuffer, size * 2, MSG_CONFIRM) == -1) {
- trb_errno = TRB_TRB3_SOCKET_ERROR;
- return -1;
- }
-
/* GetData */
status = recv(trb3_sockfd_in, (void*)dataBuffer, 1500, 0);
if (status == -1) {
if (trb_debug > 2) {
fprintf(stderr, "%d 0x%04x\n", i, dataBuffer[i]);
}
+ }
+
+ return status;
+}
+
+static int sendTrbPackage(size_t size)
+{
+ int status;
+ int i;
+
+ /* Adjust endianess ... */
+ for (i = 0; i < size; i++) {
+ if (trb_debug > 2) {
+ fprintf(stderr, "%d 0x%04x\n", i, udpBuffer[i]);
+ }
+ udpBuffer[i] = htons(udpBuffer[i]);
}
+ if (send(trb3_sockfd, (void*)udpBuffer, size * 2, MSG_CONFIRM) == -1) {
+ trb_errno = TRB_TRB3_SOCKET_ERROR;
+ return -1;
+ }
+
+ /* GetData */
+ status = getUDPPackage();
+
return status;
}
#endif /* TRB3 */
trb_errno = TRB_FIFO_TIMEOUT;
return -1;
}
-#else
+#elif defined PEXOR
if (tmp - dataBuffer >= dataBufferSize) {
trb_errno = TRB_PEXOR_DATA_ERROR;
return -1;
}
tmp++;
-#endif
+#else
+ if (tmp - dataBuffer >= dataBufferSize) {
+ /* Get next UDP BUffer */
+ if (getUDPPackage() <= 0) {
+ return -1;
+ }
+ }
+ tmp = dataBuffer;
+#endif
} /* end while () */
/* Copy StatusBits and Sequenze of TerminationPackage */