31 typedef vector<unsigned char> protobuffer;
36 buffer & append_byte ( uint8_t
byte );
37 buffer & append_word ( uint16_t word );
41 void dump (
const string & header )
const;
47 virtual void write (
const buffer &buf ) = 0;
48 virtual buffer read (
void ) = 0;
56 virtual void write (
const buffer &buf );
57 virtual buffer read (
void );
59 libusb_context *context_;
60 libusb_device_handle *handle_;
62 void usb_check (
int usb_error );
68 nxt_error (
const char *s ) : runtime_error ( s ) {};
69 nxt_error (
const string & s ) : runtime_error ( s ) {};
84 motor_regulated = 0x04
89 regulation_motor_idle = 0x00,
90 regulation_motor_speed = 0x01,
91 regulation_motor_sync = 0x02
96 motor_run_state_idle = 0x00,
97 motor_run_state_ramp_up = 0x10,
98 motor_run_state_running = 0x20,
99 motor_run_state_rampdown = 0x40
104 uint8_t protocol_minor;
105 uint8_t protocol_major;
106 uint8_t firmware_minor;
107 uint8_t firmware_major;
113 char bluetooth_address[7];
121 regulation_modes regulation;
123 motor_run_states state;
126 int32_t block_tacho_count;
127 int32_t rotation_count;
147 buffer execute (
const buffer &command,
bool with_feedback =
false );
152 buffer prepare_play_tone ( uint16_t tone_Hz, uint16_t duration_ms );
154 buffer prepare_output_state (
157 motor_modes mode = motor_brake,
158 regulation_modes regulation = regulation_motor_speed,
159 int8_t turn_ratio = 0,
160 motor_run_states state = motor_run_state_running,
161 uint32_t tacho_count = 0 );
164 buffer prepare_reset_motor_position ( motors motor,
bool relative_to_last_position =
false );
165 buffer prepare_stop_sound_playback (
void );
166 buffer prepare_keep_alive (
void );
172 void play_tone ( uint16_t tone_Hz, uint16_t duration_ms );
175 void set_motor ( motors motor, int8_t power_pct );
180 uint16_t get_battery_level (
void );
188 void msg_rate_check (
void );
194 direct_command_with_response = 0x00,
195 system_command_with_response = 0x01,
197 direct_command_without_response = 0x80,
198 system_command_without_response = 0x80
201 buffer assemble ( telegram_types teltype,
#define PLAYER_MSG1(level, msg, a)
Error message macros.
Definition: error.h:106
#define PLAYER_MSG3(level, msg, a, b, c)
Error message macros.
Definition: error.h:108
uint32_t host
The "host" on which the device resides.
Definition: player.h:148
static bool MatchMessage(player_msghdr_t *hdr, int type, int subtype, player_devaddr_t addr)
Helper for message processing.
Definition: message.h:159
Generic message header.
Definition: player.h:162
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
#define PLAYER_WARN3(msg, a, b, c)
Error message macros.
Definition: error.h:92
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
uint32_t robot
The "robot" or device collection in which the device resides.
Definition: player.h:151
double ReadTupleFloat(int section, const char *name, int index, double value)
Read a float (double) from a tuple field.
virtual void Main(void)=0
Main method for driver thread.
int ReadInt(int section, const char *name, int value)
Read an integer value.
#define PLAYER_MSGTYPE_DATA
A data message.
Definition: player.h:95
#define PLAYER_MSGTYPE_RESP_ACK
A positive response message.
Definition: player.h:112
#define PLAYER_WARN2(msg, a, b)
Error message macros.
Definition: error.h:91
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
#define PLAYER_MSGTYPE_REQ
A request message.
Definition: player.h:106
int ReadDeviceAddr(player_devaddr_t *addr, int section, const char *name, int code, int index, const char *key)
Read a device id.
Class for loading configuration file information.
Definition: configfile.h:197
A device address.
Definition: player.h:146
An autopointer for the message queue.
Definition: message.h:74
uint32_t seq
For keeping track of associated messages.
Definition: player.h:172
#define PLAYER_ERROR(msg)
Error message macros.
Definition: error.h:81
Base class for drivers which oeprate with a thread.
Definition: driver.h:553
#define PLAYER_WARN(msg)
Warning message macros.
Definition: error.h:89
#define PLAYER_MSGTYPE_CMD
A command message.
Definition: player.h:99
Base class for all drivers.
Definition: driver.h:109
#define PLAYER_WARN4(msg, a, b, c, d)
Error message macros.
Definition: error.h:93
Definition: mixed/nxt/src/chronos.hh:29
uint16_t index
Which device of that interface.
Definition: player.h:155
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