/// <summary> /// 4个天线读卡, 读取EPC数据区以及TID数据区 /// </summary> /// <param name="clientConn">连接</param> private static void SendSynBaseInventoryEpcMsg(GClient clientConn, out bool isGetSuccess) { // 4个天线读卡, 读取EPC数据区以及TID数据区 MsgBaseInventoryEpc msgBaseInventoryEpc = new MsgBaseInventoryEpc { AntennaEnable = (eAntennaNo._1 | eAntennaNo._2 | eAntennaNo._3 | eAntennaNo._4), InventoryMode = (byte)eInventoryMode.Single, // tid参数 ReadTid = new ParamEpcReadTid() }; msgBaseInventoryEpc.ReadTid.Mode = (byte)eParamTidMode.Auto; msgBaseInventoryEpc.ReadTid.Len = 6; clientConn.SendSynMsg(msgBaseInventoryEpc); if (0 == msgBaseInventoryEpc.RtCode) { isGetSuccess = true; LogUtils.Debug("Inventory epc successful."); } else { LogUtils.Debug("Inventory epc error."); isGetSuccess = false; } }
public static void TestRFID(object sender, ElapsedEventArgs elapsed) { GClient clientConn = new GClient(); //COM1 主柜rfid串口 //COM4 副柜rfid串口 if (clientConn.OpenSerial("COM1:115200", 3000, out eConnectionAttemptEventStatusType status)) //if (clientConn.OpenTcp("192.168.1.168:8160", 3000, out status)) { // 订阅标签上报事件 clientConn.OnEncapedTagEpcLog += new delegateEncapedTagEpcLog(OnEncapedTagEpcLog); clientConn.OnEncapedTagEpcOver += new delegateEncapedTagEpcOver(OnEncapedTagEpcOver); // 停止指令,空闲态 MsgBaseStop msgBaseStop = new MsgBaseStop(); clientConn.SendSynMsg(msgBaseStop); if (0 == msgBaseStop.RtCode) { LogUtils.Debug("Stop successful."); } else { LogUtils.Debug("Stop error."); } // 功率配置, 将4个天线功率都设置为30dBm. MsgBaseSetPower msgBaseSetPower = new MsgBaseSetPower { DicPower = new Dictionary <byte, byte>() { { 1, 30 }, { 2, 30 }, { 3, 30 }, { 4, 30 } } }; clientConn.SendSynMsg(msgBaseSetPower); if (0 == msgBaseSetPower.RtCode) { LogUtils.Debug("Power configuration successful."); } else { LogUtils.Debug("Power configuration error."); } LogUtils.Debug("Enter any character to start reading the tag."); Console.ReadKey(); // 4个天线读卡, 读取EPC数据区以及TID数据区 MsgBaseInventoryEpc msgBaseInventoryEpc = new MsgBaseInventoryEpc { AntennaEnable = (uint)(eAntennaNo._1 | eAntennaNo._2 | eAntennaNo._3 | eAntennaNo._4), InventoryMode = (byte)eInventoryMode.Inventory, // tid参数 ReadTid = new ParamEpcReadTid() }; msgBaseInventoryEpc.ReadTid.Mode = (byte)eParamTidMode.Auto; msgBaseInventoryEpc.ReadTid.Len = 6; clientConn.SendSynMsg(msgBaseInventoryEpc); if (0 == msgBaseInventoryEpc.RtCode) { LogUtils.Debug("Inventory epc successful."); } else { LogUtils.Debug("Inventory epc error."); } Console.ReadKey(); // 停止读卡,空闲态 clientConn.SendSynMsg(msgBaseStop); if (0 == msgBaseStop.RtCode) { LogUtils.Debug("Stop successful."); } else { LogUtils.Debug("Stop error."); } } else { LogUtils.Debug("Connect failure."); } Console.ReadKey(); clientConn.Close(); }