MRMS
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Board Class Referenceabstract

#include <mrm-board.h>

Inheritance diagram for Board:
MotorBoard SensorBoard Mrm_bldc2x50 Mrm_bldc4x2_5 Mrm_mot2x50 Mrm_mot4x10 Mrm_mot4x3_6can Mrm_8x8a Mrm_col_b Mrm_col_can Mrm_fet_can Mrm_ir_finder3 Mrm_ir_finder_can Mrm_lid_can_b Mrm_lid_can_b2 Mrm_node Mrm_ref_can Mrm_switch Mrm_therm_b_can Mrm_us Mrm_us1 Mrm_us_b

Public Member Functions

 Board (Robot *robot, uint8_t maxNumberOfBoards, uint8_t devicesOnABoard, const char *boardName, BoardType boardType, BoardId id)
 
void add (char *deviceName, uint16_t canIn, uint16_t canOut)
 
bool alive (uint8_t deviceNumber=0, bool checkAgainIfDead=false, bool errorIfNotAfterCheckingAgain=false)
 
uint8_t count ()
 
void aliveSet (bool yesOrNo, uint8_t deviceNumber=0)
 
BoardType boardType ()
 
uint8_t deadOrAliveCount ()
 
uint8_t devicesOnASingleBoard ()
 
uint8_t devicesMaximumNumberInAllBoards ()
 
uint8_t devicesScan (bool verbose=true, uint16_t mask=0xFFFF)
 
uint8_t errorCodeLast ()
 
uint8_t errorWasInDeviceNumber ()
 
void firmwareRequest (uint8_t deviceNumber=0xFF)
 
uint16_t fps (uint8_t deviceNumber=0)
 
void fpsDisplay ()
 
void fpsRequest (uint8_t deviceNumber=0xFF)
 
BoardId id ()
 
void idChange (uint16_t newDeviceNumber, uint8_t deviceNumber=0)
 
void info (uint8_t deviceNumber=0xFF)
 
bool isForMe (uint32_t canIdOut, uint8_t deviceNumber)
 
bool isFromMe (uint32_t canIdOut, uint8_t deviceNumber)
 
uint32_t lastMessageMs (uint8_t deviceNumber=0)
 
virtual bool messageDecode (uint32_t canId, uint8_t data[8])=0
 
bool messagePrint (uint32_t msgId, uint8_t dlc, uint8_t *data, bool outbound)
 ‍** Prints a frame More...
 
void messageSend (uint8_t *data, uint8_t dlc, uint8_t deviceNumber=0)
 
char * name (uint8_t deviceNumber)
 
char * name ()
 
void notificationRequest (uint8_t commandRequestingNotification, uint8_t deviceNumber)
 
void oscillatorTest (uint8_t deviceNumber=0xFF)
 
void reset (uint8_t deviceNumber=0xFF)
 
void start (uint8_t deviceNumber=0xFF, uint8_t measuringModeNow=0, uint16_t refreshMs=0)
 
void swap (uint8_t deviceNumber1, uint8_t deviceNumber2)
 
void stop (uint8_t deviceNumber=0xFF)
 
virtual void test (uint8_t deviceNumber=0xFF, uint16_t betweenTestsMs=0)
 

Protected Member Functions

bool messageDecodeCommon (uint32_t canId, uint8_t data[8], uint8_t deviceNumber=0)
 

Protected Attributes

uint32_t _alive
 
bool _aliveReport = false
 
char _boardsName [12]
 
BoardType _boardType
 
uint8_t canData [8]
 
uint8_t devicesOnABoard
 
uint8_t errorCode = 0
 
uint8_t errorInDeviceNumber = 0
 
std::vector< uint16_t > * fpsLast
 
BoardId _id
 
std::vector< uint32_t > * idIn
 
std::vector< uint32_t > * idOut
 
std::vector< uint32_t > * lastMessageReceivedMs
 
std::vector< uint32_t > * _lastReadingMs
 
uint8_t maximumNumberOfBoards
 
uint8_t measuringMode = 0
 
uint8_t measuringModeLimit = 0
 
uint8_t _message [29]
 
std::vector< char[10]> * _name
 
int nextFree
 
RobotrobotContainer
 

Detailed Description

Board is a class of all the boards of the same type, not a single board!

Constructor & Destructor Documentation

◆ Board()

Board::Board ( Robot robot,
uint8_t  maxNumberOfBoards,
uint8_t  devicesOnABoard,
const char *  boardName,
BoardType  boardType,
BoardId  id 
)
Parameters
robot- robot containing this board
maxNumberOfBoards- maximum number of boards
devicesOnABoard- number of devices on each board
boardName- board's name
id- unique id

Board is a single instance for all boards of the same type, not a single board (if there are more than 1 of the same type)!

Parameters
robot- robot containing this board
esp32CANBusSingleton- a single instance of CAN Bus common library for all CAN Bus peripherals.
maxNumberOfBoards- maximum number of boards
devicesOn1Board- number of devices on each board
boardName- board's name
id- unique id

Member Function Documentation

◆ add()

void Board::add ( char *  deviceName,
uint16_t  canIn,
uint16_t  canOut 
)

Add a device.

Parameters
deviceName
canIn
canOut

◆ alive()

bool Board::alive ( uint8_t  deviceNumber = 0,
bool  checkAgainIfDead = false,
bool  errorIfNotAfterCheckingAgain = false 
)

Did it respond to last ping? If not, try another ping and see if it responds.

Parameters
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0. 0xFF - any alive.
checkAgainIfDead- try another ping
errorIfNotAfterCheckingAgain- the robot will stop. Otherwise only warning displayed.
Returns
- alive or not

◆ aliveSet()

void Board::aliveSet ( bool  yesOrNo,
uint8_t  deviceNumber = 0 
)

Set aliveness

Parameters
yesOrNo
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0.

◆ count()

uint8_t Board::count ( )

Did any device respond to last ping?

Parameters
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0.

◆ deadOrAliveCount()

uint8_t Board::deadOrAliveCount ( )

Count all the devices, alive or not

Returns
- count

◆ devicesMaximumNumberInAllBoards()

uint8_t Board::devicesMaximumNumberInAllBoards ( )
inline

Maximum number of devices in all groups (boards) @raturn - number of devices

◆ devicesOnASingleBoard()

uint8_t Board::devicesOnASingleBoard ( )
inline

Number of devices in each group (board)

Returns
- number of devices

◆ devicesScan()

uint8_t Board::devicesScan ( bool  verbose = true,
uint16_t  mask = 0xFFFF 
)

Ping devices and refresh alive array

Parameters
verbose- prints statuses
mask- bitwise, 16 bits - no more than 16 devices! Bit == 1 - scan, 0 - no scan.
Returns
- alive count

◆ errorCodeLast()

uint8_t Board::errorCodeLast ( )
inline

Last error code

Returns
- last error code from all devices of this kind

◆ errorWasInDeviceNumber()

uint8_t Board::errorWasInDeviceNumber ( )
inline

Device which caused last error

Returns
- device number

◆ firmwareRequest()

void Board::firmwareRequest ( uint8_t  deviceNumber = 0xFF)

Request firmware version

Parameters
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0. 0xFF - for all devices.

Request firmware version

Parameters
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0.

◆ fps()

uint16_t Board::fps ( uint8_t  deviceNumber = 0)

Frames Per Second

Parameters
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0.
Returns
- FPS

Frames Per Second

Parameters
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0. 0xFF - for all devices.
Returns
- FPS

◆ fpsDisplay()

void Board::fpsDisplay ( )

Display FPS for all devices

◆ fpsRequest()

void Board::fpsRequest ( uint8_t  deviceNumber = 0xFF)

Request Frames Per Second

Parameters
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0. 0xFF - for all devices.

◆ id()

BoardId Board::id ( )
inline

Board class id, not each device's

◆ idChange()

void Board::idChange ( uint16_t  newDeviceNumber,
uint8_t  deviceNumber = 0 
)

Change CAN Bus id

Parameters
newDeviceNumber- new number
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0.

Change CAN Bus id

Parameters
newId- CAN Bus id
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0.

◆ info()

void Board::info ( uint8_t  deviceNumber = 0xFF)

Request information

Parameters
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0. 0xFF - for all devices.

◆ isForMe()

bool Board::isForMe ( uint32_t  canIdOut,
uint8_t  deviceNumber 
)

Is the frame addressed to this device's Arduino object?

Parameters
canIdOut- CAN Bus id.
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0.
Returns
- if true, it is

Is the frame addressed to this device's Arduino object?

Parameters
canIdOut- CAN Bus id.
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the deviceNumber, starting with 0.
Returns
- if true, it is

◆ isFromMe()

bool Board::isFromMe ( uint32_t  canIdOut,
uint8_t  deviceNumber 
)

Does the frame originate from this device's Arduino object?

Parameters
canIdOut- CAN Bus id.
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the deviceNumber, starting with 0.
Returns
- if true, it does

◆ lastMessageMs()

uint32_t Board::lastMessageMs ( uint8_t  deviceNumber = 0)
inline

Last message received

Parameters
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0.
Returns
- milliseconds

◆ messageDecode()

virtual bool Board::messageDecode ( uint32_t  canId,
uint8_t  data[8] 
)
pure virtual

Read CAN Bus message into local variables

Parameters
canId- CAN Bus id
data- 8 bytes from CAN Bus message.
Returns
- true if canId for this class

Implemented in Mrm_us1, Mrm_us, Mrm_us_b, Mrm_therm_b_can, Mrm_ref_can, Mrm_node, Mrm_lid_can_b2, Mrm_lid_can_b, Mrm_ir_finder3, Mrm_ir_finder_can, Mrm_fet_can, Mrm_col_can, Mrm_col_b, SensorBoard, MotorBoard, and Mrm_8x8a.

◆ messageDecodeCommon()

bool Board::messageDecodeCommon ( uint32_t  canId,
uint8_t  data[8],
uint8_t  deviceNumber = 0 
)
protected

Common part of message decoding

Parameters
canId- CAN Bus id
data- 8 bytes from CAN Bus message.
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0.
Returns
- command found

◆ messagePrint()

bool Board::messagePrint ( uint32_t  msgId,
uint8_t  dlc,
uint8_t data,
bool  outbound 
)

‍** Prints a frame

Prints a frame

Parameters
msgId- messageId
dlc- data length
data- payload
outbound- otherwise inbound
Returns
-if true, foundand printed

Prints a frame

Parameters
msgId- messageId
dlc- data length
data- payload
outbound- otherwise inbound
Returns
- if true, found and printed

◆ messageSend()

void Board::messageSend ( uint8_t data,
uint8_t  dlc,
uint8_t  deviceNumber = 0 
)

Send CAN Bus message

Parameters
dlc- data length
data- payload
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0.

◆ name() [1/2]

char* Board::name ( )
inline

Returns device group's name

Returns
- name

◆ name() [2/2]

char * Board::name ( uint8_t  deviceNumber)

Returns device's name

Parameters
deviceNumber- Motor's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0.
Returns
- name

Returns device's name

Parameters
deviceNumber- Device's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0.
Returns
- name

◆ notificationRequest()

void Board::notificationRequest ( uint8_t  commandRequestingNotification,
uint8_t  deviceNumber 
)

Request notification

Parameters
commandRequestingNotification
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0.

◆ oscillatorTest()

void Board::oscillatorTest ( uint8_t  deviceNumber = 0xFF)

Reserved for production

Parameters
deviceNumber- Devices's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0.

◆ reset()

void Board::reset ( uint8_t  deviceNumber = 0xFF)

Reset

Parameters
deviceNumber- Device's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0. 0xFF - all devices.

◆ start()

void Board::start ( uint8_t  deviceNumber = 0xFF,
uint8_t  measuringModeNow = 0,
uint16_t  refreshMs = 0 
)

Starts periodical CANBus messages that will be refreshing values that can be read by reading()

Parameters
deviceNumber- Device's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0. 0xFF - all devices.
measuringModeNow- Measuring mode id. Default 0.
refreshMs- gap between 2 CAN Bus messages to refresh local Arduino copy of device's data. 0 - device's default.

◆ stop()

void Board::stop ( uint8_t  deviceNumber = 0xFF)

Stops periodical CANBus messages that refresh values that can be read by reading()

Parameters
deviceNumber- Device's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0.

◆ swap()

void Board::swap ( uint8_t  deviceNumber1,
uint8_t  deviceNumber2 
)

add() assigns device numbers one after another. swap() changes the sequence later. Therefore, add(); add(); will assign number 0 to a device with the smallest CAN Bus id and 1 to the one with the next smallest. If we want to change the order so that now the device 1 is the one with the smalles CAN Bus id, we will call swap(0, 1); after the the add() commands.

Parameters
deviceNumber1- Device's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0.
deviceNumber2- Second device.

◆ test()

virtual void Board::test ( uint8_t  deviceNumber = 0xFF,
uint16_t  betweenTestsMs = 0 
)
inlinevirtual

Test

Parameters
deviceNumber- Device's ordinal number. Each call of function add() assigns a increasing number to the device, starting with 0. 0xFF - all devices.
betweenTestsMs- time in ms between 2 tests. 0 - default.

Reimplemented in Mrm_lid_can_b, and MotorBoard.


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