mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Fix receive side of LabVIEW USB streams (#1621)
LabView only accepts %20 instead of + for parameters, only sends '\n' at the boundaries, and includes the -- when sending the initial boundary. This solves those parts. This is not fully enough to fix shuffleboard and others, as the NT format for paths is not the correct path.
This commit is contained in:
committed by
Peter Johnson
parent
99e4f7dd2c
commit
12ab035aad
@@ -189,6 +189,9 @@ wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect(
|
||||
std::tie(key, value) = keyvalue.split('=');
|
||||
if (key.trim() == "boundary") {
|
||||
value = value.trim().trim('"'); // value may be quoted
|
||||
if (value.startswith("--")) {
|
||||
value = value.substr(2);
|
||||
}
|
||||
boundary.append(value.begin(), value.end());
|
||||
}
|
||||
}
|
||||
@@ -219,11 +222,16 @@ void HttpCameraImpl::DeviceStream(wpi::raw_istream& is,
|
||||
if (!FindMultipartBoundary(is, boundary, nullptr)) break;
|
||||
|
||||
// Read the next two characters after the boundary (normally \r\n)
|
||||
// Handle just \n for LabVIEW however
|
||||
char eol[2];
|
||||
is.read(eol, 2);
|
||||
is.read(eol, 1);
|
||||
if (!m_active || is.has_error()) break;
|
||||
// End-of-stream is indicated with trailing --
|
||||
if (eol[0] == '-' && eol[1] == '-') break;
|
||||
if (eol[0] != '\n') {
|
||||
is.read(eol + 1, 1);
|
||||
if (!m_active || is.has_error()) break;
|
||||
// End-of-stream is indicated with trailing --
|
||||
if (eol[0] == '-' && eol[1] == '-') break;
|
||||
}
|
||||
|
||||
if (!DeviceStreamFrame(is, imageBuf))
|
||||
++numErrors;
|
||||
|
||||
Reference in New Issue
Block a user