mirror of
https://gitlab.com/obbart/universal_robots_ros_driver.git
synced 2026-04-10 10:00:48 +02:00
Newline parity between printf and ros logging
This commit is contained in:
@@ -12,10 +12,10 @@
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define LOG_DEBUG(format, ...) printf("DEBUG: " format, ##__VA_ARGS__)
|
#define LOG_DEBUG(format, ...) printf("DEBUG: " format "\n", ##__VA_ARGS__)
|
||||||
#define LOG_WARN(format, ...) printf("WARNING: " format, ##__VA_ARGS__)
|
#define LOG_WARN(format, ...) printf("WARNING: " format "\n", ##__VA_ARGS__)
|
||||||
#define LOG_INFO(format, ...) printf("INFO: " format, ##__VA_ARGS__)
|
#define LOG_INFO(format, ...) printf("INFO: " format "\n", ##__VA_ARGS__)
|
||||||
#define LOG_ERROR(format, ...) printf("ERROR: " format, ##__VA_ARGS__)
|
#define LOG_ERROR(format, ...) printf("ERROR: " format "\n", ##__VA_ARGS__)
|
||||||
#define LOG_FATAL(format, ...) printf("FATAL: " format, ##__VA_ARGS__)
|
#define LOG_FATAL(format, ...) printf("FATAL: " format "\n", ##__VA_ARGS__)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -29,7 +29,7 @@ std::unique_ptr<Packet> URProducer::try_get() {
|
|||||||
ssize_t len = _stream.receive(pos, size);
|
ssize_t len = _stream.receive(pos, size);
|
||||||
|
|
||||||
if(len < 1) {
|
if(len < 1) {
|
||||||
LOG_DEBUG("Read nothing from stream\n");
|
LOG_DEBUG("Read nothing from stream");
|
||||||
return std::unique_ptr<Packet>(nullptr);
|
return std::unique_ptr<Packet>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,13 +40,13 @@ std::unique_ptr<Packet> URProducer::try_get() {
|
|||||||
packet_size = bp.peek<int32_t>();
|
packet_size = bp.peek<int32_t>();
|
||||||
//TODO: check other wrong packet sizes?
|
//TODO: check other wrong packet sizes?
|
||||||
if(packet_size > sizeof(buf)) {
|
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);
|
return std::unique_ptr<Packet>(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(total < packet_size){
|
if(total < packet_size){
|
||||||
LOG_DEBUG("Partial packet recieved\n");
|
LOG_DEBUG("Partial packet recieved");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return std::move(_parser.parse(bp));
|
return std::move(_parser.parse(bp));
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ bool RobotState::parse_with(BinParser &bp) {
|
|||||||
//continue as long as there are bytes to read
|
//continue as long as there are bytes to read
|
||||||
while(bp.check_size(sizeof(uint8_t))) {
|
while(bp.check_size(sizeof(uint8_t))) {
|
||||||
if(!bp.check_size(sizeof(uint32_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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t sub_size = bp.peek<uint32_t>();
|
uint32_t sub_size = bp.peek<uint32_t>();
|
||||||
if(!bp.check_size(static_cast<size_t>(sub_size))) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ bool RobotState_V1_6__7::parse_package(BinParser &bp) {
|
|||||||
//TODO
|
//TODO
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_ERROR("Invalid package type parsed: %" PRIu8 "\n", type);
|
LOG_ERROR("Invalid package type parsed: %" PRIu8 "", type);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ bool URStream::connect() {
|
|||||||
if(_initialized)
|
if(_initialized)
|
||||||
return false;
|
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:
|
//gethostbyname() is deprecated so use getadderinfo() as described in:
|
||||||
//http://www.beej.us/guide/bgnet/output/html/multipage/syscalls.html#getaddrinfo
|
//http://www.beej.us/guide/bgnet/output/html/multipage/syscalls.html#getaddrinfo
|
||||||
@@ -23,7 +23,7 @@ bool URStream::connect() {
|
|||||||
hints.ai_flags = AI_PASSIVE;
|
hints.ai_flags = AI_PASSIVE;
|
||||||
|
|
||||||
if(getaddrinfo(_host.c_str(), service.c_str(), &hints, &result) != 0) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,13 +45,13 @@ bool URStream::connect() {
|
|||||||
int flag = 1;
|
int flag = 1;
|
||||||
setsockopt(_socket_fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag));
|
setsockopt(_socket_fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag));
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
LOG_INFO("Connection successfully established\n");
|
LOG_INFO("Connection successfully established");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
freeaddrinfo(result);
|
freeaddrinfo(result);
|
||||||
if(!_initialized)
|
if(!_initialized)
|
||||||
LOG_ERROR("Connection failed\n");
|
LOG_ERROR("Connection failed");
|
||||||
|
|
||||||
return _initialized;
|
return _initialized;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user