Virtual Sensor using awk; help please
Posted: Wed Jan 13, 2016 9:46 am
There is a reason behind this, and if you care about the reason please see viewtopic.php?f=16&t=10651
I don't know gawk/awk at all, and I've stumbled my was through the online documentation and help that's out there and I'm still running in to a problem. Here's what I'm dealing with:
I have a file: /var/local/heading that contains the heading of my wind vane.
I am trying to create a virtual sensor, wind1, using the data from wind0 and the value in /var/local/heading
I'm using this awk expression:
awk ' { printf ''%d %d %d %d'', $1, $5, $6, $7 }' /var/local/heading
since I can observe that the value in /var/local/heading is appearing as $1. I seem to have "lost" the stdin data from wind0 since $5, $6, and $7 show as "0 0 0000"
I incremented the string variable by 1 since the data from /var/local/heading appears to be read as $1. This is almost a blatant copy of the example code in the documentation on page #32-33.
Could someone please tell me how to fix the awk statement, or suggest another way to do this (calling a script?)
Here's my wind0 & wind1 sensor output:
20160113072510 wind0 0 0 0 0134
20160113072510 wind1 123 0 0 0000
123 is the only text in the file /var/local/heading
I don't know gawk/awk at all, and I've stumbled my was through the online documentation and help that's out there and I'm still running in to a problem. Here's what I'm dealing with:
I have a file: /var/local/heading that contains the heading of my wind vane.
I am trying to create a virtual sensor, wind1, using the data from wind0 and the value in /var/local/heading
I'm using this awk expression:
awk ' { printf ''%d %d %d %d'', $1, $5, $6, $7 }' /var/local/heading
since I can observe that the value in /var/local/heading is appearing as $1. I seem to have "lost" the stdin data from wind0 since $5, $6, and $7 show as "0 0 0000"
I incremented the string variable by 1 since the data from /var/local/heading appears to be read as $1. This is almost a blatant copy of the example code in the documentation on page #32-33.
Could someone please tell me how to fix the awk statement, or suggest another way to do this (calling a script?)
Here's my wind0 & wind1 sensor output:
20160113072510 wind0 0 0 0 0134
20160113072510 wind1 123 0 0 0000
123 is the only text in the file /var/local/heading