CreateSession.cpp
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 
24 // -- END LICENSE BLOCK ------------------------------------------------
25 
26 //----------------------------------------------------------------------
33 //----------------------------------------------------------------------
34 
36 
39 
40 namespace sick {
41 namespace cola2 {
42 
44  : Command(session, 0x4F, 0x58) // see cola2 manual 0x4F = O, 0x58 = X
45 {
46  m_writer_ptr = std::make_shared<sick::data_processing::ReadWriteHelper>();
47 }
48 
50 {
51  uint8_t* data_ptr = prepareTelegramAndGetDataPtr(telegram);
53  writeClientIdToDataPtr(data_ptr);
54 }
55 
58 {
59  uint16_t prevSize = telegram.size();
60  telegram.resize(prevSize + 5);
61  return telegram.data() + prevSize;
62 }
63 
65 {
66  return true;
67 }
68 
70 {
71  if ((getCommandType() == 'O' && getCommandMode() == 'A') ||
72  (getCommandType() == 0x4F && getCommandMode() == 0x41))
73  {
75  ROS_INFO("Successfully opened Cola2 session with sessionID: %u", m_session.getSessionID());
76  return true;
77  }
78  else
79  {
80  ROS_WARN("Could not open Cola2 session");
81  return false;
82  }
83 }
84 
85 void CreateSession::writeHeartbeatTimeoutToDataPtr(uint8_t*& data_ptr) const
86 {
87  uint8_t heartBeatTimeoutSeconds = 60;
88  m_writer_ptr->writeuint8_tBigEndian(data_ptr, heartBeatTimeoutSeconds, 0);
89 }
90 
91 void CreateSession::writeClientIdToDataPtr(uint8_t*& data_ptr) const
92 {
93  uint32_t clientID = 1; // can be any random number
94  m_writer_ptr->writeuint32_tBigEndian(data_ptr, clientID, 1);
95 }
96 
97 } // namespace cola2
98 } // namespace sick
bool processReply()
Processes the return from the sensor. Checks if the request was successful.
std::shared_ptr< sick::data_processing::ReadWriteHelper > m_writer_ptr
Definition: CreateSession.h:79
uint8_t getCommandType() const
Returns the command type.
Definition: Command.cpp:82
Base class for commands. Defines the base interface and does the common tasks.
Definition: Command.h:61
#define ROS_WARN(...)
uint32_t getSessionID() const
Returns the current session ID.
Definition: Command.cpp:102
void addTelegramData(sick::datastructure::PacketBuffer::VectorBuffer &telegram) const
Adds the data to the telegram.
#define ROS_INFO(...)
void writeClientIdToDataPtr(uint8_t *&data_ptr) const
sick::cola2::Cola2Session & m_session
Definition: Command.h:191
uint8_t getCommandMode() const
Returns the command mode.
Definition: Command.cpp:92
void setSessionID(const uint32_t &session_id)
Sets the current session ID.
uint8_t * prepareTelegramAndGetDataPtr(sick::datastructure::PacketBuffer::VectorBuffer &telegram) const
bool canBeExecutedWithoutSessionID() const
Returns true since creating a new session is possible without a session ID.
void writeHeartbeatTimeoutToDataPtr(uint8_t *&data_ptr) const
uint32_t getSessionID() const
Returns the current session ID.
std::vector< uint8_t > VectorBuffer
Typedef for a vector buffer, to sort the incoming packets.
Definition: PacketBuffer.h:71
Establishes a cola2 session with a sensor and enables execution of commands in this session...
Definition: Cola2Session.h:72
CreateSession(Cola2Session &session)
Constructor to create a new command to set up a new session.


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Thu May 9 2019 02:41:08