Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4018) - 28 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

udev rules document for RPI 3

Topics about the Beta trials up to Build 3043, the last build by Cumulus's founder Steve Loft. It was by this time way out of Beta but Steve wanted to keep it that way until he made a decision on his and Cumulus's future.

Moderator: mcrossley

BigOkie
Posts: 272
Joined: Tue 28 May 2013 1:06 am
Weather Station: Davis VP2 Plus
Operating System: Raspian Buster (RPi 3b)
Location: Tulsa, OK

udev rules document for RPI 3

Post by BigOkie »

I've been meaning to do this for some time. I migrated last night to Pi and it went smoothly until this afternoon I noticed the Pi was no longer communicating with the station. For some reason, the USB hub went wonky and it disconnected and reconnected on a different port. I've created the attached document to help those of you that may have that problem work around it how I did today. This should work for all Pi units I'm told but I tested on a Pi 3 B.

As I've noted on the document, if you have any questions regarding it, please post a question here and I'll do my best to answer as timely as I can.

Mark

EDIT: PLEASE NOTE -- while this does work to make consistent device assignment names, if the USB loses connection in the middle of your Pi session, it will not regain it until CMX is restarted. If I could figure out a way to make it do that automatically based on an error in the log file I would do that for sure. Until then, manual restarts will be needed. It's likely mine did this (three times in the last two days) because I had the Pi installed with a USB stick mounted for extra storage, which could have been interfering with the USB bus. I also had it connected into a 16 foot active USB extender. I eliminated both of those and we'll see where it gets me now.
You do not have the required permissions to view the files attached to this post.
BigOkie
Posts: 272
Joined: Tue 28 May 2013 1:06 am
Weather Station: Davis VP2 Plus
Operating System: Raspian Buster (RPi 3b)
Location: Tulsa, OK

Re: udev rules document for RPI 3

Post by BigOkie »

Update. For the first time since I posted the original, I had this happen (USB disconnected and data stopped, then reassignment to a different port). However, I did figure out how to restart CMX when this happens by using a cron job every x minutes (use the log interval for X so you don't lose data). The shell file uses the startup script; it obviously could be modified if you are not using the script.

As long as you keep the symlink to the dev, once CMX restarts it will work just fine. If you have any questions please ask and I'll try to answer them the best I can.

This is my example script. You will need to call it with cron at intervals.

Note - the following assumes you have installed CMX to the standard folder on Pi. It works by listing the log files in MXdiags folder and finding the most recent and reading it for the string 'appears'. If it finds it the assumption is that it's part of the line saying 'Data input appears to have stopped'. The USB disconnect may or may not have caused this input to stop, but for me, sofar it's been the only reason. It's rather rudimentary actually. I'm keying on the word appears as stopped shows in the logs for other events, but appears seems to be unique to the data input stopped message.

Code: Select all

#!/bin/bash
cd /home/pi/CumulusMX/MXdiags || exit
LOG=$(ls -t | head -n1)
PATTERN=appears
if grep -q $PATTERN $LOG;
        then
        echo "Input stopped, restarting CMX"
        /bin/bash /home/pi/CumulusMX/cumulusmx.sh -r
else
        echo "CMX running normally"
        exit 0
fi
User avatar
steve
Cumulus Author
Posts: 26702
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: udev rules document for RPI 3

Post by steve »

Another way to detect data stopped would be to get MX to process a file locally containing the <#DataStopped> web tag.
Steve
BigOkie
Posts: 272
Joined: Tue 28 May 2013 1:06 am
Weather Station: Davis VP2 Plus
Operating System: Raspian Buster (RPi 3b)
Location: Tulsa, OK

Re: udev rules document for RPI 3

Post by BigOkie »

steve wrote:Another way to detect data stopped would be to get MX to process a file locally containing the <#DataStopped> web tag.
I never thought of that Steve but obviously it is a good idea. Thanks.

Would work easier probably since it is strictly a 0/1 boolean value.
BigOkie
Posts: 272
Joined: Tue 28 May 2013 1:06 am
Weather Station: Davis VP2 Plus
Operating System: Raspian Buster (RPi 3b)
Location: Tulsa, OK

Re: udev rules document for RPI 3

Post by BigOkie »

As a followup, Steve's suggestion with the webtag worked..I had a bit of wind yesterday, and as I live in an older part of my city, it sometimes has some power bumps.

The cronjob did its duty in reading the file properly and restarting CMX when an issue arose. Had it happen at least five times yesterday. Sofar it's been over 12 hours (likely due to the wind dying down quite a bit here lately).

I also built in a function to mail me a notification whenever the connection needed a refresh. Not a requirement, but I can add instructions on how to make that happen if there is interest.
BigOkie
Posts: 272
Joined: Tue 28 May 2013 1:06 am
Weather Station: Davis VP2 Plus
Operating System: Raspian Buster (RPi 3b)
Location: Tulsa, OK

Re: udev rules document for RPI 3

Post by BigOkie »

As a followup to this after seeing someone needed something similar in a more recent post, I will post the script I'm using (based on using Steve's recommendation to use the webtag to ascertain connection status):

Code: Select all

#!/bin/bash
cd /var/log || exit
LOG=datatag.txt
PATTERN=DataStopped=1
if grep -q $PATTERN $LOG;
        then
#       echo "Input stopped, restarting CMX"
        /bin/bash /home/pi/CumulusMX/cumulusmx.sh -r
else
        echo "CMX running normally"
        exit 0
fi
The variable LOG is based off what you are calling the file you are creating with the tag in it. Mine is in the /var/log directory of the Pi; I've named it datatag.txt. You can do this in CMX settings > Extra web files. I'm posting an image showing you my setting for that specific file. It will get updated at least as often as your web update interval is (in my case it will be five minutes).

The file was placed in the /home/pi/CumulusMX/web folder with the name datatagT.txt (for the template). The content of that template file is as follows:

Code: Select all

DataStopped=<#DataStopped>
The script then uses another variable called PATTERN to do the searching in the file. If the first condition exists (DataStopped=1) then the script is set to restart. Any other result from the file causes the script to exit with no action taken.

I have this set up to run every five minutes via cron on my system to check it. It works great. Using an MTA and mailer, if I have an issue, I have it set to send me an email if I want which will notify me if the connection gets reset.

I'm a tinkerer by nature. :)

Please let me know if you have any questions and I'll try to answer them.
takezo
Posts: 35
Joined: Fri 18 Nov 2016 2:18 pm
Weather Station: raspberry pi
Operating System: debina

Re: udev rules document for RPI 3

Post by takezo »

BigOkie wrote:As a followup to this after seeing someone needed something similar in a more recent post, I will post the script I'm using (based on using Steve's recommendation to use the webtag to ascertain connection status):

Code: Select all

#!/bin/bash
cd /var/log || exit
LOG=datatag.txt
PATTERN=DataStopped=1
if grep -q $PATTERN $LOG;
        then
#       echo "Input stopped, restarting CMX"
        /bin/bash /home/pi/CumulusMX/cumulusmx.sh -r
else
        echo "CMX running normally"
        exit 0
fi
The variable LOG is based off what you are calling the file you are creating with the tag in it. Mine is in the /var/log directory of the Pi; I've named it datatag.txt. You can do this in CMX settings > Extra web files. I'm posting an image showing you my setting for that specific file. It will get updated at least as often as your web update interval is (in my case it will be five minutes).

The file was placed in the /home/pi/CumulusMX/web folder with the name datatagT.txt (for the template). The content of that template file is as follows:

Code: Select all

DataStopped=<#DataStopped>
The script then uses another variable called PATTERN to do the searching in the file. If the first condition exists (DataStopped=1) then the script is set to restart. Any other result from the file causes the script to exit with no action taken.

I have this set up to run every five minutes via cron on my system to check it. It works great. Using an MTA and mailer, if I have an issue, I have it set to send me an email if I want which will notify me if the connection gets reset.

I'm a tinkerer by nature. :)

Please let me know if you have any questions and I'll try to answer them.
Hi BigOkie,

thanks for your post! very useful!

please, could you let me know what is the content of each file... i'm a little bit lost :cry: ...? and what bullets have you marked into "CMX settings > Extra web files"

Thanks!
takezo
Posts: 35
Joined: Fri 18 Nov 2016 2:18 pm
Weather Station: raspberry pi
Operating System: debina

Re: udev rules document for RPI 3

Post by takezo »

BigOkie wrote:As a followup to this after seeing someone needed something similar in a more recent post, I will post the script I'm using (based on using Steve's recommendation to use the webtag to ascertain connection status):

Code: Select all

#!/bin/bash
cd /var/log || exit
LOG=datatag.txt
PATTERN=DataStopped=1
if grep -q $PATTERN $LOG;
        then
#       echo "Input stopped, restarting CMX"
        /bin/bash /home/pi/CumulusMX/cumulusmx.sh -r
else
        echo "CMX running normally"
        exit 0
fi
The variable LOG is based off what you are calling the file you are creating with the tag in it. Mine is in the /var/log directory of the Pi; I've named it datatag.txt. You can do this in CMX settings > Extra web files. I'm posting an image showing you my setting for that specific file. It will get updated at least as often as your web update interval is (in my case it will be five minutes).

The file was placed in the /home/pi/CumulusMX/web folder with the name datatagT.txt (for the template). The content of that template file is as follows:

Code: Select all

DataStopped=<#DataStopped>
The script then uses another variable called PATTERN to do the searching in the file. If the first condition exists (DataStopped=1) then the script is set to restart. Any other result from the file causes the script to exit with no action taken.

I have this set up to run every five minutes via cron on my system to check it. It works great. Using an MTA and mailer, if I have an issue, I have it set to send me an email if I want which will notify me if the connection gets reset.

I'm a tinkerer by nature. :)

Please let me know if you have any questions and I'll try to answer them.
any help , please!!!
BigOkie
Posts: 272
Joined: Tue 28 May 2013 1:06 am
Weather Station: Davis VP2 Plus
Operating System: Raspian Buster (RPi 3b)
Location: Tulsa, OK

Re: udev rules document for RPI 3

Post by BigOkie »

It's actually pretty simple. I've laid out how to do this in the posts.

Take the contents of the first code window and put it in a file (I think I called mine checkmx.sh) and make sure to chmod +x that file so it can execute.

From the second code window, place that in a file somewhere in the web directory of the CumulusMX install. It doesn't really matter what you name it as long as you know what you are going to name it. I named mine datatagT.txt. This is going to be the file that processes the tag to tell you if MX has stopped receiving data.

You will then need to set up a line in the Extra Web Files section of Settings, where you tell the datatagT.txt to process every so often. In my case, it's every five minutes (that's as often as I do the internet update). Tick the process box and nothing else (you're only processing the file to be evaluated locally), and in the first box (Local Filename) put in /home/pi/CumulusMX/web/datatagT.txt (or whatever you've named the file). In the second box (Remote Filename) put in /var/log/datatag.txt. The setting you have in Settings > Internet Settings > Upload Interval determine how often in minutes this file gets processed (mine is 5 minutes as I've stated).

What you should do after this (wait until the next 5 minute interval) is test the script works.

If you placed it where I suggested in /usr/local/bin/checkmx.sh, your best bet is to issue the following command from your Pi command prompt:

Code: Select all

root@wxserver:~# bash -x /usr/local/bin/checkmx.sh
If everything is ok, you should see something that looks like the following after you press enter:

Code: Select all

+ cd /var/log
+ LOG=datatag.txt
+ PATTERN=DataStopped=1
+ grep -q DataStopped=1 datatag.txt
+ echo 'CMX running normally'
CMX running normally
+ exit 0
This is just a way to test the shell script and have it return verbose messages for each line in the script. It also helps you visualize the variables that are cast and make any changes if there are problems. If the string is actually DataStopped=1, then it should run jank's script to restart CumulusMX.

Once you are satisfied that this works as you want it, you can enter it as a scheduled cron job by adding a line to cron. This is accomplished by issuing the following:

Code: Select all

root@wxserver:~# crontab -e
You will get an editor screen (if it asks you about setting up an editor, it means you've never modified the crontab..if you have the selection of nano, use it). The editor screen looks like this with nano:

Code: Select all

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
0 0 * * * sleep 5 && /usr/bin/rsync -av /home/pi/CumulusMX/Reports/ /htdocs/Reports/ >/dev/null 2>&1
1-59/5 * * * * /usr/local/bin/checkmx.sh  > /dev/null 2>&1
That final line is my crontab entry to run the script every five minutes with an offset of 1 minute (which means it will run at 6, 11, 16, 21, etc).

Once you've done that, save the crontab and it should begin running once you do that.

I hope this helps a little.
takezo
Posts: 35
Joined: Fri 18 Nov 2016 2:18 pm
Weather Station: raspberry pi
Operating System: debina

Re: udev rules document for RPI 3

Post by takezo »

BigOkie wrote:It's actually pretty simple. I've laid out how to do this in the posts.

Take the contents of the first code window and put it in a file (I think I called mine checkmx.sh) and make sure to chmod +x that file so it can execute.

From the second code window, place that in a file somewhere in the web directory of the CumulusMX install. It doesn't really matter what you name it as long as you know what you are going to name it. I named mine datatagT.txt. This is going to be the file that processes the tag to tell you if MX has stopped receiving data.

You will then need to set up a line in the Extra Web Files section of Settings, where you tell the datatagT.txt to process every so often. In my case, it's every five minutes (that's as often as I do the internet update). Tick the process box and nothing else (you're only processing the file to be evaluated locally), and in the first box (Local Filename) put in /home/pi/CumulusMX/web/datatagT.txt (or whatever you've named the file). In the second box (Remote Filename) put in /var/log/datatag.txt. The setting you have in Settings > Internet Settings > Upload Interval determine how often in minutes this file gets processed (mine is 5 minutes as I've stated).

What you should do after this (wait until the next 5 minute interval) is test the script works.

If you placed it where I suggested in /usr/local/bin/checkmx.sh, your best bet is to issue the following command from your Pi command prompt:

Code: Select all

root@wxserver:~# bash -x /usr/local/bin/checkmx.sh
If everything is ok, you should see something that looks like the following after you press enter:

Code: Select all

+ cd /var/log
+ LOG=datatag.txt
+ PATTERN=DataStopped=1
+ grep -q DataStopped=1 datatag.txt
+ echo 'CMX running normally'
CMX running normally
+ exit 0
This is just a way to test the shell script and have it return verbose messages for each line in the script. It also helps you visualize the variables that are cast and make any changes if there are problems. If the string is actually DataStopped=1, then it should run jank's script to restart CumulusMX.

Once you are satisfied that this works as you want it, you can enter it as a scheduled cron job by adding a line to cron. This is accomplished by issuing the following:

Code: Select all

root@wxserver:~# crontab -e
You will get an editor screen (if it asks you about setting up an editor, it means you've never modified the crontab..if you have the selection of nano, use it). The editor screen looks like this with nano:

Code: Select all

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
0 0 * * * sleep 5 && /usr/bin/rsync -av /home/pi/CumulusMX/Reports/ /htdocs/Reports/ >/dev/null 2>&1
1-59/5 * * * * /usr/local/bin/checkmx.sh  > /dev/null 2>&1
That final line is my crontab entry to run the script every five minutes with an offset of 1 minute (which means it will run at 6, 11, 16, 21, etc).

Once you've done that, save the crontab and it should begin running once you do that.

I hope this helps a little.

Thank so much!!

Now everything much more clear for me and I have been able to configure without problems
perl
Posts: 52
Joined: Wed 24 Jun 2015 7:02 pm
Weather Station: Davis Vantage Pro2
Operating System: Buster Lite rPi
Location: Taasinge, Denmark
Contact:

Re: udev rules document for RPI 3

Post by perl »

Hi BigOkie,

I have tried to get i working, but I am not shure if it works.

I have mx running on a PI with no dataconnection to my Davis Vantage.

The MX sometimes show:
Screen Shot 12-16-16 at 02.07 PM.PNG
and a moment later:
Screen Shot 12-16-16 at 02.06 PM 001.PNG
I have no cron jobs running for the moment = no executing of checkmx.sh

I have set up extra files this way:
Screen Shot 12-16-16 at 02.06 PM.PNG
The datatagT.txt:
Screen Shot 12-16-16 at 02.18 PM.PNG
The datatag.txt files in /home/pi/var/log is emty (chmod 777)

And I don't think MX write anything in this file - everytime I take a look it is emty, and there is no datatagT.txttmp.
You do not have the required permissions to view the files attached to this post.
BigOkie
Posts: 272
Joined: Tue 28 May 2013 1:06 am
Weather Station: Davis VP2 Plus
Operating System: Raspian Buster (RPi 3b)
Location: Tulsa, OK

Re: udev rules document for RPI 3

Post by BigOkie »

If it's not connected to a station, then it won't be providing any data to the tag. This only works if you have a live connection.

Not sure if it helps but the remote filename for the webtag file is /var/log/datatag.txt. not /home/pi/var/log/datatag.txt

As I stated also, the tag generated will only get generated on the schedule of the internet update (in my case it's 5 minutes).
perl
Posts: 52
Joined: Wed 24 Jun 2015 7:02 pm
Weather Station: Davis Vantage Pro2
Operating System: Buster Lite rPi
Location: Taasinge, Denmark
Contact:

Re: udev rules document for RPI 3

Post by perl »

Has it something to do with user rights on my Raspberry ?
I know very little about the Raspberry system. I have downlodet Steves files and installed them on a new Raspberry PI 3 Model B.
At the beginning I always started it with the command: sudo mono CumulusMX.exe
Later I wrote:
cd CumulusMX
sudo mono CumulusMX.exe

in pi's .bashrc file

To day I also use the CumulusMX - RasperryPi - Start|Stop|Restart Script V2.5.3.0

My CumulusMX is able to make a "datatagT.txttmp" file in the CumulusMX directory but not in var/log directory !

If I place the datatag.txt and datatagT.txt in the CumulusMX directory, then it is able to make the datatagT.txttmp file and if I run this:

#!/bin/bash
cd /home/pi/CumulusMX || exit
LOG=datatagT.txttmp
PATTERN=DataStopped=1
if grep -q $PATTERN $LOG;
then
# echo "Input stopped, restarting CMX"
# /bin/bash /home/pi/CumulusMX/cumulusmx.sh -r
sudo ./cumulusmx.sh -r
else
echo "CMX running normally"
exit 0
fi


Then the system restart when the tmp file is showing: DataStopped=1

If I use the line: /bin/bash /home/pi/CumulusMX/cumulusmx.sh -r
I get a warning about starting CumulusMX.
It seem that CumulusMX was not properly stopped last time, og initially started as root (sudo)
To insure, that CumulusMX was started and managed by the same user account, don't start it at user: pi, but as root (with sudo)
If You want to manage CumulusX as user pi, stop CumulusMX (sudo ./cumulusmx.sh -q) and make sure that the /tmp/CumulusMX.pid file is not existing anymore (sudo rm /tmp/CumulusMX.pid)
A mixed usage of CumulusMX is really not recommended. Always use the same useraccount to run and manage CumulusMX. Use always sudo or always without sudo (as user pi)


Is it wrong to test at the file datatagT.txttmp ?
Should there be any data in the datatag.txt file?
Why are CumulusMX not able to make at tmp file in var/log direcotry?
BigOkie
Posts: 272
Joined: Tue 28 May 2013 1:06 am
Weather Station: Davis VP2 Plus
Operating System: Raspian Buster (RPi 3b)
Location: Tulsa, OK

Re: udev rules document for RPI 3

Post by BigOkie »

perl wrote:Has it something to do with user rights on my Raspberry ?
I know very little about the Raspberry system. I have downlodet Steves files and installed them on a new Raspberry PI 3 Model B.
At the beginning I always started it with the command: sudo mono CumulusMX.exe
Later I wrote:
cd CumulusMX
sudo mono CumulusMX.exe

in pi's .bashrc file

To day I also use the CumulusMX - RasperryPi - Start|Stop|Restart Script V2.5.3.0

My CumulusMX is able to make a "datatagT.txttmp" file in the CumulusMX directory but not in var/log directory !

If I place the datatag.txt and datatagT.txt in the CumulusMX directory, then it is able to make the datatagT.txttmp file and if I run this:

#!/bin/bash
cd /home/pi/CumulusMX || exit
LOG=datatagT.txttmp
PATTERN=DataStopped=1
if grep -q $PATTERN $LOG;
then
# echo "Input stopped, restarting CMX"
# /bin/bash /home/pi/CumulusMX/cumulusmx.sh -r
sudo ./cumulusmx.sh -r
else
echo "CMX running normally"
exit 0
fi


Then the system restart when the tmp file is showing: DataStopped=1

If I use the line: /bin/bash /home/pi/CumulusMX/cumulusmx.sh -r
I get a warning about starting CumulusMX.
It seem that CumulusMX was not properly stopped last time, og initially started as root (sudo)
To insure, that CumulusMX was started and managed by the same user account, don't start it at user: pi, but as root (with sudo)
If You want to manage CumulusX as user pi, stop CumulusMX (sudo ./cumulusmx.sh -q) and make sure that the /tmp/CumulusMX.pid file is not existing anymore (sudo rm /tmp/CumulusMX.pid)
A mixed usage of CumulusMX is really not recommended. Always use the same useraccount to run and manage CumulusMX. Use always sudo or always without sudo (as user pi)


Is it wrong to test at the file datatagT.txttmp ?
Should there be any data in the datatag.txt file?
Why are CumulusMX not able to make at tmp file in var/log direcotry?
Do not test with the tmp file.

I log into to my Pi as root (superuser) which makes things much easier, although some linux geeks scream bloody murder about it. It's my system; I'll run it the way I want to. I've been a sysadmin, network engineer, and now a software tester for 25 years, so I'm pretty experienced with what I'm doing.

But yes, it would be better IMO if you run as root and skip sudo altogether. I could never get MX to run in the root home folder (/root) so I put in in the /home/pi/ folder.

To keep this from being a flame war about the perils of using root, you will need to search out how to enable the root account on the Pi if you haven't done so already.
perl
Posts: 52
Joined: Wed 24 Jun 2015 7:02 pm
Weather Station: Davis Vantage Pro2
Operating System: Buster Lite rPi
Location: Taasinge, Denmark
Contact:

Re: udev rules document for RPI 3

Post by perl »

Hi BigOkie,
Thanks for your helpfulness and good advice. They are very welcome when you are inexperienced and looking for solutions for lost datacommunication.
Locked