Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

readUTF() not working with URCap Development - Java Socket

$
0
0

I'm developing an URCap to a camera installed in an UR Robot and I need to write to and read the response from the camera.

The camera is equipped with an object detection algorithm and the way it works is: we send a String "Run.LocateAll" to it and it returns us the coordinates of the detected objects as "x,y,z,rx,ry,rz" in a string format as well. I am able to send the locate command using writeByte() method (I tried to use writeUTF(), but it strangely sends "%Run.LocateAll" with a % in the beginning of the string, so it doesn't work) and I know that the command is working cause the camera GUI show me the located object.

The problem is the reading, because when I use the readUTF() method the robot program freezes. I already tried other methods like readLine() (it freezes as well), but with no success. I'm gonna put the screenshots of my code and the robot program for you to see.

private static void socketCommunication(ScriptWriter writer, String ip, int port) {    try{              Socket s=new Socket(ip,port);          DataOutputStream dout = new DataOutputStream(s.getOutputStream());         dout.writeBytes("Run.LocateAll,3");        DataInputStream din = new DataInputStream(s.getInputStream());        System.out.println(din.readUTF());        din.close();        dout.flush();        dout.close();          s.close();      }    catch(Exception e){System.out.println(e);}}

enter image description here

I expected that my program could read from the socket and return me the string "(x,y,z,rx,ry,rz)" of the detected objects


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>