I am trying to develop software for torque. I connect to device by java sockets, but I don't know how to establish session with torque. Establish communication steps:
me(client):send- MID 0001
torque(server):send- MID 0002
To do this I have to convert message MID 0001 to OPEN Protocol, according to documentation the result is:002000010000000000000
When I send this message server don't answer.
Maybe my message isn't converted to Open protocol good?
I was trying with sending message as bytes or string. Anyone know how to establish connection with Stanley torque using alpha open protocol and Java?
My client code:
public class MyClientSocket {
private static Socket socket;
public static void main(String args[]) {
try {
String host = "192.168.1.15";
int port = 4545;
InetAddress address = InetAddress.getByName(host);
socket = new Socket(address, port);
//Send the message to the server
DataOutputStream os = new DataOutputStream(socket.getOutputStream());
String sendMessage = "002000010000000000000";
byte[] bytes = sendMessage.getBytes(StandardCharsets.US_ASCII);
os.write(bytes);
// os.writeUTF(sendMessage);
System.out.println("Message sent to the server : " + sendMessage);
//Get the return message from the server
InputStream is = socket.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String message = br.readLine();
System.out.println("Message received from the server : " + message);
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
this is output:
Message sent to the server : 002000010000000000000
Message received from the server : null
Process finished with exit code 0
Please help me.
I found solution by myself. The last zero in message is end message zero and i had to wrote message like this:
"00200001000000000000\0"