Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Point Message Unpack() yields Bus Error #176

Open
Kygandomi opened this issue Mar 16, 2018 · 3 comments
Open

Point Message Unpack() yields Bus Error #176

Kygandomi opened this issue Mar 16, 2018 · 3 comments

Comments

@Kygandomi
Copy link

Hello,

We are running an OpenIGTLink Server on an sbRIO-9651 module running real time linux and we are running into a bus error when a point message is sent from 3D Slicer (or other external OpenIGTLink clients).

The server has been able to reliably receive transform data and other IGTLink data types such as String and Status, but point message throws a bus error specifically when the Unpack() method is called in the following code. Is there something I am missing ?

Eigen::Vector3d OpenIGTLink::ReceivePoint(igtl::Socket * socket, igtl::MessageHeader * header) {
	// Create a message buffer to receive transform data
	igtl::PointMessage::Pointer pointMsg;
	pointMsg = igtl::PointMessage::New();
	pointMsg->SetMessageHeader(header);
	pointMsg->AllocatePack();

	socket->Receive(pointMsg->GetPackBodyPointer(), pointMsg->GetPackBodySize());

	int c = pointMsg->Unpack(); // This line throws a Bus Error

	Eigen::Vector3d pointData(-1, -1, -1);
	if (c & igtl::MessageHeader::UNPACK_BODY) {
		// Retrieve the point data
		igtlFloat32 x, y, z;
		igtl::PointElement::Pointer point;
		point = igtl::PointElement::New();
		pointMsg->GetPointElement(0, point);
		point->GetPosition(x, y, z);
		pointData(0) = x;
		pointData(1) = y;
		pointData(2) = z;
	}

	return pointData;
}
@adamrankin
Copy link
Contributor

This is probably unrelated to your bug, but I highly recommend you use the igtl::MessageFactory for creating messages.

This ensures messages are created properly and ready for use. This may circumvent your bug.

@Kygandomi
Copy link
Author

@adamrankin That sounds like a good idea to try.
Do you know where I can find an example of how to setup igtl::MessageFactory to receive data?

@adamrankin
Copy link
Contributor

Some code excerpted from
https://github.com/IGSIO/UWPOpenIGTLink/blob/master/UWPOpenIGTLink/Content/IGTClient.cxx#L858

m_igtlMessageFactory = igtl::MessageFactory::New();
...
auto headerMsg = m_igtlMessageFactory->CreateHeaderMessage(IGTL_HEADER_VERSION_1);
...
numOfBytesReceived = SocketReceive(headerMsg->GetBufferPointer(), headerMsg->GetBufferSize());
...
int c = headerMsg->Unpack(1);
...
igtl::MessageBase::Pointer bodyMsg = nullptr;
try
{
  bodyMsg = m_igtlMessageFactory->CreateReceiveMessage(headerMsg);
}
catch (const std::exception&)
{
...
}
...
if (typeid(*bodyMsg) == typeid(igtl::TrackedFrameMessage))
{

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants