Writing of data to RFID tag

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

     

By using of BizTalk RFID additionally to asynchronous event processing the provided API allows one to deal synchronously with devices. More about this framework can be read here. Following example shows how to write a number of bytes to the tag.

 

public static void WriteData()

{

  try

  {

    // Shows how to connect to device by device name.(

    using (DeviceConnection connection = new DeviceConnection(m_Host, m_Device))

    {

       // After connecting the device has to be opened.

       connection.Open();

 

       TagReadEvent tagEvent = getTeagReadEvent

       new byte[] { 0x01, 0x02 },

       TagType.EpcClass1Gen2,

       new byte[] { 0x01, 0x02, 0x03, 0x04,
       0x01, 0x02, 0x03, 0x04 },

       "Antenna1");

 

       connection.WriteTagData(tagEvent.GetId(),
       tagEvent.GetData());

 

       connection.WriteTagData("Antenna1", tagEvent.GetId(),
        tagEvent.GetData(),

       null, null);

     }

}

catch (Exception ex)

{

   Console.WriteLine(ex.Message);

 }

}

 

First you have to is to create the instance of the TagReadEvent class. This object is defined by passCode (which is not relevant now), the tag identifier and tag data. The tag identifier is the second argument, which uniquely defines the tag to which the data will be written. Note that this tag should exist in the radio field, before calling the write operation.

The last argument is the array of bytes which will be written to the tag. The actual writing operation is performed by invoking of the method WriteTagData. The first argument specifies the source, mostly the antenna which will be used. Note that some DSPI provider do necessarily have to support writing by using of multiple sources. The other two arguments specify the tag identifier and the data respectively. The data can also be written by using of none generic way. This is when one defines the specific command which will be executed by provider. The more or less complete list of currently supported commands can be found here. Next example shows how to write the data to the tag by executing of WriteTagDataCommand.

 

public static void WriteTagDataCommand()

{

   // Opens the device manager proxy at the specified host.

   DeviceManagerProxy proxy = new DeviceManagerProxy(m_Host);

 

   //

   // Opens the device connection.

   using (DeviceConnection connection =
            new DeviceConnection(m_Host, m_Device))

   {

      connection.Open();

 

      // Creates the command which causes writting of
      // data to tag with specified id.

      WriteTagDataCommand rfidCmd =

      new WriteTagDataCommand(new byte[] { 0x01, 0x02 },

      new byte[] { 0x01, 0x02, 0x03, 0x04,
      0x01, 0x02, 0x03, 0x04 },

      new byte[] { 0x01, 0x02, 0x03, 0x04,
      0x05, 0x06, 0x07 });

 

      // This command enforses the provider to execute writting of data to the tag.

      Command cmd = proxy.ExecuteCommandForConnection(m_Device, 
      "Antenna1"
      connection.ConnectionId, rfidCmd);

   }

}


Posted Sep 19 2007, 05:45 PM by Damir Dobric
Filed under:

Comments

dany wrote re: Writing of data to RFID tag
on 03-07-2012 16:22

is this code is C# code?

daniel wrote re: Writing of data to RFID tag
on 03-21-2012 13:56

hello dear

does this code work for door lock system?

Jess wrote re: Writing of data to RFID tag
on 04-05-2012 18:44

can u give me the VB.net code of the above code??

thanks in advance!

developers.de is a .Net Community Blog powered by daenet GmbH.