FINS

 1 string SERV_IP_ADDR = "192.168.250.1";
 2 const int FINS_UDP_PORT = 9600;
 3 
 4 byte[] sendPacket = new byte[]
 5 {
 6     // Full UDP packet: 80 00 02 00 00 00 00 05 00 19 01 02 82 00 64 00 00 01 00 01
 7 
 8     // Header
 9         0x80//0.(ICF) Display frame information: 1000 0001
10         0x00//1.(RSV) Reserved by system: (hex)00
11         0x02//2.(GCT) Permissible number of gateways: (hex)02
12         0x00//3.(DNA) Destination network address: (hex)00, local network
13         0x00//4.(DA1) Destination node address: (hex)00, local PLC unit
14         0x00//5.(DA2) Destination unit address: (hex)00, PLC
15         0x00//6.(SNA) Source network address: (hex)00, local network
16         0x05//7.(SA1) Source node address: (hex)05, PC's IP is 192.168.250.5
17         0x00//8.(SA2) Source unit address: (hex)00, PC only has one ethernet
18         0x19//9.(SID) Service ID: just give a random number 19
19 
20         // Command
21         0x01//10.(MRC) Main request code: 01, memory area write
22         0x02//11.(SRC) Sub-request code: 02, memory area write
23 
24         // PLC Memory Area
25         0x82//12.Memory area code (1 byte): 82(DM)
26 
27         // Address information
28         0x00//13.Write start address (2 bytes): D100
29         0x64
30         0x00//15.Bit address (1 byte): Default 0
31         0x00//16.No. of items (2 bytes): only one address which is D100
32         0x01,
33 
34         // Write Data
35         0x00//18.Data to write (2 bytes): value is 1
36         0x01,
37 }; 
posted @ 2012-10-30 20:47  歪歪不歪  阅读(591)  评论(1)    收藏  举报