interface_util.h
1 /*
2  * Player - One Hell of a Robot Server
3  * Copyright (C) 2000
4  * Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
5  *
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  */
22 /********************************************************************
23  *
24  * This library is free software; you can redistribute it and/or
25  * modify it under the terms of the GNU Lesser General Public
26  * License as published by the Free Software Foundation; either
27  * version 2.1 of the License, or (at your option) any later version.
28  *
29  * This library is distributed in the hope that it will be useful,
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32  * Lesser General Public License for more details.
33  *
34  * You should have received a copy of the GNU Lesser General Public
35  * License along with this library; if not, write to the Free Software
36  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
37  *
38  ********************************************************************/
39 
46 #ifndef _INTERFACE_UTIL_H
47 #define _INTERFACE_UTIL_H
48 
49 #if defined (WIN32)
50  #if defined (PLAYER_STATIC)
51  #define PLAYERINTERFACE_EXPORT
52  #elif defined (playerinterface_EXPORTS)
53  #define PLAYERINTERFACE_EXPORT __declspec (dllexport)
54  #else
55  #define PLAYERINTERFACE_EXPORT __declspec (dllimport)
56  #endif
57 #else
58  #define PLAYERINTERFACE_EXPORT
59 #endif
60 
61 #include <playerconfig.h> // for uint16_t type
62 
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66 
69 typedef struct
72 {
73  uint16_t interf;
74  char* name;
76 
80 PLAYERINTERFACE_EXPORT int itable_init (void);
81 
86 PLAYERINTERFACE_EXPORT int itable_grow (int newSize);
87 
91 PLAYERINTERFACE_EXPORT void itable_destroy (void);
92 
96 PLAYERINTERFACE_EXPORT int itable_add (const char *name, unsigned int code, int replace);
97 
103 PLAYERINTERFACE_EXPORT int lookup_interface(const char* name, player_interface_t* interf);
104 
110 PLAYERINTERFACE_EXPORT int
111 lookup_interface_code(int code, player_interface_t* interf);
112 
118 PLAYERINTERFACE_EXPORT const char*
119 lookup_interface_name(unsigned int startpos, int code);
120 
125 PLAYERINTERFACE_EXPORT const char*
126 interf_to_str(uint16_t code);
127 
132 PLAYERINTERFACE_EXPORT uint16_t
133 str_to_interf(const char *name);
134 
139 PLAYERINTERFACE_EXPORT const char*
140 msgtype_to_str(uint8_t code);
141 
146 PLAYERINTERFACE_EXPORT uint8_t
147 str_to_msgtype(const char *name);
149 #ifdef __cplusplus
150 }
151 #endif
152 #endif
153 
#define PLAYER_DIO_CMD_VALUES
Data: input values (PLAYER_DIO_DATA_VALUES)
Definition: player_interfaces.h:1987
#define PLAYER_WARN1(msg, a)
Error message macros.
Definition: error.h:90
#define PLAYER_RFID_REQ_READTAG
Request/reply: read data from the RFID tag - to be implemented.
Definition: player_interfaces.h:4299
static bool MatchMessage(player_msghdr_t *hdr, int type, int subtype, player_devaddr_t addr)
Helper for message processing.
Definition: message.h:159
double ReadFloat(int section, const char *name, double value)
Read a floating point (double) value.
Generic message header.
Definition: player.h:161
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
Encapsulates a device (i.e., a driver bound to an interface)
Definition: device.h:74
const char * ReadString(int section, const char *name, const char *value)
Read a string value.
uint8_t subtype
Message subtype; interface specific.
Definition: player.h:168
virtual void Main(void)=0
Main method for driver thread.
int ReadInt(int section, const char *name, int value)
Read an integer value.
Available interfaces are stored in an array of these, defined in interface_util.c.
Definition: interface_util.h:71
#define PLAYER_MSGTYPE_DATA
A data message.
Definition: player.h:95
#define PLAYER_ERROR2(msg, a, b)
Error message macros.
Definition: error.h:83
uint32_t digout
output bitfield
Definition: player_interfaces.h:2011
#define PLAYER_MSGTYPE_RESP_ACK
A positive response message.
Definition: player.h:112
#define PLAYER_RFID_DATA_TAGS
Data subtype.
Definition: player_interfaces.h:4293
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
static bool MatchDeviceAddress(player_devaddr_t addr1, player_devaddr_t addr2)
Compare two addresses.
Definition: device.h:201
#define PLAYER_MSGTYPE_REQ
A request message.
Definition: player.h:106
#define PLAYER_MSGTYPE_RESP_NACK
A negative response message.
Definition: player.h:125
Command: output values (PLAYER_DIO_CMD_VALUES)
Definition: player_interfaces.h:2006
int ReadDeviceAddr(player_devaddr_t *addr, int section, const char *name, int code, int index, const char *key)
Read a device id.
Data: input values (PLAYER_DIO_DATA_VALUES)
Definition: player_interfaces.h:1994
#define PLAYER_RFID_REQ_WRITETAG
Request/reply: write data to the RFID tag - to be implemented.
Definition: player_interfaces.h:4302
#define PLAYER_RFID_REQ_LOCKTAG
Request/reply: lock data blocks of a RFID tag - to be implemented.
Definition: player_interfaces.h:4305
Class for loading configuration file information.
Definition: configfile.h:196
virtual int Setup()
Initialize the driver.
Definition: driver.h:386
A device address.
Definition: player.h:145
An autopointer for the message queue.
Definition: message.h:73
#define PLAYER_RFID_REQ_POWER
Request/reply: put the reader in sleep mode (0) or wake it up (1).
Definition: player_interfaces.h:4296
uint32_t bits
bitfield of samples
Definition: player_interfaces.h:1999
position2d data
Definition: player_interfaces.h:606
position2d geom
Definition: player_interfaces.h:655
uint32_t count
the command
Definition: player_interfaces.h:2009
#define PLAYER_ERROR(msg)
Error message macros.
Definition: error.h:81
Base class for drivers which oeprate with a thread.
Definition: driver.h:552
#define PLAYER_POSITION2D_DATA_STATE
Data: state (PLAYER_POSITION2D_DATA_STATE)
Definition: player_interfaces.h:568
double timestamp
Time associated with message contents (seconds since epoch)
Definition: player.h:170
player_pose2d_t pos
position [m,m,rad] (x, y, yaw)
Definition: player_interfaces.h:609
uint32_t size
Size in bytes of the payload to follow.
Definition: player.h:174
#define PLAYER_WARN(msg)
Warning message macros.
Definition: error.h:89
Structure describing a single RFID tag.
Definition: player_interfaces.h:4311
#define PLAYER_MSGTYPE_CMD
A command message.
Definition: player.h:99
uint32_t count
number of samples
Definition: player_interfaces.h:1997
virtual int Shutdown()
Finalize the driver.
Definition: driver.h:393
#define PLAYER_DIO_DATA_VALUES
Data: input values (PLAYER_DIO_DATA_VALUES)
Definition: player_interfaces.h:1984
Base class for all drivers.
Definition: driver.h:108
#define PLAYER_MSG0(level, msg)
General messages.
Definition: error.h:105
Data.
Definition: player_interfaces.h:4324
player_devaddr_t addr
Device to which this message pertains.
Definition: player.h:164
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition: player.h:76