1
0
mirror of https://gitlab.com/obbart/universal_robots_ros_driver.git synced 2026-04-10 01:50:46 +02:00

Newline parity between printf and ros logging

This commit is contained in:
Simon Rasmussen
2017-02-08 10:32:01 +01:00
parent 113b32d5af
commit e523a5d466
4 changed files with 15 additions and 15 deletions

View File

@@ -12,10 +12,10 @@
#else
#define LOG_DEBUG(format, ...) printf("DEBUG: " format, ##__VA_ARGS__)
#define LOG_WARN(format, ...) printf("WARNING: " format, ##__VA_ARGS__)
#define LOG_INFO(format, ...) printf("INFO: " format, ##__VA_ARGS__)
#define LOG_ERROR(format, ...) printf("ERROR: " format, ##__VA_ARGS__)
#define LOG_FATAL(format, ...) printf("FATAL: " format, ##__VA_ARGS__)
#define LOG_DEBUG(format, ...) printf("DEBUG: " format "\n", ##__VA_ARGS__)
#define LOG_WARN(format, ...) printf("WARNING: " format "\n", ##__VA_ARGS__)
#define LOG_INFO(format, ...) printf("INFO: " format "\n", ##__VA_ARGS__)
#define LOG_ERROR(format, ...) printf("ERROR: " format "\n", ##__VA_ARGS__)
#define LOG_FATAL(format, ...) printf("FATAL: " format "\n", ##__VA_ARGS__)
#endif

View File

@@ -29,7 +29,7 @@ std::unique_ptr<Packet> URProducer::try_get() {
ssize_t len = _stream.receive(pos, size);
if(len < 1) {
LOG_DEBUG("Read nothing from stream\n");
LOG_DEBUG("Read nothing from stream");
return std::unique_ptr<Packet>(nullptr);
}
@@ -40,13 +40,13 @@ std::unique_ptr<Packet> URProducer::try_get() {
packet_size = bp.peek<int32_t>();
//TODO: check other wrong packet sizes?
if(packet_size > sizeof(buf)) {
LOG_ERROR("A packet with 'len' larger than buffer was received, discarding...\n");
LOG_ERROR("A packet with 'len' (%d) larger than buffer was received, discarding...", packet_size);
return std::unique_ptr<Packet>(nullptr);
}
}
if(total < packet_size){
LOG_DEBUG("Partial packet recieved\n");
LOG_DEBUG("Partial packet recieved");
continue;
}
return std::move(_parser.parse(bp));

View File

@@ -6,13 +6,13 @@ bool RobotState::parse_with(BinParser &bp) {
//continue as long as there are bytes to read
while(bp.check_size(sizeof(uint8_t))) {
if(!bp.check_size(sizeof(uint32_t))){
LOG_ERROR("Failed to read sub-package length, there's likely a parsing error\n");
LOG_ERROR("Failed to read sub-package length, there's likely a parsing error");
return false;
}
uint32_t sub_size = bp.peek<uint32_t>();
if(!bp.check_size(static_cast<size_t>(sub_size))) {
LOG_WARN("Invalid sub-package size of %" PRIu32 " received!\n", sub_size);
LOG_WARN("Invalid sub-package size of %" PRIu32 " received!", sub_size);
return false;
}
@@ -48,7 +48,7 @@ bool RobotState_V1_6__7::parse_package(BinParser &bp) {
//TODO
break;
default:
LOG_ERROR("Invalid package type parsed: %" PRIu8 "\n", type);
LOG_ERROR("Invalid package type parsed: %" PRIu8 "", type);
return false;
}

View File

@@ -9,7 +9,7 @@ bool URStream::connect() {
if(_initialized)
return false;
LOG_INFO("Connecting to UR @ %s:%d\n", _host.c_str(), _port);
LOG_INFO("Connecting to UR @ %s:%d", _host.c_str(), _port);
//gethostbyname() is deprecated so use getadderinfo() as described in:
//http://www.beej.us/guide/bgnet/output/html/multipage/syscalls.html#getaddrinfo
@@ -23,7 +23,7 @@ bool URStream::connect() {
hints.ai_flags = AI_PASSIVE;
if(getaddrinfo(_host.c_str(), service.c_str(), &hints, &result) != 0) {
LOG_ERROR("Failed to get host name\n");
LOG_ERROR("Failed to get host name");
return false;
}
@@ -45,13 +45,13 @@ bool URStream::connect() {
int flag = 1;
setsockopt(_socket_fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag));
_initialized = true;
LOG_INFO("Connection successfully established\n");
LOG_INFO("Connection successfully established");
break;
}
freeaddrinfo(result);
if(!_initialized)
LOG_ERROR("Connection failed\n");
LOG_ERROR("Connection failed");
return _initialized;
}