paolo Posted December 20, 2008 Report Posted December 20, 2008 Good evening for everyone,i'm a new user.... I try to send and recieve data from etn21 via tcp with c# code.... with this method i create a new connection: private static Socket ConnectSocket(string server, int port) { Socket s = null; IPHostEntry hostEntry = null; hostEntry = Dns.GetHostEntry(server); foreach(IPAddress address in hostEntry.AddressList) { IPEndPoint ipe = new IPEndPoint(address, port); Socket tempSocket = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp); tempSocket.Connect(ipe); if(tempSocket.Connected) { s = tempSocket; break; } else { continue; } } return s; } so return to me an istance of shoket.... after i send to etn21 this command: fins_tcp_header[0] = 0x46; fins_tcp_header[1] = 0x49; fins_tcp_header[2] = 0x4E; fins_tcp_header[3] = 0x53; fins_tcp_header[4] = 0x00;/* Length */ fins_tcp_header[5] = 0x00; fins_tcp_header[6] = 0x00; fins_tcp_header[7] = 0x0C; fins_tcp_header[8] = 0x00;/* Command */ fins_tcp_header[9] = 0x00; fins_tcp_header[10] = 0x00; fins_tcp_header[11] = 0x00; fins_tcp_header[12] = 0x00;/* Error Code */ fins_tcp_header[13] = 0x00; fins_tcp_header[14] = 0x00; fins_tcp_header[15] = 0x00; fins_tcp_header[16] = 0x00; fins_tcp_header[17] = 0x00;/* Client Node Add */ fins_tcp_header[18] = 0x00; fins_tcp_header[19] = 0x00; fins_tcp_header[20] = 0x00;/*AUTOMATICALLY GET FINS CLIENT FINS NODE NUMBER*/ s.Send(fins_tcp_header, fins_tcp_header.Length, 0); do { bytes = s.Receive(bytesReceived, bytesReceived.Length, 0); cli_node_no = bytesReceived[19]; srv_node_no = bytesReceived[23]; } and the etn21 response correctly : 80 (server node) and 239 (client node) and the TCP led on module is on so after i send the command to read 3 DM: fins_cmnd1[0] = 0x46; //'F'; fins_cmnd1[1] = 0x49; //'I'; fins_cmnd1[2] = 0x4E; //'N'; fins_cmnd1[3] = 0x53; //'S'; fins_cmnd1[4] = 0x00;/* Length */ fins_cmnd1[5] = 0x00; fins_cmnd1[6] = 0x00; fins_cmnd1[7] = 0x1A; fins_cmnd1[8] = 0x00;/* Command */ fins_cmnd1[9] = 0x00; fins_cmnd1[10] = 0x00; fins_cmnd1[11] = 0x02; fins_cmnd1[12] = 0x00;/* Error Code */ fins_cmnd1[13] = 0x00; fins_cmnd1[14] = 0x00; fins_cmnd1[15] = 0x00; fins_cmnd[16] = 0x80; /* ICF */ fins_cmnd[17] = 0x00; /* RSV */ fins_cmnd[18] = 0x03; /* GCT */ fins_cmnd[19] = 0x00; /* DNA */ fins_cmnd[20] = 0x50;//srv_node_no.ToString("x"); /* DA1 */ fins_cmnd[21] = 0x00; /* DA2 */ fins_cmnd[22] = 0x00; /* SNA */ fins_cmnd[23] = 0xEF;//cli_node_no.ToString("x"); /* SA1 */ fins_cmnd[24] = 0x00; /* SA2 */ fins_cmnd[25] = 0x07;//++sid; /* SID */ fins_cmnd[26] = 0x01; /* MRC */ fins_cmnd[27] = 0x01; /* SRC */ fins_cmnd[28] = 0x82; fins_cmnd[29] = 0x00; fins_cmnd[30] = 0x01; fins_cmnd[31] = 0x00; fins_cmnd[32] = 0x00; fins_cmnd[33] = 0x03; s1.Send(fins_cmnd, fins_cmnd.Length, 0); But here when i execute this command the TCP led on module turn off and the data recieved are incorrect What i mistake???? Can someone help to me???
Berti Baker Posted January 8, 2009 Report Posted January 8, 2009 Hi Paolo, Wow! what a post I can't help you directly but as no-one else has any ideas I would suggest perhaps using some Ethernet Sniffer program and watching packets from Omron software to copy (as a test of your packet construction). If it was me though (as I'm a lazy ...) I would buy CX-Server Lite. It only costs €200-300 and includes a .Net communications control for C# and example programs. It also handles ALL PLCs, all the networks, and all the different protocols. For me... not worth my time developing it myself There is even a free demo version here Regards, Bertie.
BobB Posted January 8, 2009 Report Posted January 8, 2009 Here is a link for Wireshark (formerly Ethereal) download - it is a free Ethernet sniffer http://www.wireshark.org/
paolo Posted January 16, 2009 Author Report Posted January 16, 2009 Hi thanks a lot for your suggestion..during the holiday time i have develp a little internet application with remote web service (java and asp.net) for etn21 and it work very fine only an UDP protocol.... Maybe with the tcp protocol i mistake some instruction...I hope in the next to solve this problem... Thanks again Paolo P.S. Sorry about my english....
hock Posted October 15, 2014 Report Posted October 15, 2014 your GCT is wrong.. is supposed to be 02 instead of 03 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now