Go to Post Don't fix mechanical problems with software, ever. - Chris is me [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 16-11-2013, 22:23
Domenic Rodriguez's Avatar
Domenic Rodriguez Domenic Rodriguez is offline
Registered User
FRC #0316 (LuNaTeCs)
Team Role: College Student
 
Join Date: Sep 2010
Rookie Year: 2011
Location: Grove City, PA
Posts: 213
Domenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura about
Re: Which communication protocol is best?

You should take a look at this thread, as it discusses TCP/IP communication with WindRiver C++: http://www.chiefdelphi.com/forums/sh...d.php?t=100810

Mentioned within is Team 3574's 2012 code, which used a TCP to send vision data from the driver station laptop. Here's a link: https://github.com/jacob9706/HighTekerz2012. You might be able to use it as a starting point.
__________________

LuNaTeCs - Learning Under Nurturing Adults Teaching Engineering Concepts and Skills - Small and Mighty!

FRC 316 LuNaTeCs - Student (2011-2014), Lead Programmer (2011-2014), Team Captain (2013-2014), Operator (2013), Drive Coach (2014), Mentor (2015-????)
'11 Philly Regional Finalists, '13 Chestnut Hill Finalists, '13 Lenape Champions, '13 Archimedes Division, '14 Chestnut Hill Champions, '14 Lenape Champions
FTC 7071 EngiNerds - Founding Advisor (2013-2014) | FRC 5420 Velocity - Founding Advisor (2015)
Grove City College Class of '18, Electrical/Computer Engineering (B.S.E.E)

Reply With Quote
  #2   Spotlight this post!  
Unread 18-11-2013, 01:24
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: Which communication protocol is best?

Quote:
Originally Posted by Jay_To_The_Be View Post
I just don't know how to setup up the connection between the cRIO and Processing, and how to separate a comma-delimited string and make those values.
Quote:
Originally Posted by DomenicR View Post
Mentioned within is Team 3574's 2012 code, which used a TCP to send vision data from the driver station laptop.
You can also check out the Network Tables code in the WPILib source code, which includes a TCP server. VxWorks looks like it basically uses the Berkeley/POSIX sockets API, so any resources on the Internet for Linux or Unix socket code should work as well. The code is a little extensive to replicate in-thread.

As for parsing delimited strings, here's some code for that separates numbers delimited by whitespace:

Spoiler for Parse whitespace-delimited numbers:

Code:
#include <string>
#include <sstream>
#include <iterator>
#include <vector>

#include <iostream>

int main(int argc, char **argv)
{
	if (argc != 2)
		return 1;
	
	std::string input(argv[1]);
	std::stringstream ss(input);
	std::vector<double> parts((std::istream_iterator<double>(ss)), (std::istream_iterator<double>()));
	if (ss.fail() && !ss.eof())
	{
		std::cout << "Data format error" << std::endl;
		return -1;
	}
	
	for(int i=0; i < parts.size(); ++i)
	{
		std::cout << parts[i] << std::endl;
	}
	
	return 0;
}


if you need comma to be delimiters as well, the code gets a bit more complicated:

Spoiler for Parse comma- and whitespace-delimited numbers:

Code:
#include <string>
#include <sstream>
#include <vector>
#include <cctype>

#include <iostream>

int main(int argc, char **argv)
{
	if (argc != 2)
		return 1;
	
	std::string input(argv[1]);
	std::stringstream ss(input);
	std::vector<double> parts;
	double val;
	
	while(ss >> val)
	{
		parts.push_back(val);
		
		while(std::isspace(ss.peek()) || ss.peek() == ',')
			ss.ignore();
	}
	if (!ss.eof())
	{
		std::cout << "Data format error" << std::endl;
		return -1;
	}
	
	for(int i=0; i < parts.size(); ++i)
	{
		std::cout << parts[i] << std::endl;
	}
	
	return 0;
}
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:53.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi