Set BREAK: on with script

Hello,
In a serial session, I'd like to Set BREAK: on for a specific duration with a jancy script. Is this possible? I can toggle manually by clicking the purple BRK button.

4c4f3111-1dd8-4183-ab96-6dd0a492fa75-image.png

Thanks,
Stuart

Yes, it's possible; you can control all parameters of a serial port (including the break condition) from your script via the "dispatch" object g_session:

void main() {
	connect();

	// configure the port
	g_session.m_baudRate = 38400;
	g_session.m_dataBits = 8;
	// ...

	for (;;) {
		g_session.m_break = !g_session.m_break; // toggle break condition
		sys.sleep(1000);
	}
}

5d3eea6d-fbf3-4e12-8a59-0f863d5cb32f-image.png

Note: there's a typo in the serial dispatch script in the latest official release ioninja-5.3.1 (will be fixed in the very next service release). In the meantime, for the script above to work, please open to scripts/plugins/Serial/SerialDispatch.jnc and replace:

SerialDispatchCode.GetBreak -> SerialDispatchCode.GetBreakCondition
and
SerialDispatchCode.SetBreak -> SerialDispatchCode.SetBreakCondition

Let me know if this works for you.

Hi Vladimir,
Thank you, that worked well.

I feel like I should have been able to search for that in the IONinja documentation. Keywords "session" and "break" both don't yield relevant information for me.

Thanks,
Stuart

Documentation in general needs some serious improvements, that's true 🙂 Working on that.

In the meantime, we try our best to provide developer-level support and assistance -- here or via the support email.

It seems that in v5.3.2 this should be:
g_session.m_breakCondition