URCap Dashboard Server response

Hello,

Maybe someone have encountered this issue.
The URCap which I try to build will have some buttons for performing some actions, load program, start, pause, etc.
This is done by using the Dashboard Server. I can send the commands without any issues, the robot responds, everything is ok.
My issue is that I do not receive any response. It is stated at the link below that there is a response from the Server.

https://www.universal-robots.com/articles/ur/dashboard-server-cb-series-port-29999/

For example when I send start I expect to receive “Starting program” but is nothing on the Input Stream Buffered Reader.
Sometimes I get Connected: “Universal Robots Dashboard Server”.
I have tried putting \n character after play, \r\n after play, create a new buffered reader after I send the command, read from the buffered reader and skip 44 characters (the length of the automatic message from the server).
I have tried reading character by character with no results.
I have tried to make a connection every time when I send the command by opening a socket, read the first line, send command and then read again a new line but this hangs the URCap.

In conclusion I know that the socket is connected because I have the movement which is OK, when I send START the robot starts the program, but I do not receive the feedback from the SERVER. Maybe they do not have a newline character, but if this true how it is expected to read them?

Thank you in advance!

1 Like

Hello again,

Below the code which I try and still no response from the server.
If I try with socket test the server respond.

public void sendStop() {
	try {
		// Create a new Socket Client
		Socket sc = new Socket("127.0.0.1", 29999);
		if (sc.isConnected()) {
			// Create stream for data
			DataOutputStream out;
			out = new DataOutputStream(sc.getOutputStream());
			String command = new String();
			command = "stop";
			// Send command
			out.write(command.getBytes("US-ASCII"));
			BufferedReader readerFromURScript = new BufferedReader(new InputStreamReader(sc.getInputStream()));
			String input1 = readerFromURScript.readLine();
			readerFromURScript.close();
			out.flush();
			// Perform housekeeping
			out.close();
		}
		sc.close();
	} catch (IOException e) {
		System.out.println(e);
	}
}

I am expecting to receive

Thanks in advance!

The response won’t be instantaneous, only once the command has been completed. Could your readLine be timing out before the response arrives?

Hello ajp,

Good point. I will try to put a delay or somehow slow the URCap so I am waiting for a response. Even if the Play command is completed almost instantaneous.

I will try and come back with a feedback.

Thank you!

Hello,

So I have tried your idea with the delay to have the time to get a response and I get a response.
I get “Connected: Universal Robots Dashboard Server”.
I have tried to read another time but the socket reader is blocking the URCap. As I understand the issue is that the Buffered Reader ReadLine waits for a /n character from the robot. I have tried with the SocketMaster and it works without issue.
Below my code:

public void sendPlay()  {
							
						
		try {
			// Create a new Socket Client
			Socket sc = new Socket("127.0.0.1", 29999);
						
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			BufferedReader readerFromURScript11;
			readerFromURScript11 = new BufferedReader(new InputStreamReader(sc.getInputStream()));
				String input11 = readerFromURScript11.readLine();
				System.out.println(input11);
			
			// here my code is blocked. If I leave it like here i get the response "Connected: Universal Robots Dashboard 
                        //Server" and then the entire URCap is blocked.If I delete the part from above the code runs without any issues 
                        //but the response is the same.
			
			if (sc.isConnected()) {			
				    
				    
				DataOutputStream out;
				out = new DataOutputStream(sc.getOutputStream());
				
				String command = new String();

				command = "play"+ '\n';
				// Send command
				out.write(command.getBytes("US-ASCII"));		
				out.flush();
				
				try {
					Thread.sleep(500);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
				
				BufferedReader readerFromURScript10;
				readerFromURScript10 = new BufferedReader(new InputStreamReader(sc.getInputStream()));
  				String input10 = readerFromURScript10.readLine();
  				System.out.println(input10);
				// Perform housekeeping
				out.close();
			}
			sc.close();
		} catch (IOException e) {
			System.out.println(e);
		}
		
	}		



Thanks in advance!

Hi @vl4dutz_1 , not sure why the subsequent responses wouldn’t include a newline, but that seems to be the way it is.

Seems you can work around this by taking the data straight from the InputStream and no not using the BufferedReader as shown in the answer to the below post:

Hello @ajp,

I have tried the method from the post which you presented with no success.
The situation is the same, the behavior is exactly the same.
Another idea?

Thanks!

Hello,

Just as info with SocketTest works without any issues.
I have no idea.

Thanks!

Hello together,

Does anybody has an idea regarding the dashboard server response?
I have tried everything, reading from bufferedreader, straight from the input stream, every hint find on the Internet with no success.

Thanks!

Hello @ajp,

One short question, the Dashboard Server has some limitations regarding sending responses to an URCAP? Are there some rules?
Because I can send “play” to the dashboard server and get a response from the SocketTest app, and also if I use the URCAP to send a message to a standalone server created by the SocketTest app it works. Again if I send the “play” command without reading the response the robot starts the program.The only situation where it does not work is when I try to read a response from the Dashboard Server inside the URCAP.

Thanks in advance!

Or to put it in another words I have tried 3 versions:

  • first version is just socket connect–send command–close socket WORKS
  • second version is just socket connect-- read first line (“Universal Robot Connected Dashboard”) WORKS
  • third version is socket connect–read first line (“Universal Robot Connected Dashboard”)-- send command–read response; DOES NOT WORK
    I have already tried the software and works with an external server created by the Socket Test.
    The issue is reading the response from the Dashboard Server inside an URCAP.

Thanks!

Hi @vl4dutz_1,

If your methods are executed from the the Swing GUI thread (event dispatch thread). I will suggest to make use of the invokeLater method:
https://docs.oracle.com/javase/7/docs/api/javax/swing/SwingUtilities.html#invokeLater(java.lang.Runnable)

Ebbe

2 Likes

Hello @Ebbe ,

Thank you very much for your time and your idea.
It worked perfectly. For anyone which has a problem with this topic please see below the code which works without any issue.
Thank you very much again and have a nice evening.

public void sendPlay() {
    Thread appThread = new Thread() {
			public void run() {
				try {
					RobotTester robot = new RobotTester("127.0.0.1", 29999);
			            System.out.println("Connected to robot.");
			            robot.nextInput();               //Read and print robot's welcome message
			            robot.writeCommand("play");      //Send command
			            String resp = robot.nextInput(); //Read result
				} catch (Exception e) {
					e.printStackTrace();
				}
				System.out.println("Finished on " + Thread.currentThread());
			}
		};
		appThread.start();
}
1 Like

Great to see you got it resolved!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.