<?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[ASCII file data source, reading linux log file events]]></title><description><![CDATA[<p dir="auto">Hi</p>
<p dir="auto">I want to read a GPIO pin on a Raspberry Pi, but I didn't have any luck trying to read the device file (<a href="http://infiniteautomation.com/forum/topic/1891/ascii-file-source-read-binary-value-in-file" rel="nofollow ugc">as per this this thread</a>) so I thought I would try it another way.</p>
<p dir="auto">I wrote a small script in python that reads the GPIO pin and then writes any events to a log file.<br />
The format of my log file is like this:</p>
<pre><code>2015-05-24 19:31:03,705 INFO CLOSED
2015-05-24 19:29:48,691 INFO OPEN
2015-05-24 19:29:52,053 INFO CLOSED
2015-05-24 19:29:53,094 INFO OPEN
</code></pre>
<p dir="auto">Is there any way to get the ASCII file data source to read the 'CLOSED' and 'OPEN' events plus the timestamp?<br />
I have tried, I think, dozens of combinations of regex expressions!</p>
<p dir="auto">Cheers<br />
Jeremy</p>
]]></description><link>https://forum.mango-os.com/topic/1894/ascii-file-data-source-reading-linux-log-file-events</link><generator>RSS for Node</generator><lastBuildDate>Mon, 15 Jun 2026 08:04:57 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/1894.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 25 May 2015 02:39:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ASCII file data source, reading linux log file events on Tue, 26 May 2015 03:37:15 GMT]]></title><description><![CDATA[<p dir="auto">I'm not sure as I've never used it this way but it probably depends on how you have the point set to log.  If you have it set to log on change I would expect you would not get duplicates.  You might see duplicates in the cache but only the change should be logged to the database.</p>
]]></description><link>https://forum.mango-os.com/post/10036</link><guid isPermaLink="true">https://forum.mango-os.com/post/10036</guid><dc:creator><![CDATA[JoelHaggar]]></dc:creator><pubDate>Tue, 26 May 2015 03:37:15 GMT</pubDate></item><item><title><![CDATA[Reply to ASCII file data source, reading linux log file events on Tue, 26 May 2015 02:58:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joelhaggar" aria-label="Profile: JoelHaggar">@<bdi>JoelHaggar</bdi></a> said:</p>
<blockquote>
<p dir="auto">This data source will not bring in history and will only look for a current value.  If you could get your data into a csv format you could use the dataFile data source to import historical data.</p>
<p dir="auto">If you do not have the NoSQL database then it's possible to have duplicate time stamps which is what you are seeing here.</p>
</blockquote>
<p dir="auto">Hey Joel,</p>
<p dir="auto">If I modify my python script so that the logfile is just overwriting <strong>the same single line</strong> <em>(rather than amending a new line to the log)</em>, with the current timestamped state, would that give me the results that I expect? Or would I still get duplicate entries?</p>
<p dir="auto">Cheers<br />
Jeremy</p>
]]></description><link>https://forum.mango-os.com/post/10035</link><guid isPermaLink="true">https://forum.mango-os.com/post/10035</guid><dc:creator><![CDATA[jeremyh]]></dc:creator><pubDate>Tue, 26 May 2015 02:58:45 GMT</pubDate></item><item><title><![CDATA[Reply to ASCII file data source, reading linux log file events on Mon, 25 May 2015 15:54:15 GMT]]></title><description><![CDATA[<p dir="auto">This data source will not bring in history and will only look for a current value.  If you could get your data into a csv format you could use the dataFile data source to import historical data.</p>
<p dir="auto">If you do not have the NoSQL database then it's possible to have duplicate time stamps which is what you are seeing here.</p>
]]></description><link>https://forum.mango-os.com/post/10030</link><guid isPermaLink="true">https://forum.mango-os.com/post/10030</guid><dc:creator><![CDATA[JoelHaggar]]></dc:creator><pubDate>Mon, 25 May 2015 15:54:15 GMT</pubDate></item><item><title><![CDATA[Reply to ASCII file data source, reading linux log file events on Mon, 25 May 2015 09:37:15 GMT]]></title><description><![CDATA[<p dir="auto">OK, I appear to have gotten Mango reading the file and timestamp correctly.. It seems I just needed to select 'alphanumeric' not 'multistate'. However there is now an issue with repeated entries.</p>
<p dir="auto">I'm not sure whether this is the expected behaviour of the module or not. If not I may be able to modify my script/log to suit.. At the moment it appends a new line at the bottom of the log every time the GPIO pin has a rising or falling edge.</p>
<p dir="auto">When I create two lines in my log file like this:</p>
<p dir="auto"><img src="https://camo.nodebb.org/676cdc1e45ab0a0c1bcd2de7b9cc5846da68c5da?url=https%3A%2F%2Fi.imgur.com%2FrIIxmSf.png" alt="Screen Shot 2015-05-25 at 4.22.48 pm.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Mango captures it like this:</p>
<p dir="auto"><img src="https://camo.nodebb.org/272537e58e201432767ecb90f82c5f679e4e9b8c?url=https%3A%2F%2Fi.imgur.com%2FEPMo3Zs.png" alt="Screen Shot 2015-05-25 at 4.22.35 pm.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">'Justnow' and 'verysoon' are dummy values I made up. The timestamps are in the past and future respectively.</p>
<p dir="auto">What I want is for Mango to just add history point for every line in the log file. Then Mango can read the file every minute and if my sensor was tripped 4 times, I'll get those 4 timestamped events. In other words, the Mango point history should have the same number of rows as my logfile, with the same timestamped values.</p>
<p dir="auto">Is this possible or am I way off from what the module is designed to do?</p>
]]></description><link>https://forum.mango-os.com/post/10028</link><guid isPermaLink="true">https://forum.mango-os.com/post/10028</guid><dc:creator><![CDATA[jeremyh]]></dc:creator><pubDate>Mon, 25 May 2015 09:37:15 GMT</pubDate></item><item><title><![CDATA[Reply to ASCII file data source, reading linux log file events on Mon, 25 May 2015 04:57:35 GMT]]></title><description><![CDATA[<p dir="auto">I had a look at the MangoES regex examples. Using <a href="http://regexr.com" rel="nofollow ugc">regexr.com</a> to test, I copied the regex expression format and ran it against my logfile:</p>
<p dir="auto"><img src="https://camo.nodebb.org/027bdbea4ea1f6b6561967948cc6fd3177a25264?url=https%3A%2F%2Fi.imgur.com%2FIwKI0xS.png" alt="Screen Shot 2015-05-25 at 12.40.50 pm.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Capture group 1 appears to contain 'INFO' and capture group 2 appears to contain the value ('OPEN').<br />
I set up my point as follows:</p>
<p dir="auto"><img src="https://camo.nodebb.org/169fc43f41dc2cbc55bc0d7ade80005f76007ef7?url=https%3A%2F%2Fi.imgur.com%2FsA0f5B3.png" alt="Screen Shot 2015-05-25 at 12.41.22 pm.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">This regex does capture the timestamp along with the point identifier and point value:</p>
<p dir="auto"><img src="https://camo.nodebb.org/b22573e37f800273aa4ccfe7bc47dcf71fc85a49?url=https%3A%2F%2Fi.imgur.com%2FfMKce7K.png" alt="Screen Shot 2015-05-25 at 12.54.17 pm.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">But even with my point setup as follows, I still get 'active source point has no value:</p>
<p dir="auto"><img src="https://camo.nodebb.org/c2a1644bbeb839770f6b04697852609cdef52c97?url=https%3A%2F%2Fi.imgur.com%2F280QM3O.png" alt="Screen Shot 2015-05-25 at 12.54.36 pm.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">At this point I believe I'm doing everything correctly, so I'm a bit stuck.<br />
If anyone else is able to take a crack at this I'd really appreciate the help!</p>
]]></description><link>https://forum.mango-os.com/post/10027</link><guid isPermaLink="true">https://forum.mango-os.com/post/10027</guid><dc:creator><![CDATA[jeremyh]]></dc:creator><pubDate>Mon, 25 May 2015 04:57:35 GMT</pubDate></item><item><title><![CDATA[Reply to ASCII file data source, reading linux log file events on Mon, 25 May 2015 03:30:20 GMT]]></title><description><![CDATA[<p dir="auto">Hey Joel</p>
<p dir="auto">Those links 404 for me. I'll have a look in one our our MangoES units though.</p>
<p dir="auto">Regex does my head in.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joelhaggar" aria-label="Profile: JoelHaggar">@<bdi>JoelHaggar</bdi></a> said:</p>
<blockquote>
<p dir="auto">Let me know if that helps.  Awhile ago Terry was telling me it would be fairly easy to make a data source to talk to the Raspberry Pi GPIO as there is an existing java library we could use.  We might have to do that one of these days.</p>
</blockquote>
<p dir="auto">That would be really cool. I have a rPi at home that I am playing around with for various automation tasks.</p>
<p dir="auto">FWIW you can also access the GPIO as a linux device/file. Not sure about setting outputs or reading ADC (haven't looked into it) but to read an input (pin 25) you just initialise it like this:</p>
<pre><code>pi@rpi $ echo 25 &gt; /sys/class/gpio/export
</code></pre>
<p dir="auto">Then when you access this file:</p>
<pre><code>/sys/class/gpio/gpio25/value
</code></pre>
<p dir="auto">That file contains a single bit, either 0 or 1.</p>
]]></description><link>https://forum.mango-os.com/post/10022</link><guid isPermaLink="true">https://forum.mango-os.com/post/10022</guid><dc:creator><![CDATA[jeremyh]]></dc:creator><pubDate>Mon, 25 May 2015 03:30:20 GMT</pubDate></item><item><title><![CDATA[Reply to ASCII file data source, reading linux log file events on Mon, 25 May 2015 03:21:08 GMT]]></title><description><![CDATA[<p dir="auto">I'm really not good with Regex but maybe one of our developers can answer next week.  Here is an example file and data source that we use on the MangoES which should help. <a href="/uploads/files/1432523914738-systeminfo.txt">systemInfo.txt</a></p>
<p dir="auto">ASCII Data Source example JSON: <a href="/uploads/files/1432523974241-system-info-data-source.json">System Info Data Source.json</a></p>
<p dir="auto">Let me know if that helps.  Awhile ago Terry was telling me it would be fairly easy to make a data source to talk to the Raspberry Pi GPIO as there is an existing java library we could use.  We might have to do that one of these days.</p>
]]></description><link>https://forum.mango-os.com/post/10020</link><guid isPermaLink="true">https://forum.mango-os.com/post/10020</guid><dc:creator><![CDATA[JoelHaggar]]></dc:creator><pubDate>Mon, 25 May 2015 03:21:08 GMT</pubDate></item></channel></rss>