rosserial
rosserial copied to clipboard
Issue Porting to RISCV
Hello,
I'm trying to port rosserial to riscv. I'm using riscv32-unknown-elf-g++
The nodehandle instance fails to assign itself to the pointer in the publisher instance. I've modified the function as follows to demonstrate this:
bool advertise(Publisher & p)
{
for (int i = 0; i < MAX_PUBLISHERS; i++)
{
if (publishers[i] == 0) // empty slot
{
publishers[i] = &p;
p.id_ = i + 100 + MAX_SUBSCRIBERS;
p.nh_ = this;
if (p.nh_ != nullptr){
return true;
} else {
return false;
}
}
}
return false;
}
When testing with the following code based on the arduino example:
#include <ros.h>
#include <std_msgs/String.h>
ros::NodeHandle nh;
std_msgs::String str_msg;
ros::Publisher chatter("chatter", &str_msg);
char hello[13] = "hello world!";
void setup()
{
nh.initNode();
while (!nh.advertise(chatter)) {
print("Failed to init publisher!\n");
}
}
void main()
{
setup();
while (1) {
str_msg.data = hello;
chatter.publish(&str_msg);
nh.spinOnce();
}
}
We get stuck in while (!nh.advertise(chatter))
I'm guessing this is an issue with the compiler, but I thought I'd check here too.