-
Notifications
You must be signed in to change notification settings - Fork 8
[MessageControl] Make sure no messages are missed via the UDP output #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
6ed437d
57119a0
bd1e613
df1c6e2
219f0de
8a0c03a
0877d7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,9 +131,8 @@ namespace Publishers { | |
| //UDPOutput | ||
| UDPOutput::Channel::Channel(const Core::NodeId& nodeId) | ||
| : Core::SocketDatagram(false, nodeId.Origin(), nodeId, Messaging::MessageUnit::Instance().DataSize(), 0) | ||
| , _loaded(0) | ||
| , _queue() | ||
| { | ||
| ::memset(_sendBuffer, 0, sizeof(_sendBuffer)); | ||
| } | ||
| UDPOutput::Channel::~Channel() | ||
| { | ||
|
|
@@ -142,13 +141,21 @@ namespace Publishers { | |
|
|
||
| uint16_t UDPOutput::Channel::SendData(uint8_t* dataFrame, const uint16_t maxSendSize) | ||
| { | ||
| uint16_t actualByteCount = 0; | ||
|
|
||
| _adminLock.Lock(); | ||
|
|
||
| uint16_t actualByteCount = (_loaded > maxSendSize ? maxSendSize : _loaded); | ||
| memcpy(dataFrame, _sendBuffer, actualByteCount); | ||
| _loaded = 0; | ||
| if (_queue.empty() == true) { | ||
|
VeithMetro marked this conversation as resolved.
VeithMetro marked this conversation as resolved.
VeithMetro marked this conversation as resolved.
|
||
| _adminLock.Unlock(); | ||
| } | ||
| else { | ||
| string msg = _queue.front(); | ||
|
||
| _queue.pop(); | ||
| _adminLock.Unlock(); | ||
|
VeithMetro marked this conversation as resolved.
|
||
|
|
||
| _adminLock.Unlock(); | ||
| actualByteCount = std::min<uint16_t>(msg.size(), maxSendSize); | ||
| memcpy(dataFrame, msg.c_str(), actualByteCount); | ||
|
VeithMetro marked this conversation as resolved.
VeithMetro marked this conversation as resolved.
|
||
| } | ||
|
|
||
|
VeithMetro marked this conversation as resolved.
|
||
| return (actualByteCount); | ||
| } | ||
|
|
@@ -166,14 +173,7 @@ namespace Publishers { | |
| { | ||
| _adminLock.Lock(); | ||
|
|
||
| ASSERT((_loaded + text.length() + 1) < sizeof(_sendBuffer)); | ||
|
|
||
| if ((_loaded + text.length() + 1) < sizeof(_sendBuffer)) { | ||
| Core::FrameType<0> frame(_sendBuffer + _loaded, sizeof(_sendBuffer) - _loaded, sizeof(_sendBuffer) - _loaded); | ||
| Core::FrameType<0>::Writer frameWriter(frame, 0); | ||
| frameWriter.NullTerminatedText(text); | ||
| _loaded += frameWriter.Offset(); | ||
| } | ||
| _queue.push(std::move(text)); | ||
|
VeithMetro marked this conversation as resolved.
Outdated
|
||
|
|
||
| _adminLock.Unlock(); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.