0

I'm using proximity card reader to read card number. Using producer software, when I read I'm getting this number:

BF 1C 08 04 01

But using my application this one:

3F-1C-08-04-01

Code:

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 = "";
    }

Any ideas?

user13657
  • 745
  • 3
  • 17
  • 36
  • ASCII only goes up to 127, but 0xBF exceeds that limit. Perhaps that's the problem. What happens if you use `Encoding.Default` instead of `ASCIIEncoding`? – Matthew Watson Jan 23 '15 at 09:32
  • Result is 01-0D-13-00-01-3F-1C-08-04-01-3F-53-3F, but im taking only 5 from index 5, so it's 3F-1C-08-04-01 - the same wrong value – user13657 Jan 23 '15 at 09:37
  • Well, maybe there is another topic with this problem, but with every Encoding I'm getting the same (wrong) values. – user13657 Jan 23 '15 at 09:44
  • So yea, well, still have no idea wha'ts wrong assuming solution from that other topic.. – user13657 Jan 23 '15 at 09:56

0 Answers0