Discussion:
[ltk-d] LLRP configure antenna in C
Raul Rosetto Munoz
2012-01-25 11:36:36 UTC
Permalink
*Hello all.*
*
*
*That is my first e-mail for the list, I hope that some one can help me!*
*
*
*I'm creating a application in C that will listen all tags that pass in
Speedway revolution.*
*
*
*I'm started from the Exemple 1 that comming with the Library written in C,*
*
*
*When I addROSpec I can configure all things that is at the XML below with
the C structs.*

<ADD_ROSPEC MessageID='201'>
<ROSpec>
<ROSpecID>123</ROSpecID>
<Priority>0</Priority>
<CurrentState>Disabled</CurrentState>
<ROBoundarySpec>
<ROSpecStartTrigger>
<ROSpecStartTriggerType>Null</ROSpecStartTriggerType>
</ROSpecStartTrigger>
<ROSpecStopTrigger>
<ROSpecStopTriggerType>Null</ROSpecStopTriggerType>
<DurationTriggerValue>0</DurationTriggerValue>
</ROSpecStopTrigger>
</ROBoundarySpec>
<AISpec>
<AntennaIDs>0</AntennaIDs>
<AISpecStopTrigger>
<AISpecStopTriggerType>Duration</AISpecStopTriggerType>
<DurationTrigger>5000</DurationTrigger>
</AISpecStopTrigger>
<InventoryParameterSpec>
<InventoryParameterSpecID>1234</InventoryParameterSpecID>
<ProtocolID>EPCGlobalClass1Gen2</ProtocolID>
<AntennaConfiguration> //ver numero de antenas
<AntennaID>0</AntennaID>
<!-- we will over-write the transmit power in our code -->
<RFTransmitter>
<HopTableID>1</HopTableID>
<ChannelIndex>1</ChannelIndex>
<TransmitPower>1</TransmitPower>
</RFTransmitter>
<C1G2InventoryCommand>
<TagInventoryStateAware>false</TagInventoryStateAware>
<C1G2RFControl>
<!--Set mode to Gen2 DRM AutoSet Mode Tari is ignored -->
<ModeIndex>1000</ModeIndex>
<Tari>0</Tari>
</C1G2RFControl>
<C1G2SingulationControl>
<!--Will use session 2 -->
<Session>2</Session>
<TagPopulation>32</TagPopulation>
<TagTransitTime>0</TagTransitTime>
</C1G2SingulationControl>
<Impinj:ImpinjInventorySearchMode
xmlns="http://developer.impinj.com/ltk/schema/encoding/xml/1.6">
<!--Will use Dual-target-->
<InventorySearchMode>Dual_Target</InventorySearchMode>
</Impinj:ImpinjInventorySearchMode>
<!--Enable Low Duty Cycle when no tags are seen for 10 seconds. Check
antennas every 200 msec -->
<Impinj:ImpinjLowDutyCycle
xmlns="http://developer.impinj.com/ltk/schema/encoding/xml/1.6">
<LowDutyCycleMode>Enabled</LowDutyCycleMode>
<EmptyFieldTimeout>10000</EmptyFieldTimeout>
<FieldPingInterval>200</FieldPingInterval>
</Impinj:ImpinjLowDutyCycle>
</C1G2InventoryCommand>
</AntennaConfiguration>
</InventoryParameterSpec>
</AISpec>
<ResetToFactoryDefault>false</ResetToFactoryDefault>
<ROReportSpec>
<ROReportTrigger>Upon_N_Tags_Or_End_Of_ROSpec</ROReportTrigger>
<N>0</N>
<TagReportContentSelector>
<EnableROSpecID>0</EnableROSpecID>
*<EnableSpecIndex>1</EnableSpecIndex>
<EnableInventoryParameterSpecID>0</EnableInventoryParameterSpecID>
*<EnableAntennaID>1</EnableAntennaID>
<EnableChannelIndex>0</EnableChannelIndex>
<EnablePeakRSSI>0</EnablePeakRSSI>
*<EnableFirstSeenTimestamp>1</EnableFirstSeenTimestamp>
*<EnableLastSeenTimestamp>1</EnableLastSeenTimestamp>
*<EnableTagSeenCount>1</EnableTagSeenCount>
<EnableAccessSpecID>0</EnableAccessSpecID>
</TagReportContentSelector>
</ROReportSpec>
</ROSpec>
</ADD_ROSPEC>

*My first problem is how to set different configuration between antennas, I
saw to many examplos in C++ or C# that can do it easily, but I have never
seen some example in C.*
*
*
*In this example you can see in C++ the guy configure 4 times differents
antennas.*
*
http://learn.impinj.com/2010/12/setting-inventory-search-mode-with-java.html
*<http://learn.impinj.com/2010/12/setting-inventory-search-mode-with-java.html>

// Create a new inventory parameter
InventoryParameterSpec inventoryParam =
new InventoryParameterSpec();
// We're reading Gen2 tags.
inventoryParam.setProtocolID
(new AirProtocols(AirProtocols.EPCGlobalClass1Gen2));
inventoryParam.setInventoryParameterSpecID
(new UnsignedShort(1));

// Create a custom parameter (Inventory Search Mode)
Custom searchMode = new Custom();
BytesToEnd_HEX data = new BytesToEnd_HEX();
// Set the data to 0x0001 (Single target)
// Dual target = 0x0002
data.add(new SignedByte(0));
data.add(new SignedByte(1));
// 25882 is the vendor ID for Impinj
searchMode.setVendorIdentifier(new UnsignedInteger(25882));
// Parameter 23 = ImpinjInventorySearchType
searchMode.setParameterSubtype(new UnsignedInteger(23));
searchMode.setData(data);

// Set the session to Session 2
// Session is a standard LLRP setting
C1G2InventoryCommand invCmd = new C1G2InventoryCommand();
invCmd.setTagInventoryStateAware(new Bit(0));
C1G2SingulationControl c1g2SingCtrl = new C1G2SingulationControl();
TwoBitField session = new TwoBitField();
session.clear(0);
session.set(1);
c1g2SingCtrl.setSession(session);
// Tag population
c1g2SingCtrl.setTagPopulation(new UnsignedShort(32));
// Tag transit time
c1g2SingCtrl.setTagTransitTime(new UnsignedInteger(0));
invCmd.setC1G2SingulationControl(c1g2SingCtrl);
// Add our custom setting to the C1G2InventoryCommand
invCmd.addToCustomList(searchMode);

// Apply these settings to all four antennas
for (int i=1; i<=4; i++)
{
AntennaConfiguration antennaConfig = new AntennaConfiguration();
antennaConfig.setAntennaID(new UnsignedShort(i));
antennaConfig.addToAirProtocolInventoryCommandSettingsList(invCmd);
inventoryParam.addToAntennaConfigurationList(antennaConfig);
}

// Add the inventory parameters to the AISpec
aispec.addToInventoryParameterSpecList(inventoryParam);
// Add the AISpec to the ROSpec
roSpec.addToSpecParameterList(aispec);

*and in the java example you can see a 4 antennas configurations:*

<?xml version="1.0" encoding="UTF-8"?>
<llrp:ADD_ROSPEC xmlns:llrp="
http://www.llrp.org/ltk/schema/core/encoding/xml/1.0"
Version="1" MessageID="0">
<llrp:ROSpec>
<llrp:ROSpecID>123</llrp:ROSpecID>
<llrp:Priority>0</llrp:Priority>
<llrp:CurrentState>Disabled</llrp:CurrentState>
<llrp:ROBoundarySpec>
<llrp:ROSpecStartTrigger>
<llrp:ROSpecStartTriggerType>Null</llrp:ROSpecStartTriggerType>
</llrp:ROSpecStartTrigger>
<llrp:ROSpecStopTrigger>
<llrp:ROSpecStopTriggerType>Null</llrp:ROSpecStopTriggerType>
<llrp:DurationTriggerValue>0</llrp:DurationTriggerValue>
</llrp:ROSpecStopTrigger>
</llrp:ROBoundarySpec>
<llrp:AISpec>
<llrp:AntennaIDs>0</llrp:AntennaIDs>
<llrp:AISpecStopTrigger>
<llrp:AISpecStopTriggerType>Null</llrp:AISpecStopTriggerType>
<llrp:DurationTrigger>0</llrp:DurationTrigger>
</llrp:AISpecStopTrigger>
<llrp:InventoryParameterSpec>
<llrp:InventoryParameterSpecID>1</llrp:InventoryParameterSpecID>
<llrp:ProtocolID>EPCGlobalClass1Gen2</llrp:ProtocolID>
<llrp:AntennaConfiguration>
<llrp:AntennaID>1</llrp:AntennaID>
<llrp:C1G2InventoryCommand>
<llrp:TagInventoryStateAware>0</llrp:TagInventoryStateAware>
<llrp:C1G2SingulationControl>
<llrp:Session>2</llrp:Session>
<llrp:TagPopulation>32</llrp:TagPopulation>
<llrp:TagTransitTime>0</llrp:TagTransitTime>
</llrp:C1G2SingulationControl>
<llrp:Custom>
<llrp:VendorIdentifier>25882</llrp:VendorIdentifier>
<llrp:ParameterSubtype>23</llrp:ParameterSubtype>
<llrp:Data>0001</llrp:Data>
</llrp:Custom>
</llrp:C1G2InventoryCommand>
</llrp:AntennaConfiguration>
<llrp:AntennaConfiguration>
<llrp:AntennaID>2</llrp:AntennaID>
<llrp:C1G2InventoryCommand>
<llrp:TagInventoryStateAware>0</llrp:TagInventoryStateAware>
<llrp:C1G2SingulationControl>
<llrp:Session>2</llrp:Session>
<llrp:TagPopulation>32</llrp:TagPopulation>
<llrp:TagTransitTime>0</llrp:TagTransitTime>
</llrp:C1G2SingulationControl>
<llrp:Custom>
<llrp:VendorIdentifier>25882</llrp:VendorIdentifier>
<llrp:ParameterSubtype>23</llrp:ParameterSubtype>
<llrp:Data>0001</llrp:Data>
</llrp:Custom>
</llrp:C1G2InventoryCommand>
</llrp:AntennaConfiguration>
<llrp:AntennaConfiguration>
<llrp:AntennaID>3</llrp:AntennaID>
<llrp:C1G2InventoryCommand>
<llrp:TagInventoryStateAware>0</llrp:TagInventoryStateAware>
<llrp:C1G2SingulationControl>
<llrp:Session>2</llrp:Session>
<llrp:TagPopulation>32</llrp:TagPopulation>
<llrp:TagTransitTime>0</llrp:TagTransitTime>
</llrp:C1G2SingulationControl>
<llrp:Custom>
<llrp:VendorIdentifier>25882</llrp:VendorIdentifier>
<llrp:ParameterSubtype>23</llrp:ParameterSubtype>
<llrp:Data>0001</llrp:Data>
</llrp:Custom>
</llrp:C1G2InventoryCommand>
</llrp:AntennaConfiguration>
<llrp:AntennaConfiguration>
<llrp:AntennaID>4</llrp:AntennaID>
<llrp:C1G2InventoryCommand>
<llrp:TagInventoryStateAware>0</llrp:TagInventoryStateAware>
<llrp:C1G2SingulationControl>
<llrp:Session>2</llrp:Session>
<llrp:TagPopulation>32</llrp:TagPopulation>
<llrp:TagTransitTime>0</llrp:TagTransitTime>
</llrp:C1G2SingulationControl>
<llrp:Custom>
<llrp:VendorIdentifier>25882</llrp:VendorIdentifier>
<llrp:ParameterSubtype>23</llrp:ParameterSubtype>
<llrp:Data>0001</llrp:Data>
</llrp:Custom>
</llrp:C1G2InventoryCommand>
</llrp:AntennaConfiguration>
</llrp:InventoryParameterSpec>
</llrp:AISpec>
<llrp:ROReportSpec>
<llrp:ROReportTrigger>Upon_N_Tags_Or_End_Of_ROSpec</
llrp:ROReportTrigger>
<llrp:N>1</llrp:N>
<llrp:TagReportContentSelector>
<llrp:EnableROSpecID>0</llrp:EnableROSpecID>
<llrp:EnableSpecIndex>0</llrp:EnableSpecIndex>
<llrp:EnableInventoryParameterSpecID>0</
llrp:EnableInventoryParameterSpecID>
<llrp:EnableAntennaID>0</llrp:EnableAntennaID>
<llrp:EnableChannelIndex>0</llrp:EnableChannelIndex>
<llrp:EnablePeakRSSI>0</llrp:EnablePeakRSSI>
<llrp:EnableFirstSeenTimestamp>0</llrp:EnableFirstSeenTimestamp>
<llrp:EnableLastSeenTimestamp>1</llrp:EnableLastSeenTimestamp>
<llrp:EnableTagSeenCount>0</llrp:EnableTagSeenCount>
<llrp:EnableAccessSpecID>0</llrp:EnableAccessSpecID>
</llrp:TagReportContentSelector>
</llrp:ROReportSpec>
</llrp:ROSpec>
</llrp:ADD_ROSPEC>

*In my example below you can see that all structs are linked at the dad
structs, *
*
*
*The real question is how to link more than one Antenna configurations,
more than one AntennaID?*

int addROSpec (void) { LLRP_tSROSpecStartTrigger ROSpecStartTrigger = {
.hdr.elementHdr.pType = &LLRP_tdROSpecStartTrigger,
.eROSpecStartTriggerType = LLRP_ROSpecStartTriggerType_Null, };
LLRP_tSROSpecStopTrigger ROSpecStopTrigger = { .hdr.elementHdr.pType =
&LLRP_tdROSpecStopTrigger, .eROSpecStopTriggerType =
LLRP_ROSpecStopTriggerType_Null, .DurationTriggerValue = 0 /* n/a */ };
LLRP_tSROBoundarySpec ROBoundarySpec = { .hdr.elementHdr.pType =
&LLRP_tdROBoundarySpec, .pROSpecStartTrigger = &ROSpecStartTrigger,
.pROSpecStopTrigger = &ROSpecStopTrigger, }; llrp_u16_t AntennaIDs_n[1] = {
1 , 2 , 3 , 4 }; /* All */ LLRP_tSAISpecStopTrigger AISpecStopTrigger = {
.hdr.elementHdr.pType = &LLRP_tdAISpecStopTrigger, .eAISpecStopTriggerType
= LLRP_AISpecStopTriggerType_Null, .DurationTrigger = 0, };
LLRP_tSRFTransmitter RFTransmitter = { .hdr.elementHdr.pType =
&LLRP_tdRFTransmitter, .HopTableID = 1, .ChannelIndex = 1, .TransmitPower =
1, }; LLRP_tSC1G2RFControl C1G2RFControl = { .hdr.elementHdr.pType =
&LLRP_tdC1G2RFControl, .ModeIndex = 4, .Tari = 0, };
LLRP_tSC1G2SingulationControl C1G2SingulationControl = {
.hdr.elementHdr.pType = &LLRP_tdC1G2SingulationControl, .Session = 2,
.TagPopulation = 32, .TagTransitTime = 0, }; LLRP_tSC1G2InventoryCommand
C1G2InventoryCommand = { .hdr.elementHdr.pType =
&LLRP_tdC1G2InventoryCommand, /* * a g_ModeIndex was given on the command
line. */ .pC1G2RFControl = &C1G2RFControl, .pC1G2SingulationControl =
&C1G2SingulationControl, }; LLRP_tSAntennaConfiguration
AntennaConfiguration = { .hdr.elementHdr.pType =
&LLRP_tdAntennaConfiguration, //antena ID .pRFTransmitter = &RFTransmitter,
.listAirProtocolInventoryCommandSettings = &C1G2InventoryCommand.hdr, };
LLRP_tSInventoryParameterSpec InventoryParameterSpec = {
.hdr.elementHdr.pType = &LLRP_tdInventoryParameterSpec,
.InventoryParameterSpecID = 1234, .eProtocolID =
LLRP_AirProtocols_EPCGlobalClass1Gen2, .listAntennaConfiguration =
&AntennaConfiguration, }; LLRP_tSAISpec AISpec = { .hdr.elementHdr.pType =
&LLRP_tdAISpec, .AntennaIDs = { .nValue = 4, .pValue = AntennaIDs_n },
.pAISpecStopTrigger = &AISpecStopTrigger, .listInventoryParameterSpec =
&InventoryParameterSpec, }; LLRP_tSTagReportContentSelector
TagReportContentSelector = { .hdr.elementHdr.pType =
&LLRP_tdTagReportContentSelector, .EnableROSpecID = 0, .EnableSpecIndex =
1,//0 Conf. De Fabrica .EnableInventoryParameterSpecID = 0,
.EnableAntennaID = 1, .EnableChannelIndex = 0, .EnablePeakRSSI = 0,
.EnableFirstSeenTimestamp = 1, .EnableLastSeenTimestamp = 1,
.EnableTagSeenCount = 1, .EnableAccessSpecID = 0, }; LLRP_tSROReportSpec
ROReportSpec = { .hdr.elementHdr.pType = &LLRP_tdROReportSpec,
.eROReportTrigger = LLRP_ROReportTriggerType_Upon_N_Tags_Or_End_Of_ROSpec,
.N = 1, .pTagReportContentSelector = &TagReportContentSelector, };
LLRP_tSROSpec ROSpec = { .hdr.elementHdr.pType = &LLRP_tdROSpec, .ROSpecID
= 123, .Priority = 0, .eCurrentState = LLRP_ROSpecState_Disabled,
.pROBoundarySpec = &ROBoundarySpec, .listSpecParameter = &AISpec.hdr,
.pROReportSpec = &ROReportSpec, }; LLRP_tSADD_ROSPEC Cmd = {
.hdr.elementHdr.pType = &LLRP_tdADD_ROSPEC, .hdr.MessageID = 201, .pROSpec
= &ROSpec, }; LLRP_tSMessage * pRspMsg; LLRP_tSADD_ROSPEC_RESPONSE *pRsp;
/* * Send the message, expect the response of certain type */ pRspMsg =
transact(&Cmd.hdr);


*Thanks For All Help!!*
--
*Raul Rosetto Muñoz*
Loading...