26 m_sensorLabel =
"RFID";
38 std::thread(dummy_startDriver,
this).detach();
50 std::stringstream cmdline;
51 std::cout <<
"Waiting for the driver to start ... ";
54 cmdline << driver_path <<
" " << reader_name.c_str() <<
" " << IPm.c_str()
58 std::this_thread::sleep_for(2s);
60 const int ret = ::system(cmdline.str().c_str());
62 std::cerr <<
"[CImpinjRFID::startDriver] Error (" << ret
63 <<
") invoking command:\n" 64 << cmdline.str() << std::endl;
69 const std::string& iniSection)
93 IPm = configSource.
read_string(iniSection,
"local_IP",
"127.0.0.1",
false);
94 reader_name = configSource.
read_string(iniSection,
"reader_name",
"",
true);
95 port = configSource.
read_int(iniSection,
"listen_port", 0,
true);
96 driver_path = configSource.
read_string(iniSection,
"driver_path",
"",
true);
110 server = std::make_unique<mrpt::comms::CServerTCPSocket>(port);
113 client = server->accept();
115 std::this_thread::sleep_for(1s);
127 bool receivedSomething =
false;
136 client->writeAsync(
cmd, 10);
139 while (client->readAsync(msg, 34, 100) > 0)
141 receivedSomething =
true;
147 std::cerr <<
"[CImpinjRFID::getObservation] Unexpected format " 148 "in sensor data! (skipping).\n";
151 const char ant_port = *ant_port_ptr;
165 new_tag.
epc = std::string(epc);
166 new_tag.
power = atof(rx_pwr);
173 if (receivedSomething)
178 catch (
const std::exception& e)
180 std::cerr << e.what() << std::endl;
194 client->writeAsync(
cmd, 10);
std::string antennaPort
Port of the antenna that did the reading.
std::string read_string(const std::string §ion, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
std::string std::string format(std::string_view fmt, ARGS &&... args)
This class implements an interface to an Impinj RFID reader.
Contains classes for various device interfaces.
char * strcpy(char *dest, size_t destSize, const char *source) noexcept
An OS-independent version of strcpy.
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
void loadConfig_sensorSpecific(const mrpt::config::CConfigFileBase &configSource, const std::string §ion) override
Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, loading from the section "[iniSection]" (see config::CConfigFileBase and derived classes)
This class allows loading and storing values and vectors of different types from a configuration text...
void initialize() override
This method can or cannot be implemented in the derived class, depending on the need for it...
std::string epc
EPC code of the observed tag.
char * strtok(char *str, const char *strDelimit, char **context) noexcept
An OS-independent method for tokenizing a string.
void startDriver()
start the external driver
double power
The power or signal strength as sensed by the RFID receiver (in dBm)
static Ptr Create(Args &&... args)
#define IMPLEMENTS_GENERIC_SENSOR(class_name, NameSpace)
This must be inserted in all CGenericSensor classes implementation files:
static void dummy_startDriver(CImpinjRFID *o)
TCLAP::CmdLine cmd("system_control_rate_timer_example")
std::string sensorLabel
An arbitrary label that can be used to identify the sensor.
void connect()
Connect to the reader.
OBSERVATION_T::Ptr getObservation(mrpt::obs::CSensoryFrame::Ptr &observations, mrpt::obs::CObservation::Ptr &observation, bool priority_to_sf=true)
Given an mrpt::obs::CSensoryFrame and a mrpt::obs::CObservation pointer if a OBSERVATION_T type obser...
bool getObservation(mrpt::obs::CObservationRFID &obs)
Gets the information of the tags as a timestamped observation NOTE: Deprecated, use getObservations i...
std::vector< TTagReading > tag_readings
The vector of individual tag observations.
Each of the individual readings of a RFID tag.
void doProcess() override
This method will be invoked at a minimum rate of "process_rate" (Hz)
This represents one or more RFID tags observed by a receiver.
void closeReader()
Close the connection to the reader.