using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;  //api

namespace DL580_9130
{
    class readerDLL
    {
        //public struct TagIds
        //{
        //    public byte[] TagID;  //[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)] 
        //    byte Tagatype;
        //    byte AntNum;
        //    private TagIds(byte A, byte B, byte[] C)
        //    {
        //        this.Tagatype = A;
        //        this.AntNum = B;
        //        this.TagID =C;
        //    }
        //}
        public static IntPtr hComm;

        [DllImport("Reader.dll")]
        public  static extern short OpenReader(ref IntPtr hCom, byte LinkType,string com_port);   //打开通信口
        [DllImport("Reader.dll")]
        public static extern short CloseReader(IntPtr hCom);        //关闭通信口
        [DllImport("Reader.dll")]
        public static extern short SetBaudRate(IntPtr hCom, int BaudRate);     //设置波特率
        [DllImport("Reader.dll")]
        public static extern short ResetReader(IntPtr hCom); // 复位读写器
        [DllImport("Reader.dll")]
        public static extern short GetFirmwareVersion(IntPtr hCom, ref byte flag, ref byte major, ref byte minor);      //读写器版本信息
        [DllImport("Reader.dll")]
        public static extern short SingleTagIdentifyEX(IntPtr hCom, ref byte TagType,byte [] value);    //读卡标签ID，每次只读取一张
        [DllImport("Reader.dll")]
        public static extern short MultipleTagIdentify(IntPtr hCom, byte TagType, ref int Count,byte[] value);//读卡标签ID，每次读取多张
//      public static extern short MultipleTagIdentify(IntPtr hCom, byte TagType, ref int Count,ref TagIds value);//读卡标签ID，每次读取多张

        [DllImport("Reader.dll")]
        public static extern short ReadTagUserWithID(IntPtr hCom, byte  count, int Addr, byte[] Id, byte[] value);            //功能说明：读取指定标签指定地址的存储内容
        [DllImport("Reader.dll")]
        public static extern short WriteTagUserWithID(IntPtr hCom, byte  count, int Addr, byte[] Id, byte[] value, byte Result);  //写指定标签指定地址的存储区域
    }
}
