<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Reading Values of Properties of Serial Port in Script]]></title><description><![CDATA[<p dir="auto">Hi.<br />
Is there a possibility that we can be able to read the values of properties in the script? For example, if you have a serial session, I would like to be able to read, say "RX total bytes"; even if I be able to read this on a "onLogRecord" event, it would be fine.<br />
Thanks in advance for your time.</p>
]]></description><link>http://64.23.185.212/forum/topic/10/reading-values-of-properties-of-serial-port-in-script</link><generator>RSS for Node</generator><lastBuildDate>Thu, 12 Mar 2026 08:01:50 GMT</lastBuildDate><atom:link href="http://64.23.185.212/forum/topic/10.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Aug 2021 05:39:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Reading Values of Properties of Serial Port in Script on Fri, 01 Oct 2021 03:05:38 GMT]]></title><description><![CDATA[<p dir="auto">Sure. The basic idea is to listen for new log records and update your variables holding the state of RTS/CTS lines accordingly. You would need <code>SerialLogRecordCode.PortOpened</code> to get the initial line state on port open, <code>SerialLogRecordCode.RtsChanged</code> to track RTS changes, and <code>SerialLogRecordCode.StatusLineChanged</code> to track CTS changes.</p>
<p dir="auto">In the sample below, I simply print the states of those lines to the session system log (Menu -&gt; View -&gt; System Log). Feel free to change it according to the requirements of your script.</p>
<pre><code>import "io_base.jncx"
import "io_Serial.jnc"
import "Serial/SerialLogRecordCode.jnc"

bool g_rts;
bool g_cts;

void onLogRecord(
	uint64_t timestamp,
	uint64_t recordCode,
	void const* p,
	size_t size
) {
	switch (recordCode) {
	case SerialLogRecordCode.PortOpened:
		SerialOpenParams const* params = (SerialOpenParams const*)p;
		g_rts = params.m_rts;
		g_cts = (params.m_statusLines &amp; io.SerialStatusLines.Cts) != 0;
		printf("Initial RTS: %d CTS: %d\n", g_rts, g_cts);
		break;

	case SerialLogRecordCode.RtsChanged:
		g_rts = *(bool const*) p;
		printf("RTS changed: %d\n", g_rts);
		break;

	case SerialLogRecordCode.StatusLineChanged:
		SerialStatusLineChangedParams const* params = (SerialStatusLineChangedParams const*)p;
		if (params.m_mask &amp; io.SerialStatusLines.Cts) {
			g_cts = (params.m_lines &amp; io.SerialStatusLines.Cts) != 0;
			printf("CTS changed: %d\n", g_cts);
		}
		
		break;
	}
}
</code></pre>
]]></description><link>http://64.23.185.212/forum/post/48</link><guid isPermaLink="true">http://64.23.185.212/forum/post/48</guid><dc:creator><![CDATA[Vladimir]]></dc:creator><pubDate>Fri, 01 Oct 2021 03:05:38 GMT</pubDate></item><item><title><![CDATA[Reply to Reading Values of Properties of Serial Port in Script on Wed, 29 Sep 2021 02:45:58 GMT]]></title><description><![CDATA[<p dir="auto">For example, can you please provide an example how to read the status of RTS/CTS for example from the script either in main() or onLogRecord?</p>
]]></description><link>http://64.23.185.212/forum/post/44</link><guid isPermaLink="true">http://64.23.185.212/forum/post/44</guid><dc:creator><![CDATA[Mohammad]]></dc:creator><pubDate>Wed, 29 Sep 2021 02:45:58 GMT</pubDate></item><item><title><![CDATA[Reply to Reading Values of Properties of Serial Port in Script on Fri, 06 Aug 2021 09:59:06 GMT]]></title><description><![CDATA[<p dir="auto">Maybe, a concrete example of what you try to get? Most likely, it's doable from <code>onLogRecord</code>...</p>
]]></description><link>http://64.23.185.212/forum/post/24</link><guid isPermaLink="true">http://64.23.185.212/forum/post/24</guid><dc:creator><![CDATA[Vladimir]]></dc:creator><pubDate>Fri, 06 Aug 2021 09:59:06 GMT</pubDate></item><item><title><![CDATA[Reply to Reading Values of Properties of Serial Port in Script on Fri, 06 Aug 2021 09:57:26 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto">Well, in building test benches, keeping an eye on things like total bytes, throughput and status of lines like DSR/DTR and even RTS and CTS (when they are used as IO) is important.</p>
</blockquote>
<p dir="auto">Right. The proper way of getting notifications about all of these events is through the <code>onLogRecord</code> callback. Every time a new record appears in the log, your <code>onLogRecord</code> is called; you analyze the <code>recordCode</code> and react accordingly.</p>
<p dir="auto">I still don't see the benefit of reading these values from the "Information" pane -- they are updated on-timer and are generally not in-sync with your <code>onLogRecordCode</code>.</p>
<blockquote>
<p dir="auto">Although I don't need information like CRC things, but I assume for other use cases accessing that can be useful.</p>
</blockquote>
<p dir="auto">Checksums in the "Information" pane are updated when a user <em>manually</em> selects ranges in the log. In other words, they are updated based on <em>UI events</em>, and as such, they can't be relied upon from <em>scripts</em>. If checksums are important for your script, you must calculate them in your <code>onLogRecord</code> (e.g., using helper functions in files like <code>scripts/common/crc16.jnc</code>).</p>
]]></description><link>http://64.23.185.212/forum/post/23</link><guid isPermaLink="true">http://64.23.185.212/forum/post/23</guid><dc:creator><![CDATA[Vladimir]]></dc:creator><pubDate>Fri, 06 Aug 2021 09:57:26 GMT</pubDate></item><item><title><![CDATA[Reply to Reading Values of Properties of Serial Port in Script on Fri, 06 Aug 2021 04:17:09 GMT]]></title><description><![CDATA[<p dir="auto">Well, in building test benches, keeping an eye on things like total bytes, throughput and status of lines like DSR/DTR and even RTS and CTS (when they are used as IO) is important. Although I don't need information like CRC things, but I assume for other use cases accessing that can be useful.</p>
]]></description><link>http://64.23.185.212/forum/post/22</link><guid isPermaLink="true">http://64.23.185.212/forum/post/22</guid><dc:creator><![CDATA[Mohammad]]></dc:creator><pubDate>Fri, 06 Aug 2021 04:17:09 GMT</pubDate></item><item><title><![CDATA[Reply to Reading Values of Properties of Serial Port in Script on Thu, 05 Aug 2021 01:14:42 GMT]]></title><description><![CDATA[<p dir="auto">You mean, to read values from the "Information" pane? Yes, that is technically possible, but could you give a use case that would require such a feature? There might be a better way to achieve the same...</p>
]]></description><link>http://64.23.185.212/forum/post/21</link><guid isPermaLink="true">http://64.23.185.212/forum/post/21</guid><dc:creator><![CDATA[Vladimir]]></dc:creator><pubDate>Thu, 05 Aug 2021 01:14:42 GMT</pubDate></item></channel></rss>