NXT Namespace Reference

Contains all the functions that have to do with the NXT. More...


Namespaces

namespace  File
 NXT file functions.
namespace  Module
 NXT module functions.
namespace  Motor
 Contains all the functions that have to do with a motor.
namespace  NxtCam
 NXTCam functions.
namespace  Sensor
 Contains all the functions that have to do with a sensor.

Functions

bool Open (Comm::NXTComm *comm)
 Initiates the NXT connection.
bool OpenBT (Comm::NXTComm *comm)
 Initiates the NXT connection through Bluetooth.
void Close (Comm::NXTComm *comm)
 Closes the NXT connection.
void PlayTone (Comm::NXTComm *comm, int frequency, int duration)
 Plays a tone.
int BatteryLevel (Comm::NXTComm *comm)
 Returns the current battery level.
std::string GetName (Comm::NXTComm *comm)
 Gets the name of the NXT.
double GetAvailableFlash (Comm::NXTComm *comm)
 Gets the amount of availiable flash memory on the NXT.
void StopProgram (Comm::NXTComm *comm)
 Stops the current program if one is running.
double GetProtocolVersion (Comm::NXTComm *comm)
 Gets the protocol version of the NXT.
double GetFirmwareVersion (Comm::NXTComm *comm)
 Gets the firmware version of the NXT.
void StartProgram (Comm::NXTComm *comm, std::string name)
 Starts a program on the NXT with a specified name.
void PlaySoundFile (Comm::NXTComm *comm, std::string name, bool loop)
 Plays a sound file on the NXT with a specified name.
void StopSound (Comm::NXTComm *comm)
 Stops the currently playing sound.
void KeepAlive (Comm::NXTComm *comm)
 Resets the internal sleep timer.
void SendDirectCommand (Comm::NXTComm *comm, ViBoolean response, ViByte *dc_buf, int dc_buf_size, ViByte *re_buf, int re_buf_size)
 Sends a direct command to the NXT.


Detailed Description

Contains all the functions that have to do with the NXT.

Function Documentation

int NXT::BatteryLevel ( Comm::NXTComm *  comm  ) 

Returns the current battery level.

Returns:
The current battery level in millivolts.

void NXT::Close ( Comm::NXTComm *  comm  ) 

Closes the NXT connection.

double NXT::GetAvailableFlash ( Comm::NXTComm *  comm  ) 

Gets the amount of availiable flash memory on the NXT.

Does not work with linux yet.

Returns:
The amount of free flash memory in kilobytes.

double NXT::GetFirmwareVersion ( Comm::NXTComm *  comm  ) 

Gets the firmware version of the NXT.

Does not work with linux yet.

Returns:
The firmware version of the NXT.

std::string NXT::GetName ( Comm::NXTComm *  comm  ) 

Gets the name of the NXT.

Returns:
The name of the NXT.

double NXT::GetProtocolVersion ( Comm::NXTComm *  comm  ) 

Gets the protocol version of the NXT.

Does not work with linux yet.

Returns:
The protocol version of the NXT.

void NXT::KeepAlive ( Comm::NXTComm *  comm  ) 

Resets the internal sleep timer.

This function is used so the NXT will not automatically turn off while the computer is still controlling it. Note: an alternative to this is to set the shutoff time to never in the NXT settings menu.

bool NXT::Open ( Comm::NXTComm *  comm  ) 

Initiates the NXT connection.

Returns true if it completed without error. Returns false if it failed. You should not continue to use the interface functions if this happens. Refer to example.cpp for info on how to properly handle this.

bool NXT::OpenBT ( Comm::NXTComm *  comm  ) 

Initiates the NXT connection through Bluetooth.

Returns true if it completed without error. Returns false if it failed. You should not continue to use the interface functions if this happens. Refer to example.cpp for info on how to properly handle this. Does not work with linux yet.

void NXT::PlaySoundFile ( Comm::NXTComm *  comm,
std::string  name,
bool  loop 
)

Plays a sound file on the NXT with a specified name.

Parameters:
name The filename of the sound you wish to play. Don't forget to include the '.rso'!

void NXT::PlayTone ( Comm::NXTComm *  comm,
int  frequency,
int  duration 
)

Plays a tone.

Parameters:
frequency The frequency in hertz.
duration The duration in milliseconds.

void NXT::SendDirectCommand ( Comm::NXTComm *  comm,
ViBoolean  response,
ViByte *  dc_buf,
int  dc_buf_size,
ViByte *  re_buf,
int  re_buf_size 
)

Sends a direct command to the NXT.

This low-level function is used to send commands to the NXT - just like all the other functions do. The only difference is that this function is harder to use, but in turn, provides much more control of the NXT. For a reference about direct commands, look in the PDF titled Appendix 2.

Parameters:
response Whether or not you want to recieve a response from the direct command.
dc_buf The buffer that contains the direct command.
dc_buf_size The number of bytes in the direct command buffer.
re_buf The buffer that will contain the response to the direct command if specified.
re_buf_size The number of bytes in the response buffer.

void NXT::StartProgram ( Comm::NXTComm *  comm,
std::string  name 
)

Starts a program on the NXT with a specified name.

Parameters:
name The filename of the program you wish to execute. Don't forget to include the '.rxe'!

void NXT::StopProgram ( Comm::NXTComm *  comm  ) 

Stops the current program if one is running.

void NXT::StopSound ( Comm::NXTComm *  comm  ) 

Stops the currently playing sound.

SourceForge.net Logo