ros-industrial / motoman

ROS-Industrial Motoman support (http://wiki.ros.org/motoman)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing `else` condition

ted-miller opened this issue · comments

A user has found a missing else condition. This leads to an improper response to an unknown message type.

if (receiveMsg->header.msgType == ROS_MSG_MOTO_SELECT_TOOL)

Isn't the actual consequence the else will always be taken if receiveMsg->header.msgType != ROS_MSG_MOTO_SELECT_TOOL?

So

replyMsg->body.motionReply.groupNo = -1;
replyMsg->body.motionReply.sequence = -1;
replyMsg->body.motionReply.command = receiveMsg->header.msgType;

will always be executed?

Without the "else" on line 153, all the preceeding code (line 138 to 152) is pointless because whatever is set in that code gets overwritten by line 161 and 162.

Yes. That is what I wrote.

But only if msgType != ROS_MSG_MOTO_SELECT_TOOL.

Isn't the actual consequence the else will always be taken if receiveMsg->header.msgType != ROS_MSG_MOTO_SELECT_TOOL?

Yes, you're correct. Now that I think about it some more... this might explain some wireshark captures that I've seen in the past that had unexpected sequence-id's in the reply. (I don't remember for certain. But I think I've seen this and just ignored it.)

Closing as #550 was merged (replacement PR).