antipole2/JavaScript_pi

Receiving JSON message from OpenDraw crashes OpenCPN

Closed this issue · 1 comments

When a JSON message is received from OpenDraw, it crashes OpenCPN.
No problem with other messages far as is known.

What is different about OpenDraw? Might they be extra long? Buffer overrun?

Following script demonstrates

odMessage = "OCPN_DRAW_PI";
message = {
	Source: "JAVASCRIPT_PI",
	Type: "Request",
	Msg: "FindPointInAnyBoundary",
	MsgId: "distance",
	lat: 50.5,
	lon: -2.2,
	BoundaryType: "Exclusion",
	BoundaryState: "Active"
	};

OCPNonMessageName(receive, "OCPN_WPT_ACTIVATED");

OCPNsendMessage(odMessage, JSON.stringify(message));

function receive(result){
	printOrange(result, "\n");
	}

Turns out OD invokes SetMessage directly without going through the normal messaging process.
This was causing re-entry to the running byte code.

SendMessage to OCPN_DRAW_PI now shows an error.