|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Receiving UDP packets on the CRIO
Hi,
I've been trying to receive custom data on port 1130, but I am unable to get a connection. When running the following code on the CRIO, it stops after printing "Opening socket connection." I assume the issue is with ss.acceptAndOpen(). It doesn't crash, it just stops at that point. Quote:
Thanks for any help. Last edited by alexhenning : 31-01-2011 at 08:47. |
|
#2
|
|||
|
|||
|
Re: Receiving UDP packets on the CRIO
A ServerSocketConnection is TCP, not UDP. You'd be wanting DatagramConnection, which is UDP. Open with
Quote:
Quote:
|
|
#3
|
|||
|
|||
|
Re: Receiving UDP packets on the CRIO
Greetings,
I'm attaching a working CRIO C++ example function that we managed to get working the other day. I wish I could help in Java but perhaps this example might help. There is some dialog on this on another thread around what we can/can’t do with this new UDP functionality. John Related thread: http://www.chiefdelphi.com/forums/sh...&highlight=UDP |
|
#4
|
|||
|
|||
|
Re: Receiving UDP packets on the CRIO
I had tried datagram before, unfortunately, when I run it I get:
Quote:
|
|
#5
|
||||
|
||||
|
Re: Receiving UDP packets on the CRIO
Which protocols are supported aren't standardized in CLDC. Java on the cRIO supports socket:, serversocket:, and file: protocols currently. Unfortunately it doesn't support datagrams yet.
|
|
#6
|
|||
|
|||
|
Re: Receiving UDP packets on the CRIO
Thanks for the info. That's very very annoying, do you know if there are any plans to add support for it. We were going to take advantage of the UDP ports for a custom dashboard and breakout box, but we'd rather stay in java.
|
|
#7
|
|||
|
|||
|
Re: Receiving UDP packets on the CRIO
If you read team update #5 it mentions a TCP port you can take advantage of, it's currently what I'm using. There's really no good reason to be using UDP, seeing as communications are so close (it just ends up making things more complicated, but whatever).
Oh, port should be 1180, just remembered. |
|
#8
|
|||
|
|||
|
Re: Receiving UDP packets on the CRIO
Wouldn't that be a better reason to use UDP? If there's less of a chance of dropped packets, why bother with the added overhead of TCP?
|
|
#9
|
|||
|
|||
|
Re: Receiving UDP packets on the CRIO
Quote:
Besides apparently not being able to use UDP, TCP is generally easier to use, as a stream, than to have to fit everything into a fixed datagram and then unpack it (this is more of a personal choice, though). The only benefit of UDP will be if you are sending time sensitive information, otherwise I see no reason why it would be chosen to use. It doesn't matter either way. You can do some time tests with TCP vs UDP, if you want. |
|
#10
|
|||
|
|||
|
Re: Receiving UDP packets on the CRIO
I was planning on using the camera too, which according to the update is used by the camera. Also, I control data is time sensitive, so UDP seemed sensible.
|
|
#11
|
|||
|
|||
|
Re: Receiving UDP packets on the CRIO
I was looking at the WPILib/CLDC very carefully recently and I noticed that there is a package called com.sun.cldc.jna that specifies several classes to allow for calling native functions from Java. I was wondering if one could make use of vxWorks UDP functions and implement a UDP communication class using native vxWorks calls. I notice that this is what WPILib essentially does with functions like FRC_NetworkCommunication_JaguarCANDriver_sendMessa ge and FRC_NetworkCommunication_JaguarCANDriver_receiveMe ssage. It appears that this is almost like extern'ing in C/C++.
Alex Brinister |
|
#12
|
|||
|
|||
|
Re: Receiving UDP packets on the CRIO
This might be obsolete, as next year Java teams are no longer constrained to Java ME, and can use the full power of Java SE (which supports both TCP and UDP) on the RoboRio.
Don't think it is fruitful to attempt to add functionality to the current system since it will be phased out next season. Hope this helps, Kevin |
|
#13
|
|||
|
|||
|
Re: Receiving UDP packets on the CRIO
Agreed. Also the method I was suggesting doesn't work because to implement sockets in C, you need special types such as sockaddr, sockaddr_in and others and with the native library functions, you can only access functions from shared objects. It is certainly nice to hear they are replacing ME with SE!
Alex Brinister |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|