Group Abstract Group Abstract

Message Boards Message Boards

Streaming data from my robot to Mathematica over UDP

Posted 10 years ago
POSTED BY: LV VS
9 Replies
Posted 6 years ago

Thanks a lot for sharing, Ian.

The error occurs because the InetAddress class has not been loaded. Add this line after InstallJava[]:

LoadJavaClass["java.net.InetAddress"]
POSTED BY: Marcus M
Posted 8 years ago

Hi Ian, I'm getting the exact same error as Pedro. Using version 11.3

POSTED BY: Diego Zviovich

Hi,

When applying the above code, I get the following message after using the writeSocket:

writeSocket[udpSocket, "127.0.0.1", 5000, ToCharacterCode["hello from mathematica"]]

JavaNew::argx: Incorrect number or type of arguments to constructor for class java.net.DatagramPacket. The arguments, shown here in a list, were {{104,101,108,108,111,32,102,114,111,109,32,109,97,116,104,101,109,97,116,105,99,97},22,InetAddress`getByName[127.0.0.1],5000}.

Java::argx1: Method named send defined in class java.net.DatagramSocket was called with an incorrect number or type of arguments. The argument was $Failed.

$Failed

any idea why?

POSTED BY: Pedro Fonseca
Posted 8 years ago
POSTED BY: Updating Name

Ah. Copy/pasting the writeSocket function to the reply section here seems to have taken out some necessary formatting. When I added back in the underscores for the function arguments and matched those arguments to the variables in the function body, all is good.

Good to hear.

POSTED BY: Ian Johnson
POSTED BY: Ian Johnson

Hi Ian, I'm having trouble getting this example to run as written (Mathematica version 11.0.1.0) -- seems to be something in the writeSocket function, possibly InetAddress, but I can't figure it out. Anyone else having trouble? Thanks, Chris

Hi Christopher,

What exactly is the error message you're seeing? It's possible that there were changes in 11.0.1 that broke the code I posted above.

Thanks,

Ian

POSTED BY: Ian Johnson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard