From 5810d815261a05d36691e3ccd6b6e87ffde47675 Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Tue, 20 Sep 2011 21:20:36 +0200 Subject: [PATCH] right byteOrder flaga --- pvAccessApp/remote/blockingTCP.h | 2 +- pvAccessApp/remote/blockingTCPTransport.cpp | 25 ++++++++++++--------- pvAccessApp/remote/blockingUDPTransport.cpp | 6 ++--- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/pvAccessApp/remote/blockingTCP.h b/pvAccessApp/remote/blockingTCP.h index 3bb8e48..8cd6c3e 100644 --- a/pvAccessApp/remote/blockingTCP.h +++ b/pvAccessApp/remote/blockingTCP.h @@ -328,7 +328,7 @@ namespace epics { int _sendBufferSentPosition; - + int8 _byteOrderFlag; diff --git a/pvAccessApp/remote/blockingTCPTransport.cpp b/pvAccessApp/remote/blockingTCPTransport.cpp index aa7ed72..f3e6e56 100644 --- a/pvAccessApp/remote/blockingTCPTransport.cpp +++ b/pvAccessApp/remote/blockingTCPTransport.cpp @@ -1,8 +1,5 @@ /* * blockingTCPTransport.cpp - * - * Created on: Dec 29, 2010 - * Author: Miha Vitorovic */ #define __STDC_LIMIT_MACROS 1 @@ -116,6 +113,7 @@ namespace epics { _lastSegmentedMessageCommand(0), _flushRequested(false), _sendBufferSentPosition(0), + _byteOrderFlag((EPICS_BYTE_ORDER == EPICS_ENDIAN_BIG) ? 0x80 : 0x00), _storedPayloadSize(0), _storedPosition(0), _storedLimit(0), @@ -181,7 +179,8 @@ namespace epics { "Failed to set SO_RCVTIMEO for TDP socket %s: %s.", inetAddressToString(_socketAddress).c_str(), errStr); } - + + // TODO this will create marker with invalid endian flag // prepare buffer clearAndReleaseBuffer(); } @@ -248,7 +247,7 @@ namespace epics { // prepare ACK marker _sendBuffer->putByte(CA_MAGIC); _sendBuffer->putByte(CA_VERSION); - _sendBuffer->putByte(1); // control data + _sendBuffer->putByte(0x01 | _byteOrderFlag); // control data _sendBuffer->putByte(1); // marker ACK _sendBuffer->putInt(0); } @@ -343,7 +342,7 @@ namespace epics { _lastMessageStartPosition = _sendBuffer->getPosition(); _sendBuffer->putByte(CA_MAGIC); _sendBuffer->putByte(CA_VERSION); - _sendBuffer->putByte(_lastSegmentedMessageType | ((EPICS_BYTE_ORDER == EPICS_ENDIAN_BIG) ? 0x80 : 0x00)); // data + endianess + _sendBuffer->putByte(_lastSegmentedMessageType | _byteOrderFlag); // data + endianess _sendBuffer->putByte(command); // command _sendBuffer->putInt(0); // temporary zero payload @@ -426,7 +425,7 @@ namespace epics { bytesLeft>=CA_MESSAGE_HEADER_SIZE)) { _sendBuffer->putByte(CA_MAGIC); _sendBuffer->putByte(CA_VERSION); - _sendBuffer->putByte(1); // control data + _sendBuffer->putByte(0x01 | _byteOrderFlag); // control data _sendBuffer->putByte(0); // marker _sendBuffer->putInt((int)(_totalBytesSent+position+CA_MESSAGE_HEADER_SIZE)); _nextMarkerPosition = position+_markerPeriodBytes; @@ -649,9 +648,15 @@ namespace epics { { // check 7-th bit - // TODO no sync !!! on send - _socketBuffer->setEndianess(_packetType < 0 ? EPICS_ENDIAN_BIG : EPICS_ENDIAN_LITTLE); - _sendBuffer->setEndianess(_packetType < 0 ? EPICS_ENDIAN_BIG : EPICS_ENDIAN_LITTLE); + int endianess = (_packetType < 0 ? EPICS_ENDIAN_BIG : EPICS_ENDIAN_LITTLE); + _socketBuffer->setEndianess(endianess); + + // TODO register as TransportSender and add to the queue + // current implementation is OK, but not nice + _sendQueueMutex.lock(); + _sendBuffer->setEndianess(endianess); + _byteOrderFlag = (endianess == EPICS_ENDIAN_BIG) ? 0x80 : 0x00; + _sendQueueMutex.unlock(); } diff --git a/pvAccessApp/remote/blockingUDPTransport.cpp b/pvAccessApp/remote/blockingUDPTransport.cpp index b361bce..7ecef79 100644 --- a/pvAccessApp/remote/blockingUDPTransport.cpp +++ b/pvAccessApp/remote/blockingUDPTransport.cpp @@ -1,7 +1,5 @@ -/* blockingUDPTransport.cpp - * - * Created on: Dec 20, 2010 - * Author: Miha Vitorovic +/* + * blockingUDPTransport.cpp */ /* pvAccess */