C#读写西门子PLC DB数据,S7协议

C#读写西门子PLC DB数据,S7协议

此Demo使用snap7类库开发,snap7为开源类库,无需在网上找那些付费的库,hsl…这些,直接免费使用,没必要去花钱
在这里插入C#读写西门子PLC DB数据,S7协议_第1张图片

C#读写西门子PLC DB数据,S7协议_第2张图片

[DllImport(S7Consts.Snap7LibName)]
        protected static extern int Cli_DBRead(IntPtr Client, int DBNumber, int Start, int Size, byte[] Buffer);
        public int DBRead(int DBNumber, int Start, int Size, byte[] Buffer)
        {
            return Cli_DBRead(Client, DBNumber, Start, Size, Buffer);
        }

        [DllImport(S7Consts.Snap7LibName)]
        protected static extern int Cli_DBWrite(IntPtr Client, int DBNumber, int Start, int Size, byte[] Buffer);
        public int DBWrite(int DBNumber, int Start, int Size, byte[] Buffer)
        {
            return Cli_DBWrite(Client, DBNumber, Start, Size, Buffer);
        }

        [DllImport(S7Consts.Snap7LibName)]
        protected static extern int Cli_MBRead(IntPtr Client, int Start, int Size, byte[] Buffer);
        public int MBRead(int Start, int Size, byte[] Buffer)
        {
            return Cli_MBRead(Client, Start, Size, Buffer);
        }

https://download.csdn.net/download/qq_36762573/85506253

你可能感兴趣的:(c#,wpf)