driver.h
141 int AddInterface(player_devaddr_t *addr, ConfigFile * cf, int section, int code, const char * key = NULL);
159 int AddFileWatch(int fd, bool ReadWatch = true, bool WriteWatch = false, bool ExceptWatch = true);
162 int RemoveFileWatch(int fd, bool ReadWatch = true, bool WriteWatch = false, bool ExceptWatch = true);
ThreadedDriver(ConfigFile *cf, int section, bool overwrite_cmds, size_t queue_maxlen, int interface_)
Constructor with implicit interface.
#define PLAYER_MSG5(level, msg, a, b, c, d, e)
Error message macros.
Definition: error.h:110
virtual void Publish(QueuePointer &queue, player_msghdr_t *hdr, void *src, bool copy=true)
Publish a message via one of this driver's interfaces.
virtual void Publish(player_devaddr_t addr, QueuePointer &queue, uint8_t type, uint8_t subtype, void *src=NULL, size_t deprecated=0, double *timestamp=NULL, bool copy=true)
Publish a message via one of this driver's interfaces.
static bool MatchMessage(player_msghdr_t *hdr, int type, int subtype, player_devaddr_t addr)
Helper for message processing.
Definition: message.h:159
virtual int ProcessInternalMessages(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Internal message handler.
pthread_mutex_t barrierMutex
barrier to make sure StartThread doesnt return until cleanup handlers etc have been installed.
Definition: driver.h:501
virtual bool RegisterProperty(Property *property, ConfigFile *cf, int section)
Property registration.
virtual int Subscribe(QueuePointer &, player_devaddr_t)
Subscribe to this driver.
Definition: driver.h:343
int RemoveFileWatch(int fd, bool ReadWatch=true, bool WriteWatch=false, bool ExceptWatch=true)
Remove a previously added watch, call with the same arguments as when adding the watch.
virtual int MainSetup(void)
Sets up the resources needed by the driver thread.
Definition: driver.h:658
virtual void MainQuit(void)
Cleanup method for driver thread (called when main exits)
Definition: driver.h:664
uint8_t type
Message type; must be one of PLAYER_MSGTYPE_*.
Definition: player.h:166
uint32_t robot
The "robot" or device collection in which the device resides.
Definition: player.h:151
Definition: position/differential/chronos.hh:28
QueuePointer InQueue
Queue for all incoming messages for this driver.
Definition: driver.h:285
#define PLAYER_MSGTYPE_RESP_ACK
A positive response message.
Definition: player.h:112
virtual void SubscriptionLock(void)
Lock to protect the subscription count for the driver.
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
player_thread_state_t ThreadState
TODO: insert state machine here.
Definition: driver.h:584
ThreadedDriver(ConfigFile *cf, int section, bool overwrite_cmds=true, size_t queue_maxlen=PLAYER_MSGQUEUE_DEFAULT_MAXLEN)
Constructor for multiple-interface drivers.
virtual void TestCancel()
enable thread cancellation and test for cancellation
Definition: driver.h:186
int ReadDeviceAddr(player_devaddr_t *addr, int section, const char *name, int code, int index, const char *key)
Read a device id.
virtual int Unsubscribe(QueuePointer &, player_devaddr_t)
Unsubscribe from this driver.
Definition: driver.h:369
Driver(ConfigFile *cf, int section, bool overwrite_cmds=true, size_t queue_maxlen=PLAYER_MSGQUEUE_DEFAULT_MAXLEN)
Constructor for multiple-interface drivers.
virtual void SubscriptionUnlock(void)
Unlock to protect the subscription count for the driver.
pthread_mutex_t accessMutex
Mutex used to lock access, via Lock() and Unlock(), to driver internals, like the list of subscribed ...
Definition: driver.h:168
Driver(ConfigFile *cf, int section, bool overwrite_cmds, size_t queue_maxlen, int interf)
Constructor for single-interface drivers.
PlayerBarrier SetupBarrier
Barrier to synchronise threads on setup.
Definition: driver.h:588
virtual bool RegisterProperty(const char *key, Property *property, ConfigFile *cf, int section)
Property registration.
player_devaddr_t device_addr
Default device address (single-interface drivers)
Definition: driver.h:269
virtual void StopThread(void)
Cancel (and wait for termination) of the driver thread.
pthread_mutex_t subscriptionMutex
Mutex used to protect the subscription count for the driver.
Definition: driver.h:170
static void DummyMainQuit(void *driver)
Dummy main cleanup (just calls real main cleanup).
virtual void Publish(player_msghdr_t *hdr, void *src, bool copy=true)
Publish a message via one of this driver's interfaces.
virtual void Publish(player_devaddr_t addr, uint8_t type, uint8_t subtype, void *src=NULL, size_t deprecated=0, double *timestamp=NULL, bool copy=true)
Publish a message via one of this driver's interfaces.
int AddInterface(player_devaddr_t *addr, ConfigFile *cf, int section, int code, const char *key=NULL)
Add an interface.
int AddFileWatch(int fd, bool ReadWatch=true, bool WriteWatch=false, bool ExceptWatch=true)
Wake up the driver if the specified event occurs on the file descriptor.
int entries
Total number of entries in the device table using this driver.
Definition: driver.h:273
player_devaddr_t addr
Device to which this message pertains.
Definition: player.h:164
uint16_t interf
The interface provided by the device; must be one of PLAYER_*_CODE.
Definition: player.h:153
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition: player.h:76
int subscriptions
Number of subscriptions to this driver.
Definition: driver.h:118
Definition: driver.h:472