Project Home

Trackers

Source Code

File Releases

Documents

Wiki

Discussions

Reports

Project Info
Artifact artf4817 : CameraServer HW Compression Issue Print Preview
Tracker:Bugs
Title:CameraServer HW Compression Issue
Description:
(I know there are other trackers for this bug, but I'm unable to comment on them)

When using the Java dashboard with a USB camera, CameraServer will refuse connections (saying "choose USB Camera HW" on 
the labview dashboard) until you open the labview dashboard, choose the option, then close the dashboard.

We debugged this issue with Wireshark and discovered that the Java dashboard actually sends its request data in 2 
packets most of the time. CameraServer was only picking up the first packet, leaving the last 2 fields of Request zeroed
 out.

Our fix is attached. Here are the relevant lines of code
---
		Request req;
		// the problem with the default implementation of receiving the Request in
		// CameraServer was that it required the entire buffer to already be there
		// by the time it got to read. Sometimes the buffer would not be there, which
		// caused a loop of SmartDashboard repeatedly trying to connect. The code
		// below makes sure we have the entire contents of the Request (12 bytes)
		// before we try to interpret the contents
		char requestBuffer[sizeof(Request)];
		unsigned int index = 0;

		bool connFailed = false;

		while (index < sizeof(Request)) {
			char next;
			int sizeRead = read(conn, &next, sizeof(next));
			if (sizeRead == -1) {
				wpi_setErrnoError();
				close(conn);
				connFailed = true;
				break;
			}
			if (sizeRead < 1)
				continue;
			requestBuffer[index] = next;
			index++;
		}

		if (connFailed) {
			continue;
		}

		// slightly unsafe cast. We use sizeof(Request) so it should be ok
		memcpy(&req, &requestBuffer, sizeof(Request));

		req.fps = ntohl(req.fps);
		req.compression = ntohl(req.compression);
		req.size = ntohl(req.size);
---
Submitted By:Erik Uhlmann (2877)
Submitted On:02/05/2016 11:12 PM GMT
Last Modified:12/31/2016 8:04 PM GMT
Closed:12/31/2016 8:04 PM GMT

Active Tab Status / Comments Inactive Tab - left sideChange Log Inactive Tab - left sideAssociations Inactive Tab - left sideDependencies Inactive Tab - left sideAttachments (2)Inactive Tab - right side  
C++ WPILib
Status
Planning Folder:*None
3
Closed
None
Comments
#3Thad House: 12/31/2016 8:04 PM GMT
 Comment:
Closed because of new CameraServer for 2017. If you see this again after kickoff, please repost the isssue on GitHub.
 Action:Update
Closed set to 12/31/2016
Status changed from Fix Commited to Closed
#2Peter Johnson (294): 02/28/2016 6:02 AM GMT
 Action:Update
Status changed from Open to Fix Commited
#1Erik Uhlmann (2877): 02/05/2016 11:12 PM GMT
 Attachment:TextLCameraServer.h(2.66 KB)
TextLCameraServer.cpp(8.58 KB)
 Action:Create
Added attachments.

Button Divider
< Previous
Next >