I am working on a client application that is supposed to send a signal to modbus that opens and close a gate with ip address and non-changeable port number 502. The instruction say to create a win-socket client application and send command buffer. I don't understand how to send the command buffer. This is a snapshot of commands. Modbus Commands
I have created a Java socket client class but I don't know what message to send and what datatype to use to send a message. or am I supposed to use one of the modbus libraries to send a signal. Thank you!
socket = new Socket("192.168.0.8, 502);
OutputStream output = socket.getOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(output);
BufferedWriter bw = new BufferedWriter(writer);
short buffer = ??; // don't know what to send here
//String sendMesage = buffer;
bw.write(buffer);
bw.flush();
System.out.println("Message sent to the server: " + buffer);
InputStream receive = socket.getInputStream();
InputStreamReader reader = new InputStreamReader(receive);
BufferedReader bufferedReader = new BufferedReader(reader);