public WriteParms( ) { WriteRandomParms tempRandom = new WriteRandomParms(); WriteSequentialParms tempSequential = new WriteSequentialParms(); UInt32 max = 0; // arbitrarily default to one of the lengths max = tempSequential.length; if (tempRandom.length > max) { max = tempRandom.length; } this.length_ = this.length_ + max; }
public QTParms( ) { WriteRandomParms tempRandom = new WriteRandomParms(); WriteSequentialParms tempSequential = new WriteSequentialParms(); ReadCmdParms tempRead = new ReadCmdParms(); UInt32 max = 0; // arbitrarily default to one of the lengths max = tempSequential.length; // account for randomParms being larger if (tempRandom.length > max) { max = tempRandom.length; } // account for readParms being larger if (tempRead.length > max) { max = tempRead.length; } this.length_ = this.length_ + max; }
private void btnActivateKey_Click(object sender, EventArgs e) { byte flag = 0, selectOpsFlag = 0, postMatchFlag = 0; bool writeParamActivateKey0Flag = false, writeParamActivateKey1Flag = false; if ((textBoxInserKey0.Text.Length / 2) < 16) { MessageDisplay("Please enter 16 bytes hexadecimal value for Key0", "Key0 Information", MessageBoxIcon.Error); } else if ((textBoxInserKey1.Text.Length / 2) < 16) { MessageDisplay("Please enter 16 bytes hexadecimal value for Key1", "Key1 Information", MessageBoxIcon.Error); } else if (CheckKeyType(textBoxInserKey0.Text) != true) { MessageDisplay("Key0 is invalid hexadecimal value", "Key0 Information", MessageBoxIcon.Error); } else if (CheckKeyType(textBoxInserKey1.Text) != true) { MessageDisplay("Key1 is invalid hexadecimal value", "Key1 Information", MessageBoxIcon.Error); } else { selectOpsFlag = (chkPerformSelectOps.Checked == true) ? (byte)1 : (byte)0; postMatchFlag = (chkPerformPostMatch.Checked == true) ? (byte)1 : (byte)0; //Write key0 trigger value to activate the key0 WriteParms paramActivateKey = new WriteParms(); WriteSequentialParms writeParamActivateKey = new WriteSequentialParms(); writeParamActivateKey.bank = MemoryBank.USER; writeParamActivateKey.count = 1; writeParamActivateKey.offset = 200; //C8 : Key0 header writeParamActivateKey.pData = new ushort[1]; writeParamActivateKey.pData[0] = 0xE200; paramActivateKey.accessPassword = Convert.ToUInt32(TEXTBOX_TagAccessAccessPassword.Text, 16); paramActivateKey.writeParms = writeParamActivateKey; paramActivateKey.writeType = WriteType.SEQUENTIAL; paramActivateKey.common.callback = new rfid.CallbackDelegate(this.m_reader.MyCallback); paramActivateKey.common.strcTagFlag.RetryCount = retryCount; paramActivateKey.common.strcTagFlag.SelectOpsFlag = selectOpsFlag; paramActivateKey.common.strcTagFlag.PostMatchFlag = postMatchFlag; paramActivateKey.common.OpMode = RadioOperationMode.NONCONTINUOUS; Array.Clear(paramActivateKey.common.bufMTIA, 0, paramActivateKey.common.bufMTIA.Length); paramActivateKey.common.tagFlag = false; writeParamActivateKey0Flag = true; if (Result.OK != LakeChabotReader.MANAGED_ACCESS.API_l8K6CTagWrite(paramActivateKey, flag)) { writeParamActivateKey0Flag = false; MessageDisplay("Activate the Key0 command failed.", "Key0 Information", MessageBoxIcon.Error); } else if (paramActivateKey.common.tagFlag != true) { writeParamActivateKey0Flag = false; MessageDisplay("No Tag", "Key0 Information", MessageBoxIcon.Warning); } else if (paramActivateKey.common.bufMTIA[tagErrorCode] != 0x00) { writeParamActivateKey0Flag = false; MessageDisplay("Tag Error Code : 0x" + paramActivateKey.common.bufMTIA[19].ToString("X2"), "Key0 Information", MessageBoxIcon.Error); } else if (paramActivateKey.common.bufMTIA[moduleErrorCode1] != 0x00 || paramActivateKey.common.bufMTIA[moduleErrorCode2] != 0x00) { writeParamActivateKey0Flag = false; MessageDisplay("Module Error Code : 0x" + paramActivateKey.common.bufMTIA[moduleErrorCode1].ToString("X2") + paramActivateKey.common.bufMTIA[moduleErrorCode2].ToString("X2"), "Key0 Information", MessageBoxIcon.Error); } //Write key1 trigger value to activate the key1 writeParamActivateKey.bank = MemoryBank.USER; writeParamActivateKey.count = 1; writeParamActivateKey.offset = 216; //D8 : Key1 header writeParamActivateKey.pData = new ushort[1]; writeParamActivateKey.pData[0] = 0xE200; paramActivateKey.accessPassword = Convert.ToUInt32(TEXTBOX_TagAccessAccessPassword.Text, 16); paramActivateKey.writeParms = writeParamActivateKey; paramActivateKey.writeType = WriteType.SEQUENTIAL; paramActivateKey.common.callback = new rfid.CallbackDelegate(this.m_reader.MyCallback); paramActivateKey.common.strcTagFlag.RetryCount = retryCount; paramActivateKey.common.strcTagFlag.SelectOpsFlag = selectOpsFlag; paramActivateKey.common.strcTagFlag.PostMatchFlag = postMatchFlag; paramActivateKey.common.OpMode = RadioOperationMode.NONCONTINUOUS; Array.Clear(paramActivateKey.common.bufMTIA, 0, paramActivateKey.common.bufMTIA.Length); paramActivateKey.common.tagFlag = false; writeParamActivateKey1Flag = true; if (Result.OK != LakeChabotReader.MANAGED_ACCESS.API_l8K6CTagWrite(paramActivateKey, flag)) { writeParamActivateKey1Flag = false; MessageDisplay("Activate the Key1 command failed.", "Key1 Information", MessageBoxIcon.Error); } else if (paramActivateKey.common.tagFlag != true) { writeParamActivateKey1Flag = false; MessageDisplay("No Tag", "Key1 Information", MessageBoxIcon.Warning); } else if (paramActivateKey.common.bufMTIA[tagErrorCode] != 0x00) { writeParamActivateKey1Flag = false; MessageDisplay("Tag Error Code : 0x" + paramActivateKey.common.bufMTIA[19].ToString("X2"), "Key1 Information", MessageBoxIcon.Error); } else if (paramActivateKey.common.bufMTIA[moduleErrorCode1] != 0x00 || paramActivateKey.common.bufMTIA[moduleErrorCode2] != 0x00) { writeParamActivateKey1Flag = false; MessageDisplay("Module Error Code : 0x" + paramActivateKey.common.bufMTIA[moduleErrorCode1].ToString("X2") + paramActivateKey.common.bufMTIA[moduleErrorCode2].ToString("X2"), "Key1 Information", MessageBoxIcon.Error); } if (writeParamActivateKey0Flag != true || writeParamActivateKey1Flag != true) { textBoxEPC.Text = ""; textBoxInserKey0.Text = ""; textBoxInserKey1.Text = ""; btnInsertKey.Enabled = false; btnActivateKey.Enabled = false; MessageDisplay("Activate Keys Fail", "Keys Information", MessageBoxIcon.Error); } else { MessageDisplay("Activate Keys Success", "Keys Information", MessageBoxIcon.Information); } } }
private void btnInsertKey_Click(object sender, EventArgs e) { int i, key0Length, key1Length; byte flag = 0, selectOpsFlag = 0, postMatchFlag = 0; bool writeKey0Flag = false, writeKey1Flag = false; if ((textBoxInserKey0.Text.Length / 2) < 16) { MessageDisplay("Please enter 16 bytes hexadecimal value for Key0", "Key0 Information", MessageBoxIcon.Error); } else if ((textBoxInserKey1.Text.Length / 2) < 16) { MessageDisplay("Please enter 16 bytes hexadecimal value for Key1", "Key1 Information", MessageBoxIcon.Error); } else if (CheckKeyType(textBoxInserKey0.Text) != true) { MessageDisplay("Key0 is invalid hexadecimal value", "Key0 Information", MessageBoxIcon.Error); } else if (CheckKeyType(textBoxInserKey1.Text) != true) { MessageDisplay("Key1 is invalid hexadecimal value", "Key1 Information", MessageBoxIcon.Error); } else { selectOpsFlag = (chkPerformSelectOps.Checked == true) ? (byte)1 : (byte)0; postMatchFlag = (chkPerformPostMatch.Checked == true) ? (byte)1 : (byte)0; key0Length = textBoxInserKey0.Text.Length; short[] key0 = new short[key0Length / 4]; for (i = 0; i < key0Length; i += 4) { key0[i / 4] = Convert.ToInt16(textBoxInserKey0.Text.Substring(i, 4), 16); } //Write key0 value WriteParms paramKey0 = new WriteParms(); WriteSequentialParms writeparamKey0 = new WriteSequentialParms(); writeparamKey0.bank = MemoryBank.USER; writeparamKey0.count = 8; writeparamKey0.offset = 192; //C0 writeparamKey0.pData = new ushort[8]; writeparamKey0.pData[0] = (ushort)key0[0]; writeparamKey0.pData[1] = (ushort)key0[1]; writeparamKey0.pData[2] = (ushort)key0[2]; writeparamKey0.pData[3] = (ushort)key0[3]; writeparamKey0.pData[4] = (ushort)key0[4]; writeparamKey0.pData[5] = (ushort)key0[5]; writeparamKey0.pData[6] = (ushort)key0[6]; writeparamKey0.pData[7] = (ushort)key0[7]; paramKey0.accessPassword = Convert.ToUInt32(TEXTBOX_TagAccessAccessPassword.Text, 16); paramKey0.writeParms = writeparamKey0; paramKey0.writeType = WriteType.SEQUENTIAL; paramKey0.common.callback = new rfid.CallbackDelegate(this.m_reader.MyCallback); paramKey0.common.strcTagFlag.RetryCount = retryCount; paramKey0.common.strcTagFlag.SelectOpsFlag = selectOpsFlag; paramKey0.common.strcTagFlag.PostMatchFlag = postMatchFlag; paramKey0.common.OpMode = RadioOperationMode.NONCONTINUOUS; Array.Clear(paramKey0.common.bufMTIA, 0, paramKey0.common.bufMTIA.Length); paramKey0.common.tagFlag = false; writeKey0Flag = true; if (Result.OK != LakeChabotReader.MANAGED_ACCESS.API_l8K6CTagWrite(paramKey0, flag)) { writeKey0Flag = false; MessageDisplay("Write Key0 data command failed", "Key0 Information", MessageBoxIcon.Error); } else if (paramKey0.common.tagFlag != true) { writeKey0Flag = false; MessageDisplay("No Tag", "Key0 Information", MessageBoxIcon.Warning); } else if (paramKey0.common.bufMTIA[tagErrorCode] != 0x00) { writeKey0Flag = false; MessageDisplay("Tag Error Code : 0x" + paramKey0.common.bufMTIA[19].ToString("X2"), "Key0 Information", MessageBoxIcon.Error); } else if (paramKey0.common.bufMTIA[moduleErrorCode1] != 0x00 || paramKey0.common.bufMTIA[moduleErrorCode2] != 0x00) { writeKey0Flag = false; MessageDisplay("Module Error Code : 0x" + paramKey0.common.bufMTIA[moduleErrorCode1].ToString("X2") + paramKey0.common.bufMTIA[moduleErrorCode2].ToString("X2"), "Key0 Information", MessageBoxIcon.Error); } key1Length = textBoxInserKey1.Text.Length; short[] key1 = new short[key1Length / 4]; for (i = 0; i < key0Length; i += 4) { key1[i / 4] = Convert.ToInt16(textBoxInserKey1.Text.Substring(i, 4), 16); } //Write key1 value WriteParms paramKey1 = new WriteParms(); WriteSequentialParms writeparamKey1 = new WriteSequentialParms(); writeparamKey1.bank = MemoryBank.USER; writeparamKey1.count = 8; writeparamKey1.offset = 208; //D0 writeparamKey1.pData = new ushort[8]; writeparamKey1.pData[0] = (ushort)key1[0]; writeparamKey1.pData[1] = (ushort)key1[1]; writeparamKey1.pData[2] = (ushort)key1[2]; writeparamKey1.pData[3] = (ushort)key1[3]; writeparamKey1.pData[4] = (ushort)key1[4]; writeparamKey1.pData[5] = (ushort)key1[5]; writeparamKey1.pData[6] = (ushort)key1[6]; writeparamKey1.pData[7] = (ushort)key1[7]; paramKey1.accessPassword = Convert.ToUInt32(TEXTBOX_TagAccessAccessPassword.Text, 16); paramKey1.writeParms = writeparamKey1; paramKey1.writeType = WriteType.SEQUENTIAL; paramKey1.common.callback = new rfid.CallbackDelegate(this.m_reader.MyCallback); paramKey1.common.strcTagFlag.RetryCount = retryCount; paramKey1.common.strcTagFlag.SelectOpsFlag = selectOpsFlag; paramKey1.common.strcTagFlag.PostMatchFlag = postMatchFlag; paramKey1.common.OpMode = RadioOperationMode.NONCONTINUOUS; Array.Clear(paramKey1.common.bufMTIA, 0, paramKey1.common.bufMTIA.Length); paramKey1.common.tagFlag = false; writeKey1Flag = true; if (Result.OK != LakeChabotReader.MANAGED_ACCESS.API_l8K6CTagWrite(paramKey1, flag)) { writeKey1Flag = false; MessageDisplay("Write Key1 data command failed", "Key1 Information", MessageBoxIcon.Error); } else if (paramKey1.common.tagFlag != true) { writeKey1Flag = false; MessageDisplay("No Tag", "Key1 Information", MessageBoxIcon.Warning); } else if (paramKey1.common.bufMTIA[tagErrorCode] != 0x00) { writeKey1Flag = false; MessageDisplay("Tag Error Code : 0x" + paramKey1.common.bufMTIA[19].ToString("X2"), "Key1 Information", MessageBoxIcon.Error); } else if (paramKey1.common.bufMTIA[moduleErrorCode1] != 0x00 || paramKey1.common.bufMTIA[moduleErrorCode2] != 0x00) { writeKey1Flag = false; MessageDisplay("Module Error Code : 0x" + paramKey1.common.bufMTIA[moduleErrorCode1].ToString("X2") + paramKey1.common.bufMTIA[moduleErrorCode2].ToString("X2"), "Key1 Information", MessageBoxIcon.Error); } if (writeKey0Flag != true || writeKey1Flag != true) { textBoxEPC.Text = ""; textBoxInserKey0.Text = ""; textBoxInserKey1.Text = ""; btnInsertKey.Enabled = false; btnActivateKey.Enabled = false; MessageDisplay("Insert Keys Fail", "Keys Information", MessageBoxIcon.Error); } else { MessageDisplay("Insert Keys Success", "Keys Information", MessageBoxIcon.Information); } } }
public void AccessThreadProc() { rfid.Constants.Result result = rfid.Constants.Result.NOT_INITIALIZED; byte flags = 0; StartEvent.WaitOne(); switch (_tagAccessData.type) { case TagAccessType.Read: { ReadParms parameters = new ReadParms(); BuildParams_ReadCmd(ref parameters.readCmdParms, ref parameters.accessPassword); parameters.common.callback = new rfid.CallbackDelegate(this._reader.MyCallback); //clark 2011.4.25 Set tag access flag to inventory structure parameters.common.strcTagFlag.RetryCount = _tagAccessData.strcTagFlag.RetryCount; parameters.common.strcTagFlag.PostMatchFlag = _tagAccessData.strcTagFlag.PostMatchFlag; parameters.common.strcTagFlag.SelectOpsFlag = _tagAccessData.strcTagFlag.SelectOpsFlag; parameters.common.OpMode = RadioOperationMode.NONCONTINUOUS; result = LakeChabotReader.MANAGED_ACCESS.API_l8K6CTagRead(parameters, flags); } break; //Add LargeRead case TagAccessType.LargeRead: { ReadParms parameters = new ReadParms(); BuildParams_ReadCmd(ref parameters.readCmdParms, ref parameters.accessPassword); parameters.common.callback = new rfid.CallbackDelegate(this._reader.MyCallback); //clark 2011.4.25 Set tag access flag to inventory structure parameters.common.strcTagFlag.RetryCount = _tagAccessData.strcTagFlag.RetryCount; parameters.common.strcTagFlag.PostMatchFlag = _tagAccessData.strcTagFlag.PostMatchFlag; parameters.common.strcTagFlag.SelectOpsFlag = _tagAccessData.strcTagFlag.SelectOpsFlag; parameters.common.OpMode = RadioOperationMode.NONCONTINUOUS; parameters.readCmdParms.count = (byte)(_tagAccessReadSet.ReadWords);//籠筁count //parameters.readCmdParms.offset = 0; //□add loop for (int ccnt = 0; ccnt < (_tagAccessReadSet.TotalReadWords /_tagAccessReadSet.ReadWords); ccnt++) // TotalReadWords/ReadWords { UInt16 choff = (UInt16)(_tagAccessReadSet.ReadWords);// readwords result = LakeChabotReader.MANAGED_ACCESS.API_l8K6CTagRead(parameters, flags); parameters.readCmdParms.offset = (UInt16)(parameters.readCmdParms.offset + choff); if (Stop) break; } //◆add loop //result = LakeChabotReader.MANAGED_ACCESS.API_l8K6CTagRead(parameters, flags); } break; case TagAccessType.Write: { WriteParms parameters = new WriteParms(); WriteSequentialParms writeParameters = new WriteSequentialParms(); BuildParams_WriteCmd(ref writeParameters, ref parameters.accessPassword); parameters.writeParms = writeParameters; parameters.writeType = WriteType.SEQUENTIAL; parameters.common.callback = new rfid.CallbackDelegate(this._reader.MyCallback); //clark 2011.4.25 Set tag access flag to inventory structure parameters.common.strcTagFlag.RetryCount = _tagAccessData.strcTagFlag.RetryCount; parameters.common.strcTagFlag.PostMatchFlag = _tagAccessData.strcTagFlag.PostMatchFlag; parameters.common.strcTagFlag.SelectOpsFlag = _tagAccessData.strcTagFlag.SelectOpsFlag; parameters.common.OpMode = RadioOperationMode.NONCONTINUOUS; result = LakeChabotReader.MANAGED_ACCESS.API_l8K6CTagWrite(parameters, flags); } break; case TagAccessType.BlockWrite: { BlockWriteParms parameters = new BlockWriteParms(); BuildParams_BlockWriteCmd(ref parameters.blockWriteCmdParms, ref parameters.accessPassword); parameters.common.callback = new rfid.CallbackDelegate(this._reader.MyCallback); //clark 2011.4.25 Set tag access flag to inventory structure parameters.common.strcTagFlag.RetryCount = _tagAccessData.strcTagFlag.RetryCount; parameters.common.strcTagFlag.PostMatchFlag = _tagAccessData.strcTagFlag.PostMatchFlag; parameters.common.strcTagFlag.SelectOpsFlag = _tagAccessData.strcTagFlag.SelectOpsFlag; parameters.common.OpMode = RadioOperationMode.NONCONTINUOUS; result = LakeChabotReader.MANAGED_ACCESS.API_l8K6CTagBlockWrite(parameters, flags); } break; case TagAccessType.BlockErase: { BlockEraseParms parameters = new BlockEraseParms(); BuildParams_BlockEraseCmd(ref parameters.blockEraseCmdParms, ref parameters.accessPassword); parameters.common.callback = new rfid.CallbackDelegate(this._reader.MyCallback); //clark 2011.4.25 Set tag access flag to inventory structure parameters.common.strcTagFlag.RetryCount = _tagAccessData.strcTagFlag.RetryCount; parameters.common.strcTagFlag.PostMatchFlag = _tagAccessData.strcTagFlag.PostMatchFlag; parameters.common.strcTagFlag.SelectOpsFlag = _tagAccessData.strcTagFlag.SelectOpsFlag; parameters.common.OpMode = RadioOperationMode.NONCONTINUOUS; result = LakeChabotReader.MANAGED_ACCESS.API_l8K6CTagBlockErase(parameters, flags); } break; case TagAccessType.Lock: { LockParms parameters = new LockParms(); BuildParams_LockCmd(ref parameters.lockCmdParms, ref parameters.accessPassword); parameters.common.callback = new rfid.CallbackDelegate(this._reader.MyCallback); //clark 2011.4.25 Set tag access flag to inventory structure parameters.common.strcTagFlag.RetryCount = _tagAccessData.strcTagFlag.RetryCount; parameters.common.strcTagFlag.PostMatchFlag = _tagAccessData.strcTagFlag.PostMatchFlag; parameters.common.strcTagFlag.SelectOpsFlag = _tagAccessData.strcTagFlag.SelectOpsFlag; parameters.common.OpMode = RadioOperationMode.NONCONTINUOUS; result = LakeChabotReader.MANAGED_ACCESS.API_l8K6CTagLock(parameters, flags); } break; case TagAccessType.Kill: { KillParms parameters = new KillParms(); BuildParams_KillCmd(ref parameters.killCmdParms, ref parameters.accessPassword); parameters.common.callback = new rfid.CallbackDelegate(this._reader.MyCallback); //clark 2011.4.25 Set tag access flag to inventory structure parameters.common.strcTagFlag.RetryCount = _tagAccessData.strcTagFlag.RetryCount; parameters.common.strcTagFlag.PostMatchFlag = _tagAccessData.strcTagFlag.PostMatchFlag; parameters.common.strcTagFlag.SelectOpsFlag = _tagAccessData.strcTagFlag.SelectOpsFlag; parameters.common.OpMode = RadioOperationMode.NONCONTINUOUS; result = LakeChabotReader.MANAGED_ACCESS.API_l8K6CTagKill(parameters, flags); } break; case TagAccessType.QT_None: case TagAccessType.QT_Read: case TagAccessType.QT_Write: { QTParms parameters = new QTParms(); BuildParams_QT(ref parameters, ref parameters.accessPassword); parameters.common.callback = new rfid.CallbackDelegate(this._reader.MyCallback); //clark 2011.4.25 Set tag access flag to inventory structure parameters.common.strcTagFlag.RetryCount = _tagAccessData.strcTagFlag.RetryCount; parameters.common.strcTagFlag.PostMatchFlag = _tagAccessData.strcTagFlag.PostMatchFlag; parameters.common.strcTagFlag.SelectOpsFlag = _tagAccessData.strcTagFlag.SelectOpsFlag; parameters.common.OpMode = RadioOperationMode.NONCONTINUOUS; result = LakeChabotReader.MANAGED_ACCESS.API_l8K6CTagQT(parameters, flags); } break; default: System.Diagnostics.Debug.Assert(false, "Tag Acces Type"); break; } }
private void BuildParams_QT(ref QTParms parameters, ref UInt32 accessPassword) { parameters = new QTParms(); switch (_tagAccessData.type) { case TagAccessType.QT_Read: ReadCmdParms readParameters = new ReadCmdParms(); BuildParams_ReadCmd(ref readParameters, ref parameters.accessPassword); parameters.accessParms = readParameters; parameters.optCmdType = OptType.OPT_READ; break; case TagAccessType.QT_Write: WriteSequentialParms writeParameters = new WriteSequentialParms(); BuildParams_WriteCmd(ref writeParameters, ref parameters.accessPassword); parameters.accessParms = writeParameters; parameters.optCmdType = OptType.OPT_WRITE_TYPE_SEQUENTIAL; break; case TagAccessType.QT_None: parameters.optCmdType = OptType.OPT_NONE; break; default: System.Diagnostics.Debug.Assert(false, "Tag Acces Type"); break; } parameters.qtCmdParms.qtReadWrite = _tagAccessData.qtReadWrite; parameters.qtCmdParms.qtPersistence = _tagAccessData.qtPersistence; parameters.qtCmdParms.qtShortRange = _tagAccessData.qtShortRange; parameters.qtCmdParms.qtMemoryMap = _tagAccessData.qtMemoryMap; accessPassword = _tagAccessData.accessPassword; }
private void BuildParams_WriteCmd(ref WriteSequentialParms parameters, ref UInt32 accessPassword) { parameters.bank = _tagAccessData.bank; parameters.offset = _tagAccessData.offset; parameters.pData = new ushort[2]; parameters.pData[0] = _tagAccessData.value1; parameters.pData[1] = _tagAccessData.value2; parameters.count = _tagAccessData.count; accessPassword = _tagAccessData.accessPassword; }