rosserial embedded tcp custom port fail

asked 2018-12-14 04:21:49 -0500

krl101 gravatar image

Hi there!

i just played around with rosserial and an tcp connection to my tiny linux board. Going through the tutorial is quiet easy. But if i try to run my node on a custom port it gives me:

Connecting to TCP server at 192.168.1.5}L�����ǐHu+�T���h俋�AH}L������H>T:11420....

code snippet:

....
char *rosSrvrIp = "192.168.1.5:11420";
....
nh.initNode(rosSrvrIp);

Diggin into ros_lib/embedded_linux_comms.c i found this else-Path for a custom port: (somewhere around line 128)

else
{
    tcpPortNum = strtol(tcpPortNumString + 1, NULL, 10);
    strncpy(ip, portName, tcpPortNumString - portName);
}

printf("Connecting to TCP server at %s:%ld....\n", ip, tcpPortNum);

I have added following line after the strncpy-line:

ip[tcpPortNumString - portName] = '\0';   // set  null-terminator

An now it works for me

Question: Have i missed something obvious or does it belong to my compiler (gcc 5.3) ?

edit retag flag offensive close merge delete

Comments

I would recommend to report this over at ros-drivers/rosserial/issues instead of opening a Q&A here: it's an issue, not a question we can answer.

Following up: seeing as you have a candidate solution, I would recommend submitted a PR as well.

gvdhoorn gravatar image gvdhoorn  ( 2018-12-14 08:37:17 -0500 )edit