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

namespace CsharpLfReaderExample
{
    class Program
    {
        static void Main(string[] args)
        {
            if (test.gConnReader("com8", 0))
            {
                test.gSetBeep(100, 0);

                //StringBuilder str_out = new StringBuilder(50);
                bool res = false;
                int len = 0;
                byte[] str_out = new byte[50];
                res = test.gGetModel(ref str_out[0], ref len, 0);
                
                Console.WriteLine(str_out);
                Console.WriteLine(len);

                test.gDiscReader(0);
            }
            else 
            {
                Console.WriteLine("connect error");
            }
            Console.ReadLine();
        }
    }

    class test
    {
        [DllImport("RFID_LF_DLL.dll")]
        public static extern bool gConnReader(string port, int addr);

        [DllImport("RFID_LF_DLL.dll")]
        public static extern bool gDiscReader(int addr);

        [DllImport("RFID_LF_DLL.dll")]
        public static extern bool gSetBeep(Byte time, int addr);

        [DllImport("RFID_LF_DLL.dll")]
        public static extern bool gGetModel(ref byte model, ref int len, int addr);
    }
}
