|
NAMERobot Communication API - Functionsvoid rct_init_brick_struct (rct_brick_t *brick,
rct_brick_type_t type)
Detailed Descriptionlibroboctl is a C Application Programming Interface (API) for communication with robot bricks such as Lego and VEX. It implements the basic functions of the controller communication protocols, plus higher level functions such as file uploading, downloading, etc. The library allows programs written in C (and other languages capable of linking to C routines) to locate robo bricks on available communication links (e.g. USB, Bluetooth), open a connection to the brick, send commands and data, and retrieve data. The top-layer C API is brick and interface independent, so you can in many cases write one program that will work with any brick over any communication interface. E.g., uploading a program file or checking the battery level is essentially the same for all bricks and it makes no difference whether we use a serial port, USB, or Bluetooth to perform these tasks. Although use of the device independent API is encouraged for the sake of minimizing code changes for new bricks, it is not required. Some operations, are of course, specific to a certain type of brick or only make sense for certain communication links. For example, using NXT direct commands to remote-control an NXT robot connected via a USB cable could be problematic or disastrous for the robot. In these cases, a program might want a Bluetooth connection or nothing. Example program to print some basic device info: #include <stdio.h> #include <sysexits.h> #include <legoctl/legoctl.h> /* See alsonbc(1), nxc(1), nqc(1), legoctl(1), vexctl(1), ape(1) Function Documentationrct_brick_t* rct_get_brick_from_list (rct_brick_list_t * list, int n)Get brick N from an rct_brick_list_t structure. Parameters: list - a structure containing an array of bricks.
n - the index of the desired brick. Author: Jason W. Bacon
Return a pointer to brick N in the array of bricks. void rct_init_brick_struct (rct_brick_t * brick, rct_brick_type_t type)Initialize a brick structure. Parameters: brick - Pointer to an uninitialized brick
stucture.
type - RCT_NXT or RCT_RCX. Author: Jason W. Bacon
This function initializes the brick structure, including the brick dependent substructures for NXT, RCX, etc. This function must be called before any other functions that operate on the structure. Calling this function on a brick structure that has already been initialized and worked with may have disastrous results. Supported bricks:
rct_status_t rct_motor_on (rct_brick_t * brick, int port, int power)Parameters: \param
\author rct_status_t rct_open_brick (rct_brick_t * brick)Open a connection to a brick. Parameters: brick - Pointer to an initialized brick
stucture.
Author: Jason W. Bacon
Open a connection to specified brick. The connection handle is stored within the rct_brick_t structure. The structure must be initialized with rct_init_brick() first. This is normally done by rct_find_*(). Supported bricks/interfaces:
rct_status_t rct_play_sound_file (rct_brick_t * brick, rct_flag_t flags, char * filename)Instruct the brick to play a sound file. Parameters: brick - Pointer to a brick structure with an open
connection.
flags - Bit flags to control play mode. filename - Name of sound file (must be on brick already). Author: Jason W. Bacon
Play the specified sound file on the brick. The filename must end in '.rso', and must have been previously uploaded to the brick. The brick must first be opened with rct_open_brick(). Valid flags:
Supported bricks:
rct_status_t rct_play_tone (rct_brick_t * brick, int herz, int milliseconds)Instruct the robo brick to play a tone. Parameters: brick - Pointer to a brick structure with an open
connection.
herz - Frequency of the tone (200 - 14000Hz). milliseconds - Duration of the tone. Author: Jason W. Bacon
Play the specified tone for the specified duration. The brick must first be opened with rct_open_brick(). Supported bricks:
rct_status_t rct_upload_file (rct_brick_t * brick, char * filename, rct_flag_t flags)Upload a file to the brick. Parameters: brick - Pointer to a brick structure with an open
connection.
filename - name of the file on the local computer. flags - upload mode Author: Jason W. Bacon
Upload the specified file (e.g. an executable or sound file) to the brick. The brick must first be opened with rct_open_brick(). Valid flags:
AuthorGenerated automatically by Doxygen for roboctl from the source code.
|