Sign in to follow this  
Followers 0
jomi

FINS - Connection Problen

14 posts in this topic

Hello everybody, I have some problems with the implementation of a FINS connection to a CJ2M-CPU32. I connect with a QTCPSocket in QT and get the right response containing the nodes. When I send a second command, like read some entry of DM-Register the response is wrong and the connection is closed by remote host. Here are the frames I sended and received: send: 46494E530000000C00000000000000000000000000 recv: 46494E53000000100000000100000000000000EF00000001 send: 46494E530000001A000000020000000080000300010000EF000101018201000003 recv: 46494E53000000080000000300000003 I compared my sended commands with those of Multiway ad they are identical. I also tried the connection using WinSockets with a similar result (Dosconnection at second command) Has anyone an idea what I am doing wrong? thanks jomi

Share this post


Link to post
Share on other sites
Hi, The packet does not look right to me. Here is an example. Some of the data might be wrong. I created it long ago when I was looking at FINS TCP and making notes. Any errror should be easy to resolve by looking in the specification, W421-E1-02. Read one word from D0014 Byte Hex Dec Desc 0 46 70 F 1 49 73 I 2 4E 78 N 3 53 83 S 4 0 0 Length 5 0 0 6 0 0 7 1A 26 8 0 0 Command 9 0 0 10 0 0 11 2 2 12 0 0 Error Code 13 0 0 14 0 0 15 0 0 16 80 128 Displays frame information ICF 1000 0000 bit 0 response required 17 0 0 Reserved by system RSB Bit 6 0 is command 1 is response 18 2 2 Permissible number of gateways GCT Fixed at 2 19 0 0 Destintation Network Address Number DNA 20 2 2 Destintation Node Number DA1 21 0 0 Destintation Unit Number DA2 22 0 0 Source Network Address Number SNA 23 4 4 Source Node Number SA1 24 0 0 Source Unit Address SA2 25 3 3 Service ID SID Use as table index 26 1 1 Main Request Code MRC Memory Area Read 27 1 1 Sub Request Code SRC 28 82 130 Memory Area Data memory 29 0 0 Beginning address 30 0E 14 31 0 0 32 0 0 No of items 33 1 1
1 person likes this

Share this post


Link to post
Share on other sites
Client to Server: 46494E53 0000000C 00000000 00000000 00000000 Server to Client: 46494E53 00000010 00000001 00000000 000000EF 0000000A(Mr PLC NODE NO. is ten) FINS FRAME SEND Command:46494E53 0000001A 00000002 00000000 800002 020A00 02EF00 00 0101 82 000000 0001(Read D0) Edited by vnforever10
1 person likes this

Share this post


Link to post
Share on other sites
Thank you very much. You really helped me out. I reimplemented the example code in the manual and it worked also in my application.

Share this post


Link to post
Share on other sites
Hi guys! I have a problem to implemented this protocol with Java. I want to read the alarm from word 142 to 172 and I send to PLC this packet: streamOut1.writeByte('F'); // HeaderstreamOut1.writeByte('I');streamOut1.writeByte('N');streamOut1.writeByte('S'); streamOut1.writeInt(26); //lenghtstreamOut1.writeInt(0x02);//cmd = 2streamOut1.writeInt(0x00); // Error Code streamOut2.writeByte(0x80); //ICF Information Control Field bit 7 Bridges (allways 1) ohter 0.streamOut2.writeByte(0x00); //RSV Reserved 00 AlwaysstreamOut2.writeByte(0x02); //GCT Gateway Count Ver.2.0 streamOut2.writeByte(0x00); //DNA Destination network address 00streamOut2.writeByte(0x01); //DA1 Destination node address Ethernet Node 01 CPU unitstreamOut2.writeByte(0x00); //DA2 Destination unit address Ethernet 00 CPU unitstreamOut2.writeByte(0x00); //SNA Source network address 00streamOut2.writeByte(0x03); //SA1 Source node address Fixed to 2.streamOut2.writeByte(0x00); //SA2 Source unit address 00 Node 00 PCstreamOut2.writeByte(0x00); //SID Service ID. 00 to FFstreamOut3.writeByte(mrcCmd); //0x01; //MRC Command Code (01,01 read) (01,02 write)streamOut3.writeByte(srcCmd); //0x01; //SRC Command CodestreamOut3.writeByte(memType); //0x82; //Memory Type: DMstreamOut3.writeByte(start); // the first word that i want to read streamOut3.writeByte(0x00); //start bit streamOut3.writeByte(nWord); //number of word that i want to readThis 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 1 0 0 3 0 0 1 1 82 -116 0 32 Please help me.. Thanks..

Share this post


Link to post
Share on other sites
Hello, Download and install the PeakHMI demo. In configuration mode set a read to read the data register you want. Install Wireshark if needed. Start Wireshark and begin a trace. Select the read test button in PeakHMI. Stop the read test after success. Stop Wireshark trace. Look at the trace in Wireshark and compare to what you are doing to find the error. My2c.

Share this post


Link to post
Share on other sites
I don't understand. I want to have a program that simulated PLC Omron with FINS protocol and then i can use my program written in Java to communicate with the simulator. There is a guide to follow for configure PeakHMI ? Thanks.

Share this post


Link to post
Share on other sites
I want to understand the logic of protocol. Can i send directly FINS READ COMMAND after inizializated socket to plc ? Or i have to send SEND FINS/TCP COMMAND after that SEND FINS COMMAND FRAME to read the words ? Thanks.

Share this post


Link to post
Share on other sites
Hello, > Is there a guide to configuring PeakHMI. Sure, there are videos, example projects, a 900+ page manual and a "Getting started" document. >..simulated PLC Omron FINS protocol. That is not what you said in your first message. Simulating the FINS protocol is one thing, not that difficult. Simulating a PLC, correctly, is a large undertaking. To your last post: open the socket and when it is connected (assuming TCP) issue the read command as is covered in the protocol specification. When you post a frame for us to look at, only post the data bytes, posting the source means I have to pick through all the code to get the data bytes. If you post only the data bytes, I can copy the bytes to a spreadsheet and decode rapidly. If I have to pick through, I will not do it. My2c. Edited by Mark-

Share this post


Link to post
Share on other sites
I have two class Main (connect and send command) and Listener (receive response of plc) ... Main.java: package com.prova;import java.io.*;import java.net.*;public class Main { static final String HOST = "192.168.1.7"; static final int PORT = 9600; static Socket socket = null; static Listener listenerThread = null; static OutputStream out_stream; static DataOutput out_data; //FUNZIONE CHE MI CONNETTE INVIANDO IL PRIMO PACCHETTO private static void Connect() { byte[] fins_tcp_header = new byte[20]; fins_tcp_header[0] = (byte) 'F'; // Header fins_tcp_header[1] = (byte) 'I'; fins_tcp_header[2] = (byte) 'N'; fins_tcp_header[3] = (byte) 'S'; fins_tcp_header[4] = (byte) 0x00; // Length fins_tcp_header[5] = (byte) 0x00; fins_tcp_header[6] = (byte) 0x00; fins_tcp_header[7] = (byte) 0x0C; fins_tcp_header[8] = (byte) 0x00; // Command fins_tcp_header[9] = (byte) 0x00; fins_tcp_header[10] = (byte) 0x00; fins_tcp_header[11] = (byte) 0x00; fins_tcp_header[12] = (byte) 0x00; // Error Code fins_tcp_header[13] = (byte) 0x00; fins_tcp_header[14] = (byte) 0x00; fins_tcp_header[15] = (byte) 0x00; fins_tcp_header[16] = (byte) 0x00; // Client Node Add fins_tcp_header[17] = (byte) 0x00; fins_tcp_header[18] = (byte) 0x00; fins_tcp_header[19] = (byte) 0x00; // Client fins node addresses are automatically obtained when set to 0 //printSendData(fins_tcp_header); StampoPacchetto(fins_tcp_header); try{ out_data.write(fins_tcp_header); } catch( Exception e ) { e.printStackTrace(); } } //COMANDO DI LETTURA WORD ALLARMI private static void SendReadFinsCommand() { byte[] fins_tcp_header = new byte[16]; byte[] fins_header = new byte[10]; byte[] fins_cmnd = new byte[8]; fins_tcp_header[0] = (byte) 'F'; // Header fins_tcp_header[1] = (byte) 'I'; fins_tcp_header[2] = (byte) 'N'; fins_tcp_header[3] = (byte) 'S'; fins_tcp_header[4] = (byte) 0x00; // Length fins_tcp_header[5] = (byte) 0x00; fins_tcp_header[6] = (byte) 0x00; fins_tcp_header[7] = (byte) 0x1A; // LUNGHEZZA DAL COMANDO ALLA FINE DEL PACCHETTO fins_tcp_header[8] = (byte) 0x00; // Command fins_tcp_header[9] = (byte) 0x00; fins_tcp_header[10] =(byte) 0x00; fins_tcp_header[11] = (byte) 0x02; fins_tcp_header[12] = (byte) 0x00; // Error Code fins_tcp_header[13] = (byte) 0x00; fins_tcp_header[14] = (byte) 0x00; fins_tcp_header[15] = (byte) 0x00; fins_header[0] = (byte) 0x80; //ICF Information Control Field bit 7 Bridges (allways 1) ohter 0. fins_header[1] = (byte) 0x00; //RSV Reserved 00 Always fins_header[2] = (byte) 0x02; //GCT Gateway Count Ver.2.0 fins_header[3] = (byte) 0x00; //DNA Destination network address 00 fins_header[4] = (byte) 0x01; //DA1 Destination node address Ethernet Node 01 CPU unit fins_header[5] = (byte) 0x00; //DA2 Destination unit address Ethernet 00 CPU unit fins_header[6] = (byte) 0x00; //SNA Source network address 00 fins_header[7] = (byte) 0x02; //SA1 Source node address Fixed to 2. fins_header[8] = (byte) 0x00; //SA2 Source unit address 00 Node 00 PC fins_header[9] = (byte) 0x00; //SID Service ID. 00 to FF fins_cmnd[0] = (byte) 0x01; //MRC Command Code (01,01 read) (01,02 write) fins_cmnd[1] = (byte) 0x01; //SRC Command Code fins_cmnd[2] = (byte) 0x82; //Memory Type: DM fins_cmnd[3] = (byte) 0x00; //start word read (2 byte) - inizio dalla word 142 fins_cmnd[4] = (byte) 0x8C; fins_cmnd[5] = (byte) 0x00; //Bit word fins_cmnd[6] = (byte) 0x00; //quante word (2 byte) - 32 word fins_cmnd[7] = (byte) 0x20; //printSendData(fins_tcp_header); //printSendData(fins_header); //printSendData(fins_cmnd); StampoPacchetto(fins_tcp_header); StampoPacchetto(fins_header); StampoPacchetto(fins_cmnd); try { out_data.write(fins_tcp_header); out_data.write(fins_header); out_data.write(fins_cmnd); } catch (IOException e) { e.printStackTrace(); } } //STAMPO PACCHETTO HEX private static void printSendData(byte [] data) { int j=0; StringBuilder sb = new StringBuilder(); for (byte b : data) { j++; sb.append(String.format("%02X", b)); if (j==4){ sb.append(" "); j=0; } } System.out.println("Send: "+sb.toString()); } //FUNZIONE CHE MI STAMPA I BYTE DI UN PACCHETTO (ARRAY DI BYTE) public static void StampoPacchetto(byte[] data) { for(byte b: data) { // print character System.out.print(b + " "); } System.out.println(" \n"); } public static void main(String[] args) { try { socket = new Socket (HOST,PORT); System.out.println("Connected using IP: "+ socket.getLocalSocketAddress()+" Port: "+socket.getLocalPort()); } catch (IOException e) { e.printStackTrace(); } listenerThread = new Listener (socket); listenerThread.start(); try { out_data = new DataOutputStream(socket.getOutputStream()); } catch (IOException e1) { e1.printStackTrace(); } Connect(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } SendReadFinsCommand(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } }}Class Listener.java : package com.prova;import java.io.DataInputStream;import java.io.IOException;import java.net.Socket;public class Listener extends Thread { Socket listener; boolean running = false; DataInputStream in_data = null; byte nodeNumber = 0; private void PrintData(byte [] buffer) { int j=0; StringBuilder sb = new StringBuilder(); for (byte b : buffer) { j++; sb.append(String.format("%02X", b)); if (j==4){ sb.append(" "); j=0; } } System.out.println("Receive: "+sb.toString()); } //FUNZIONE CHE MI STAMPA I BYTE DI UN PACCHETTO (ARRAY DI BYTE) public static void StampoPacchetto(byte[] data) { for(byte b: data) { // print character System.out.print(b + " "); } System.out.println(" \n"); } public Listener(Socket listener_socket) { listener = listener_socket; running = true; } public void run(){ while(running) { byte [] received_buffer = new byte [40]; try{ System.out.println("Listening..."); in_data = new DataInputStream(listener.getInputStream()); in_data.read(received_buffer); } catch (IOException e) { e.printStackTrace(); running = false; } StampoPacchetto(received_buffer); if (received_buffer[15] == 0x03) { running = false; try { listener.close(); } catch (IOException e) { e.printStackTrace(); } } } } public void stopListening() { running = false; }}Thanks a lot..

Share this post


Link to post
Share on other sites
This is a useful pdf https://www.kepware.com/products/kepserverex/drivers/omron-fins-ethernet/documents/omron-fins-ethernet-manual/

Share this post


Link to post
Share on other sites
I don't know if it's ok... I hope that you can tell me if it is ok or not... tomorrow or Friday I have to do a test in a factory...

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