rec::robotino::api2 C interface
Macros | Typedefs | Functions
Com.h File Reference

In "rec/robotino/api2/c/Com.h" you can find functions for manipulating the communication interface to Robotino. More...

#include "rec/robotino/api2/c/globals.h"
#include "rec/robotino/api2/c/AnalogInput.h"
#include "rec/robotino/api2/c/Bumper.h"
#include "rec/robotino/api2/c/Camera.h"
#include "rec/robotino/api2/c/CompactBHA.h"
#include "rec/robotino/api2/c/DigitalInput.h"
#include "rec/robotino/api2/c/DigitalOutput.h"
#include "rec/robotino/api2/c/DistanceSensor.h"
#include "rec/robotino/api2/c/EncoderInput.h"
#include "rec/robotino/api2/c/Gripper.h"
#include "rec/robotino/api2/c/Info.h"
#include "rec/robotino/api2/c/Motor.h"
#include "rec/robotino/api2/c/NorthStar.h"
#include "rec/robotino/api2/c/Odometry.h"
#include "rec/robotino/api2/c/OmniDrive.h"
#include "rec/robotino/api2/c/PowerManagement.h"
#include "rec/robotino/api2/c/PowerOutput.h"
#include "rec/robotino/api2/c/Relay.h"
#include "rec/robotino/api2/c/LaserRangeFinder.h"
#include "rec/robotino/api2/c/Manipulator.h"

Go to the source code of this file.

Macros

#define INVALID_COMID   -1
 

Typedefs

typedef int ComId
 

Functions

DLLEXPORT ComId Com_construct ()
 
DLLEXPORT BOOL Com_constructWithId (ComId id)
 
DLLEXPORT BOOL Com_destroy (ComId id)
 
DLLEXPORT void Com_destroyAll (void)
 
DLLEXPORT BOOL Com_setAddress (ComId id, const char *address)
 
DLLEXPORT BOOL Com_address (ComId id, char *addressBuffer, unsigned int addressBuffersSize)
 
DLLEXPORT BOOL Com_setAutoReconnectEnabled (ComId id, BOOL enable)
 
DLLEXPORT BOOL Com_setImageServerPort (ComId id, int port)
 
DLLEXPORT BOOL Com_connect (ComId id)
 
DLLEXPORT BOOL Com_disconnect (ComId id)
 
DLLEXPORT BOOL Com_isConnected (ComId id)
 
DLLEXPORT int Com_num_objects (void)
 

Detailed Description

In "rec/robotino/api2/c/Com.h" you can find functions for manipulating the communication interface to Robotino.

Use Com_construct() to create a new com object. Set the IP-address of Robotino with Com_setAddress(). Com_connect() establishes the connection.

#include "rec/robotino/api2/c/Com.h"
ComId com;
int main( int argc, char **argv )
{
  com = Com_construct();
  if( argc > 1 )
  {
    Com_setAddress( com, argv[1] );
  }
  else
  {
    Com_setAddress( com, "172.26.1.1" );
  }
  if( FALSE == Com_connect( com ) )
  {
    exit( 1 );
  }
  else
  {
    char addressBuffer[256];
    Com_address( com, addressBuffer, 256 );
    printf( "Connected to %s\n", addressBuffer );
  }
  Com_destroy( com );
  return 0;
}

Macro Definition Documentation

#define INVALID_COMID   -1

Invalid ComId is -1

Typedef Documentation

typedef int ComId

ComId

Function Documentation

DLLEXPORT BOOL Com_address ( ComId  id,
char *  addressBuffer,
unsigned int  addressBuffersSize 
)
Parameters
idThe ComId returned by Com_construct().
addressBufferWill contain the currently active server address set with Com_setAddress() as '\0' terminated string.
addressBuffersSizeThe size of addressBuffer.
Returns
Returns TRUE (1) on success. Returns FALSE (0) if the given ComId is invalid or if addressBuffer is to small to contain the address string.
See also
Com_setAddress
DLLEXPORT BOOL Com_connect ( ComId  id)

Establish the communication. Call Com_setAddress() first.

Parameters
idThe ComId returned by Com_construct().
Returns
Returns TRUE (1) on success. Returns FALSE (0) if the given ComId is invalid.
DLLEXPORT ComId Com_construct ( )

Construct an interface for communicating to one Robotino

Returns
Returns the ID of the newly constructed communication interface.
DLLEXPORT BOOL Com_constructWithId ( ComId  id)

Construct an interface for communicating to one Robotino

Parameters
idA user defined id. The value must be greater equal 0.
Returns
Returns TRUE if a com object with the given id could be constructed. Returns FALSE if the given id is already in use.
DLLEXPORT BOOL Com_destroy ( ComId  id)

Destroy the communication interface assigned to id

Parameters
idThe id of the communication interface to be destroyed
Returns
Returns TRUE (1) on success. Returns FALSE (0) if the given ComId is invalid.
DLLEXPORT void Com_destroyAll ( void  )

Destroy all Com objects and attached actuators and sensors.

DLLEXPORT BOOL Com_disconnect ( ComId  id)

Stop communication.

Parameters
idThe ComId returned by Com_construct().
Returns
Returns TRUE (1) on success. Returns FALSE (0) if the given ComId is invalid.
DLLEXPORT BOOL Com_isConnected ( ComId  id)

Check if the communication is established.

Parameters
idThe ComId returned by Com_construct().
Returns
Returns TRUE (1) if the communication is active. Returns FALSE (0) if the communication is inactive or if the given ComId is invalid.
DLLEXPORT int Com_num_objects ( void  )

For debugging only.

DLLEXPORT BOOL Com_setAddress ( ComId  id,
const char *  address 
)
Parameters
idThe ComId returned by Com_construct().
addressA null terminated string containing the (IP)-address (plus port) of Robotino. The default to connect to Robotino is 172.26.1.1 (port can be omitted. To connect to RobotinoSim running at localhost use 127.0.0.1:8080 (or higher ports).
Returns
Returns TRUE (1) on success. Returns FALSE (0) if the given ComId is invalid.
DLLEXPORT BOOL Com_setImageServerPort ( ComId  id,
int  port 
)
Parameters
idThe ComId returned by Com_construct().
portThe image server port. To be able to receive images from Robotino there is a UDP server running on your machine. The default port is 8080, but you might change this.
Returns
Returns TRUE (1) on success. Returns FALSE (0) if the given ComId is invalid.