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,