Example #1
0
void throw_on_fatal()
{
	loguru::set_fatal_handler([](const loguru::Message& message){
		LOG_F(INFO, "Throwing exception...");
		throw std::runtime_error(std::string(message.prefix) + message.message);
	});
	{
		LOG_SCOPE_F(INFO, "CHECK_F throw + catch");
		try {
			CHECK_F(false, "some CHECK_F message");
		} catch (std::runtime_error& e) {
			LOG_F(INFO, "CHECK_F threw this: '%s'", e.what());
		}
	}
#if LOGURU_WITH_STREAMS
	{
		LOG_SCOPE_F(INFO, "CHECK_S throw + catch");
		try {
			CHECK_S(false) << "Some CHECK_S message";
		} catch (std::runtime_error& e) {
			LOG_F(INFO, "CHECK_S threw this: '%s'", e.what());
		}
	}
	LOG_F(INFO, "Trying an uncaught exception:");
	CHECK_S(false);
#else
	CHECK_F(false);
#endif // LOGURU_WITH_STREAMS
}
void init_serial() {
  // Open the serial port.
  const char *const SERIAL_PORT_DEVICE = "/dev/ttyACM0";

  serial_port.Open(SERIAL_PORT_DEVICE);
  CHECK_S("Could not open serial port")
  //SET_AND_CHECK( SetBaudRate, BAUD_9600, "Could not set the baud rate."      );
  SET_AND_CHECK( SetCharSize, CHAR_SIZE_8, "Could not set the character size." );
  SET_AND_CHECK( SetParity  , PARITY_NONE, "Could not disable the parity."     );

  // Set the number of stop bits
  serial_port.SetNumOfStopBits(1);
  CHECK_S("Could not set the number of stop bits")
  // Turn on hardware flow control
  serial_port.SetFlowControl(LibSerial::SerialStreamBuf::FLOW_CONTROL_NONE);
  CHECK_S("Could not use hardware flow control")
}
Example #3
0
CSupervisorConfig::CSupervisorConfig()
{
  const char* configFile = "SupervisorServer.cfg";
  const char* group      = "SupervisorServer";

  if(_access(configFile, 4) != 0) {
    r3dError("can't open config file %s", configFile);
  }

  masterPort_  = r3dReadCFG_I(configFile, group, "masterPort", SBNET_MASTER_PORT);
  masterIp_    = r3dReadCFG_S(configFile, group, "masterIp", "");
  
  serverGroup_ = r3dReadCFG_I(configFile, group, "serverGroup", GBNET_REGION_Unknown);
  serverName_  = r3dReadCFG_S(configFile, group, "serverName", "");

  maxPlayers_  = r3dReadCFG_I(configFile, group, "maxPlayers", 1024);
  maxGames_    = r3dReadCFG_I(configFile, group, "maxGames", 32);
  portStart_   = r3dReadCFG_I(configFile, group, "portStart", SBNET_GAME_PORT);
  gameServerExe_ = r3dReadCFG_S(configFile, group, "gameServerExe", "WO_GameServer.exe");
  externalIpStr_ = r3dReadCFG_S(configFile, group, "externalIp", "");
  externalIpAddr_= 0;
  
  uploadLogs_ = r3dReadCFG_I(configFile, group, "uploadLogs", 0);
  
  #define CHECK_I(xx) if(xx == 0)  r3dError("missing %s value", #xx);
  #define CHECK_S(xx) if(xx == "") r3dError("missing %s value", #xx);
  CHECK_I(masterPort_);
  CHECK_S(masterIp_);

  CHECK_I(serverGroup_);
  CHECK_S(serverName_);
  CHECK_I(maxPlayers_);
  CHECK_I(maxGames_);
  CHECK_I(portStart_);
  CHECK_S(gameServerExe_);
  #undef CHECK_I
  #undef CHECK_S
  
  if(_access(gameServerExe_.c_str(), 4) != 0) {
    r3dError("can't access game server '%s'\n", gameServerExe_.c_str());
  }
  
  ParseExternalIpAddr();
  
  return;
}
Example #4
0
int NS(SendS) (NS_ARGS)
{
  SETUP_mqctx
  MQ_SRT val;
  CHECK_S(val)
  CHECK_NOARGS
  ErrorMqToTclWithCheck(MqSendS(mqctx, val));
  RETURN_TCL
}