Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Communicating With A PC (http://www.chiefdelphi.com/forums/showthread.php?t=86006)

davidthefat 03-06-2010 12:37

Communicating With A PC
 
I am stuck here guys and I need some help, I am not going to use a serial port since out laptop does not have a serial port. I was thinking either communicate with an ethernet on the 2nd port or the existing connection with the dashboard. The problem is I do not know how to do that, there is no socket class, or anything similar to it. I am currently looking at the DataOutputStream and the Driverstation class, but I am not sure if thats the one that communicate through the ethernet. I have an idea on what they do, but I have no idea from the client side to get that data being sent. Should I use sockets? If I do use sockets, whats the port and IP of the robot? I know I sound like a total noob, but its been a long day, I woke up at 5:30 and lifted for an hour and now I am school trying to figure this out...

apalrd 03-06-2010 12:49

Re: Communicating With A PC
 
1. You could use the DashBoard data stream to feed data one-way to the PC, then setup the Classmate to feed to an external dashboard (it will do this), on your computer. I do not know what port this uses, but the IP is 10.xx.yy.2 where xx.yy is your team number (For me it would be 10.0.33.2). Dashboard will only send data to port 1, directly to the Classmate, which then relays the data to your program.

2. You could use sockets. In LabVIEW (after not using the front panel controls and Dashboard) I would go to sockets. Nothing wrong with them, you just need to know what you are doing.

3. If you do not understand the Dashboard, you should probably not go into sockets.

4. Read through some of the LabVIEW dashboard code to get a feel for how the Dashboard operates client-side. There are two VI's of significance:
There is one (I forgot it's name), that gives you your data. It gives you two strings: High and Low (priority). You then take the binary string and get a structure of data. You do not have to do it that way, but you get two strings whatever way you do it. Look inside this VI. It will tell you exactly how the Dashboard is getting its data. It uses a UDP socket and waits for new data (in it's own thread). You should *probably* create a new thread to run it in, so your other code dosen't have to wait for new data (and hang when there is no data coming in).
The other VI is Get Image from Controller. It does just that, it gets the latest camera image from the crio. Feed it the IP (which you know) and it will get it for you. Inside, it has a TCP or UDP socket (I think it's TCP but I am not quite sure) that gets a string, which it then converts to an image. I do not know the encoding on it, but it uses the LabVIEW image to string function to create it.

RyanCahoon 03-06-2010 14:44

Re: Communicating With A PC
 
Quote:

Originally Posted by davidthefat (Post 965155)
there is no socket class, or anything similar to it. I am currently looking at the DataOutputStream and the Driverstation class, but I am not sure if thats the one that communicate through the ethernet

Sounds like you're using Java, so I'll write a response to that; [apalrd]'s got the rest of it covered. Going off of the Javadoc here. You can use the SocketConnection interface; create the instance using the static methods of the Connector class. There's an example in the Javadoc for the SocketConnection class (here).

--Ryan

JamesBrown 03-06-2010 14:47

Re: Communicating With A PC
 
Quote:

Originally Posted by RyanCahoon (Post 965171)
Sounds like you're using Java,

...


--Ryan

Based on his previous posts it is probably safe to assume he is using C++.

virtuald 03-06-2010 14:54

Re: Communicating With A PC
 
You're using C++, right? It depends on what information you're trying to communicate to/from the PC. If you don't use the dashboard interface, then you'll want to use sockets. Lookup how to use sockets, its mostly the same interface as every other OS.

If you use sockets, you get to pick the port that you use. We have a webserver running on our robot that we use to communicate with it. The code for it uses the portable boost::asio asynchronous I/O library to abstract all the socket crap away. But, asynchronous I/O is inherently tricky, so user beware. http://code.google.com/p/webdma/

byteit101 03-06-2010 14:57

Re: Communicating With A PC
 
what are you trying to transfer? If you just want to get feedback or basic debug info, you could just use my ZomB Dashboard: http://firstforge.wpi.edu/sf/projects/zombdashboard
it (currently) uses the dashboard packets to send ints, floats, and strings, and also supports the video stream. You can also configure the DS to send data (minus video) to a remote computer (its in a draft manual on the site)
It uses the Dashboard class and works with Java and C++ If you need help, pm me.

davidthefat 03-06-2010 19:06

Re: Communicating With A PC
 
Quote:

Originally Posted by JamesBrown (Post 965174)
Based on his previous posts it is probably safe to assume he is using C++.

No, I should have mentioned it, the cRio is flashed to Java so I have to use java, the client will be in C++ though. Thanks Ryan, just what I needed

Quote:

Originally Posted by byteit101 (Post 965182)
what are you trying to transfer? If you just want to get feedback or basic debug info, you could just use my ZomB Dashboard: http://firstforge.wpi.edu/sf/projects/zombdashboard
it (currently) uses the dashboard packets to send ints, floats, and strings, and also supports the video stream. You can also configure the DS to send data (minus video) to a remote computer (its in a draft manual on the site)
It uses the Dashboard class and works with Java and C++ If you need help, pm me.


Thanks for your help, if you have not noticed, I like to do a lot of things from scratch, LOL

byteit101 03-06-2010 21:10

Re: Communicating With A PC
 
Quote:

Originally Posted by davidthefat (Post 965225)
Thanks for your help, if you have not noticed, I like to do a lot of things from scratch, LOL

I have, you can download it and see how I did it, and use that knowledge to enable you to build your own.

apalrd 03-06-2010 21:16

Re: Communicating With A PC
 
Quote:

Originally Posted by davidthefat (Post 965225)
...the cRio is flashed to Java...

The solution is to flash the crio. Not that hard, just open the FRC crio imaging tool (In LabVIEW it is under one of the menus, there is a shortcut to it somewhere also), select the crio and C++, and hit the button. Done in under 10 minutes.

davidthefat 03-06-2010 21:21

Re: Communicating With A PC
 
Quote:

Originally Posted by apalrd (Post 965260)
The solution is to flash the crio. Not that hard, just open the FRC crio imaging tool (In LabVIEW it is under one of the menus, there is a shortcut to it somewhere also), select the crio and C++, and hit the button. Done in under 10 minutes.

But then I have to download the C++ library and the IDE and stuff, I will do it after I am done with this part of the project, its for my AP Comp Sci final and I don't want to risk messing up, I only have like 1 week left

Radical Pi 03-06-2010 22:11

Re: Communicating With A PC
 
Quote:

Originally Posted by apalrd (Post 965260)
The solution is to flash the crio. Not that hard, just open the FRC crio imaging tool (In LabVIEW it is under one of the menus, there is a shortcut to it somewhere also), select the crio and C++, and hit the button. Done in under 10 minutes.

More like 20 seconds

And the C++ libraries should already be in place on your computer if you installed the build tools from the DVD. As far as I know the imaging tool just changes a few config files to load the correct environment


All times are GMT -5. The time now is 03:26.

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