0

我正在使用感应读卡器读取卡号。使用生产者软件,当我阅读时,我得到了这个数字:

BF 1C 08 04 01

但是使用我的应用程序这个:

3F-1C-08-04-01

代码:

void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
    {
            _received += sp.ReadExisting();
            ASCIIEncoding encoding = new ASCIIEncoding();
            byte[] bytes = encoding.GetBytes(_received);
            bytes = SubArray(bytes, 5, 5);//to get only that I need
            string s2 = BitConverter.ToString(bytes);


            _received = s2.Replace("-", "");

            string result = SocketSendReceive(host, port);

            _received = "";
    }

有任何想法吗?

4

0 回答 0