﻿//============================================================-
//	MODBUSTCPCS.CS
//	Class file for libmodbus
//												CONTEC.Co.,Ltd.
//============================================================-
using System;
using System.Runtime.InteropServices;

public enum ModbusTcpConst
{
    //----------------------------------------
    //Parameters
    //----------------------------------------
    //----------------------------------------
    //ModbusTCP Port Number
    //----------------------------------------
    MODBUS_TCP_DEFAULT_PORT = 502,
    //----------------------------------------
    //ModbusTCP Slave Id
    //----------------------------------------
    MODBUS_TCP_SLAVE = 255,
    // ----------------------------------------
    // TCP MODBUS ADU
    // ----------------------------------------
    //Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5
    //253 bytes + MBAP (7 bytes) = 260 bytes
    MODBUS_TCP_MAX_ADU_LENGTH = 260,
}

namespace ModbusTcpCs
{
    public class ModbusTcp
    {
        [DllImport("modbus.dll", CallingConvention = CallingConvention.Cdecl)] static extern IntPtr modbus_new_tcp(string ip_address, int port);

        public IntPtr NewTcp(string ip_address, int port)
        {
            IntPtr ctx = modbus_new_tcp(ip_address, port);
            return ctx;
        }
    }

    // Description of common functions

}

