Public Member Functions | Protected Member Functions | Protected Attributes
CNTronBase Class Reference

#include <cntronbase.h>

List of all members.

Public Member Functions

int checkPenalization (CNTronNode &nodeInf)
 CNTronBase (int baseId=DEFAULT_ID)
 Default constructor.
int detectBeacons ()
void finish (void)
 Finish the serial communication (closes serial port)
int getBaseId () const
 Returns the unique identifier of the base node (node connected to PC).
int init (const char *pDev)
unsigned int numBeacons () const
void printBeacons () const
int readRange (unsigned int node, CNTronRange &pData, std::string &msg)
 ~CNTronBase (void)
 Default destructor.

Protected Member Functions

int chartohex (char *cnum)
int readBaseID ()
int sendCommand (const char *command, int size)

Protected Attributes

int m_baseId
 Base Id.
std::vector< int > m_nodeIDs
 Nodes unique ID.
std::map< int, CNTronNodem_nodes
 Nodes information.
int m_portHandler
 Serial port handler.
char m_readBuff [256]
 Reading buffer.

Detailed Description

Definition at line 70 of file cntronbase.h.


Constructor & Destructor Documentation

Default constructor.

Software License Agreement (BSD License)

Copyright (c) 2013-2015 Robotics, Vision and Control Group (GRVC), University of Seville. 2013 Fernando Caballero <fcaballero@us.es> 2014 Felipe R.Fabresse <felramfab@us.es> 2014 Alfredo Vazquez <avringeniero@gmail.com> 2015 Felipe R.Fabresse <felramfab@gmail.com> All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition at line 42 of file cntronbase.cpp.

Default destructor.

Definition at line 47 of file cntronbase.cpp.


Member Function Documentation

int CNTronBase::chartohex ( char *  cnum) [protected]

Reads the last part of the MAC address given and returns the ID associated.

This function reads the part of the MAC address associated to the unique ID of Nanotron range sensors, i.e. it reads the last 2 bytes of the MAC address.

Parameters:
cnumHexadecimal MAC address.
Returns:
The unique ID associated to a MAC address.

Definition at line 409 of file cntronbase.cpp.

Checks if the penalization of a node must be set to 0 beacuse of a delay time.

Parameters:
nodeInfThe node information.
Returns:
The node penalization.

Definition at line 300 of file cntronbase.cpp.

Detects the list of beacons available.

Returns:
  • -1: Error sending command.
  • -5: Empty buffer.
  • 0: Beacons detected correctly.

Definition at line 320 of file cntronbase.cpp.

void CNTronBase::finish ( void  )

Finish the serial communication (closes serial port)

Definition at line 127 of file cntronbase.cpp.

int CNTronBase::getBaseId ( void  ) const

Returns the unique identifier of the base node (node connected to PC).

Definition at line 51 of file cntronbase.cpp.

int CNTronBase::init ( const char *  pDev)

Intialize the serial port to the given values. The function open the serial port in read-write mode

Parameters:
pDevPort of the serial device (e.g. '/dev/ttyUSB0')
Returns:
  • 0: success
  • -1: error while open the device
  • -2: erroneous parity
  • -3: erroneous dataBits
  • -4: erroneous stopBits

Definition at line 79 of file cntronbase.cpp.

unsigned int CNTronBase::numBeacons ( ) const

Return the current number of detected nodes.

Definition at line 55 of file cntronbase.cpp.

void CNTronBase::printBeacons ( ) const

Definition at line 59 of file cntronbase.cpp.

int CNTronBase::readBaseID ( ) [protected]

Reads the base node ID (MAC of node connected to serial port)

return= -1; Error sending command. [ SendCommand() devuelve -6 ]. return= -5; Empty serial buffer. [ read() devuelve 0 ]. return= 0; Success.

Definition at line 136 of file cntronbase.cpp.

int CNTronBase::readRange ( unsigned int  node,
CNTronRange pData,
std::string &  msg 
)

This function parse a complete message sent by the sensor board. First sends a RangeTo command and then reads the result. The beacon to be used for range request is selected automatically, reading periodically the list of available beacons and then selecting the next beacon to be ranged.

Sensor information is sent in binary mode.

Parameters:
nodeThe node to be requested to range.
pDataPointer to the structure where range information will be located.
msgA reference to a string where any error message will be saved.
Returns:
  • <0: Error
  • 0: No new data available
  • 1: New data available

Definition at line 196 of file cntronbase.cpp.

int CNTronBase::sendCommand ( const char *  command,
int  size 
) [protected]

Sends a stream of data to the configured serial port.

Parameters:
commandData stream
sizeLength of the data stream.
Returns:
0 if command was sent successfully -6 if any error.

Definition at line 183 of file cntronbase.cpp.


Member Data Documentation

int CNTronBase::m_baseId [protected]

Base Id.

Definition at line 187 of file cntronbase.h.

std::vector<int> CNTronBase::m_nodeIDs [protected]

Nodes unique ID.

Definition at line 190 of file cntronbase.h.

std::map<int, CNTronNode> CNTronBase::m_nodes [protected]

Nodes information.

Definition at line 193 of file cntronbase.h.

int CNTronBase::m_portHandler [protected]

Serial port handler.

Definition at line 181 of file cntronbase.h.

char CNTronBase::m_readBuff[256] [protected]

Reading buffer.

Definition at line 184 of file cntronbase.h.


The documentation for this class was generated from the following files:


nanotron_swarm
Author(s): Felipe Ramón Fabresse, Alfredo Vázquez Reyes, Fernando Caballero Benitez
autogenerated on Sat Jun 8 2019 20:36:48