Sign in to follow this  
Followers 0
ngo4life

send FINS command using Java UDP/IP

4 posts in this topic

/* This program will read 150 words of data memory starting from D100 * The ethernet unit IP address is 123.456.789.01 * The PC IP address is 123.456.789.02 * Note: I as the poster, will not be responsible for any damage/injure in properties and/or human. * Try this at your own risk. This is for someone who knows java and omron plc programming. */ // get a datagram socket try{ socket = new DatagramSocket(); } catch(SocketException se){ } // send request byte[] buf = new byte[18]; buf[0] = (byte) 0x80; //ICF buf[1] = (byte) 0x00; //RSV buf[2] = (byte) 0x02; //GCT buf[3] = (byte) 0x00; //DNA buf[4] = (byte) 0x01; //DA1 buf[5] = (byte) 0x00; //DA2 buf[6] = (byte) 0x00; //SNA buf[7] = (byte) 0x02; //SA1 buf[8] = (byte) 0x00; //SA2 buf[9] = (byte) 0x00; //SID buf[10] = (byte) 0x01; //MRC buf[11] = (byte) 0x01; //SRC buf[12] = (byte) 0x82; //Variable Type:DM buf[13] = (byte) 0x00; buf[14] = (byte) 0x64; buf[15] = (byte) 0x00; buf[16] = (byte) 0x00; buf[17] = (byte) 0x96; try{ address = InetAddress.getByName("123.456.789.01"); } catch(UnknownHostException uhe){ } packet = new DatagramPacket(buf, buf.length, address, 9600); try{ socket.send(packet); } catch(IOException ioe){ } byte[] buf1 = new byte[1000]; packet1 = new DatagramPacket(buf1,buf1.length); try{ socket.receive(packet1); } catch(SocketException se){ System.out.println("can't receive packet"); } catch(IOException ioe){ System.out.println("can't receive packet"); }

Share this post


Link to post
Share on other sites
I tried this and it works. I got response. Thanks. But you need to convert the response in order to understand.

Share this post


Link to post
Share on other sites
Hi guys! There is a way to try this code? Thanks. I have to do the same thing; communicate to omron fins protocol by tcp/ip in java. Before read this post I used DataInputStream,DataOutpurSterean with ByteArrayOuputStream and ByteArrayInputStream with normal socket not datagramsocket. It use correct to use datagramsocket? Help me.. Thanks.

Share this post


Link to post
Share on other sites
I have done a test in a factory. This is the packet that I send to PLC: 70 73 78 83 0 0 0 26 0 0 0 2 0 0 0 0 -128 0 2 0 0 0 0 -13 0 100 1 1 -126 0 -116 0 0 32 -> read word from word 140 to 172. This is the response of PLC: 70, 73, 78, 83, 0, 0, 0, 16, 0, 0, 0, 1, 0, 0, 0, 2, -128, 0, 2, 0, 0, 0, 0, 80 Can someone help me please? Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0