Jump to content

Ardivaba

Members
  • Posts

    4
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Ardivaba

  1. Are you certain that the issue is not with your Profilic drivers? They have to be old ones from 2008. Look at this video here: The download link to old drivers is in the description. Apparently they decided to disable support for Windows 8+ so that people would buy new cables but fortunately old drivers still work with Windows 8 and 10. U90 works nicely on my Win8.
  2. R&D Guru, thank you very, very much for noting out the \n != \r mistake. As soon as i changed that, i got my response. You made my day. Cheers, Ardi Vaba
  3. Thank you for such a quick response. That gave me confidence that i am not doing something extremely stupid. I will try to get to the bottom of this. My goal is to connect PLC with Android smartphones, hence the need to do it using Java. Needless to say, i am software guy that is somewhat new to automatics world. If i fail to get this communication to work i'll simply set up .NET server as a middleman and use .NET communications driver but this does add the requirement of a server which is not very good.
  4. Hello. I am unable to get any information from PLC using Java currently. It does manage to connect to it though, as while the application is running and socket is connected, no other software can communicate with plc. I have spent a better part of my day trying to get my Java application to communicate with PLC but without much. I also haven't found any information regarding Java Unitronics driver so i guess there isn't one? I would appreciate any kind of help. Code below. Cheers, Ardi Vaba import java.io.*; import java.net.Socket; import java.nio.ByteBuffer; public class asd { private static final String HOST = "192.168.1.74"; private static final int PORT = 20256; public static void main(String[] args) throws IOException { Socket socket = new Socket(HOST, PORT); //I still don't underastand what [0] and [1] are for... byte[] tcpHeader = new byte[6]; tcpHeader[0] = 1; //??? tcpHeader[1] = 0; //??? tcpHeader[2] = 101; //Ascii comm type tcpHeader[3] = 0; tcpHeader[4] = 14; ///01RE0020051F + CRC = 14 tcpHeader[5] = 0; String message = "/01RE0020051F\n"; byte[] finalMessage = new byte[message.getBytes("ASCII").length + tcpHeader.length]; //Let's add messange and hader together... ByteBuffer buffer = ByteBuffer.wrap(finalMessage); buffer.put(tcpHeader); buffer.put(message.getBytes("ASCII")); //Let's wait until socket is connected...just to be sure while(!socket.isConnected()){} System.out.println("Sending ascii message..."); //Send the message socket.getOutputStream().write(finalMessage); //Start waiting for response... BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream())); System.out.println("Starting to wait for response..."); String response = ""; while((response = reader.readLine()) != null) { System.out.println(response); } } } Updated code to more readable format...
×
×
  • Create New...