Compare commits

...

2 Commits

Author SHA1 Message Date
Fredric Silberberg
16343bbe71 Updated release to version 5. 2016-03-01 15:55:19 -05:00
Peter Johnson
623a5fcf8d Fix C++ CameraServer request handling.
The request is not guaranteed to be in a single packet, so it may be necessary
to perform multiple reads to get the complete request.  The previous code
could unpredictably fail as it only performed a single read.

Fixes artf4817.

Change-Id: I7734a12e1a2542f5d7ca0889453c387f0bb30538
2016-02-24 00:18:59 -08:00
3 changed files with 17 additions and 7 deletions

View File

@@ -189,16 +189,26 @@ void CameraServer::Serve() {
}
Request req;
if (read(conn, &req, sizeof(req)) == -1) {
char reqBuf[sizeof(req)];
size_t reqPos = 0;
while (reqPos < sizeof(req)) {
ssize_t sizeRead = read(conn, &reqBuf[reqPos], sizeof(req) - reqPos);
if (sizeRead < 0) break;
reqPos += sizeRead;
}
if (reqPos < sizeof(req)) {
wpi_setErrnoError();
close(conn);
continue;
} else {
req.fps = ntohl(req.fps);
req.compression = ntohl(req.compression);
req.size = ntohl(req.size);
}
memcpy(&req, reqBuf, sizeof(req));
req.fps = ntohl(req.fps);
req.compression = ntohl(req.compression);
req.size = ntohl(req.size);
// TODO: Support the SW Compression. The rest of the code below will work as
// though this
// check isn't here

View File

@@ -56,7 +56,7 @@ RobotBase::RobotBase() : m_ds(DriverStation::GetInstance()) {
file = fopen("/tmp/frc_versions/FRC_Lib_Version.ini", "w");
if (file != nullptr) {
fputs("2016 C++ Release 4", file);
fputs("2016 C++ Release 5", file);
fclose(file);
}
}

View File

@@ -223,7 +223,7 @@ public abstract class RobotBase {
output = new FileOutputStream(file);
output.write("2016 Java Release 4".getBytes());
output.write("2016 Java Release 5".getBytes());
} catch (IOException ex) {
ex.printStackTrace();