User Tools

Site Tools



RTS2 uses its own messaging system. Messages contains name of the originator, type (debug, info, warning, error) and message text, which is unformated string. Please note that this message subsystem is intended only to pass string messages. It was not invited to pass some structured infromation from one component to the other - for such tasks are commands.

To send message from any RTS2 code, use:

logStream (type) 
  << 1234      // use it as stream, add others values if necessary
  << sendLog;  // send it

where type is one of MESSAGE_ERROR, MESSAGE_WARNING, MESSAGE_INFO, MESSAGE_DEBUG (defined in include/message.h).

So for example to send warning message, use:

   << "This is warning message, component "
   << 123454
   << " failed with error "
   << 12
   << " (external intelligence not found)"
   << sendLog;

To process messages coming from other connected devices over TCP/IP, hook on to public virtual function

  virtual void message (Rts2Message & msg)

Please see utils/rts2message.h for operations allowed on message.

To process messages which are generated inside application, you need to hook on virtual function sendMessage:

void Rts2Centrald::sendMessage (messageType_t in_messageType, const char *in_messageString)

You get message type and string to send. In order to send generated message to all connected devices, you need to call sendMessageAll. However, please note that usual infrastructure of RTS2 assumes that you send message only to centrald, and then centrald distributed message to log and to other components in the system. So you should not care about sending messages.

devel/messaging.txt · Last modified: 2008/09/06 00:00 (external edit)