accept the front of over-length data
This commit is contained in:
parent
fdb2980d0e
commit
a81bc5b1fd
|
@ -113,17 +113,14 @@ void Universe::setData(const std::vector<uint8_t>& data)
|
|||
if (data.front() != E111_NULL_START)
|
||||
return altSCdata(data);
|
||||
|
||||
// too many slots!
|
||||
if (data.size() > null_start_data.size())
|
||||
return;
|
||||
|
||||
// copy data
|
||||
null_start_mutex.lock();
|
||||
if (data.size() < null_start_data.size())
|
||||
null_start_data.fill(0);
|
||||
std::copy(data.begin(), data.end(), null_start_data.begin());
|
||||
null_start_mutex.unlock();
|
||||
|
||||
// accept variable lenth input, but never more than the limit
|
||||
const auto max_length = null_start_data.size();
|
||||
const auto length = data.size() < max_length ? data.size() : max_length;
|
||||
null_start_mutex.lock(); // take the lock
|
||||
if (length < max_length)
|
||||
null_start_data.fill(0); // wipe old data
|
||||
std::copy_n(data.cbegin(), length, null_start_data.begin()); // copy new data
|
||||
null_start_mutex.unlock(); // free the lock
|
||||
|
||||
rx_timeout_(true); // update rx times
|
||||
doDataCallbacks(); // notify callbacks
|
||||
|
|
Loading…
Reference in New Issue