磁卡读卡器无意义的数据 [英] Magnetic card reader meaningless data

查看:71
本文介绍了磁卡读卡器无意义的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MSR206读卡器设备,我编写了一个应用程序,用C#在其上写数据:

I have a MSR206 card reader device, and I wrote an application to write data on it in C#:

SerialPort sp = new SerialPort(driveletter);
List<byte> bytes = new List<byte>();
            bytes.Add(0x1B);
            bytes.Add(0x77);
            bytes.Add(0x1B);
            bytes.Add(0x73);
            bytes.Add(0x1B);
            bytes.Add(0x01);
            bytes.AddRange(Encoding.ASCII.GetBytes(u));
            bytes.Add(0x1B);
            bytes.Add(0x02);
            bytes.AddRange(Encoding.ASCII.GetBytes(p));
            bytes.Add(0x1B);
            bytes.Add(0x03);
            bytes.AddRange(Encoding.ASCII.GetBytes(o));
            bytes.Add(0x3F);
            bytes.Add(0x1C);
SendBytes(sp, bytes.ToArray());

static void SendBytes(SerialPort sp, byte[] bytes)
        {
            try
            {
                if (!sp.IsOpen)
                    sp.Open();
                sp.Write(bytes, 0, bytes.Length);

                Console.WriteLine("Bytes sent...");
            }
            catch (Exception ee)
            {
                Console.WriteLine(ee.Message);
            }
        }



这应该在3条磁道上写3条字符串,但是当我尝试从卡中读取数据时,它会返回无意义的信息. (设备发送回"WRITE OK",因此写入成功).



This should write 3 strings on the 3 tracks, but when I try to read the datas from the card it gives back meaningless informations. (the device sends back a "WRITE OK", so the writing was succesful)

推荐答案

没有实际硬件,很难说出问题出在哪里,但是快速浏览手册会发现它使用5位数据-由于小写的值不存在,因此小写的值将不起作用(PDF版本的第9-2页).
您是否尝试过数值?还是检查他们提供的测试程序做什么?
Without the actual hardware it is difficult to tell what the problem is, but a quick look at the manual suggests that it uses 5 bit data - so lowercase values are not going to work (Page 9-2 of the PDF version) as they don''t exist.
Have you tried numeric values? Or checking what the test program they supply does?


这篇关于磁卡读卡器无意义的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆