Permissions issue for /dev/ttyAMA0 after upgrade attempt from 5.0 to 5.0.1

146 views
Skip to first unread message

Mark Conner

unread,
Feb 6, 2024, 2:45:35 PMFeb 6
to weewx...@googlegroups.com
Hi,

I recently tried to upgrade my weewx installation from 5.0 to 5.0.1 on my Raspberry Pi 2 using 'sudo apt-get' and afterwards I was unable to start weewxd.  I am reading from a Davis Vantage Pro2 with a serial logger via a MeteoPi interface.  Thinking it was an upgrade problem, I downgraded to 5.0.0 and still have the same issue.  Here are the weewxd related lines from startup from /var/log/syslog: 

Feb  6 13:29:00 raspberrypi110 weewxd[2836]: INFO __main__: Initializing weewxd version 5.0.0
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: INFO __main__: Command line: /usr/share/weewx/weewxd.py /etc/weewx/weewx.conf
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: INFO __main__: Using Python 3.9.2 (default, Mar 12 2021, 04:06:34) #012[GCC 10.2.1 20210110]
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: INFO __main__: Located at /usr/bin/python3
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: INFO __main__: Platform Linux-6.1.21-v7+-armv7l-with-glibc2.31
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: INFO __main__: Locale: 'en_US'
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: INFO __main__: Entry path: /usr/share/weewx/weewxd.py
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: INFO __main__: WEEWX_ROOT: /
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: INFO __main__: Configuration file: /etc/weewx/weewx.conf
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: INFO __main__: User module: /etc/weewx/bin/user
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: INFO __main__: Debug: 0
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: INFO weewx.engine: Loading station type Vantage (weewx.drivers.vantage)
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: ERROR weewx.engine: Import of driver failed: [Errno 13] could not open port /dev/ttyAMA0: [Errno 13] Permission denied: '/dev/ttyAMA0' (<class 'serial.serialutil.SerialException'>)
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****  Traceback (most recent call last):
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****    File "/usr/local/lib/python3.9/dist-packages/serial/serialposix.py", line 322, in open
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****      self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****  PermissionError: [Errno 13] Permission denied: '/dev/ttyAMA0'
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****  
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****  During handling of the above exception, another exception occurred:
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****  
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****  Traceback (most recent call last):
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****    File "/usr/share/weewx/weewx/engine.py", line 115, in setupStation
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****      self.console = loader_function(config_dict, self)
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****    File "/usr/share/weewx/weewx/drivers/vantage.py", line 32, in loader
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****      return VantageService(engine, config_dict)
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****    File "/usr/share/weewx/weewx/drivers/vantage.py", line 2046, in __init__
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****      Vantage.__init__(self, **config_dict[DRIVER_NAME])
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****    File "/usr/share/weewx/weewx/drivers/vantage.py", line 536, in __init__
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****      self.port.openPort()
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****    File "/usr/share/weewx/weewx/drivers/vantage.py", line 319, in openPort
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****      self.serial_port = serial.Serial(self.port, self.baudrate, timeout=self.timeout)
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****    File "/usr/local/lib/python3.9/dist-packages/serial/serialutil.py", line 244, in __init__
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****      self.open()
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****    File "/usr/local/lib/python3.9/dist-packages/serial/serialposix.py", line 325, in open
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****      raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL weewx.engine:     ****  serial.serialutil.SerialException: [Errno 13] could not open port /dev/ttyAMA0: [Errno 13] Permission denied: '/dev/ttyAMA0'
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL __main__: Unable to load driver: [Errno 13] could not open port /dev/ttyAMA0: [Errno 13] Permission denied: '/dev/ttyAMA0'
Feb  6 13:29:00 raspberrypi110 weewxd[2836]: CRITICAL __main__:     ****  Exiting...

I did not change anything myself related to /dev/ttyAMA0 in the upgrade/downgrade process.  What is strange is that I can read current data from the VP2 using weectl.

pi@raspberrypi110:~ $ sudo weectl device --current
Using configuration file /etc/weewx/weewx.conf
Using driver weewx.drivers.vantage.
Using Vantage driver version 3.6.2 (weewx.drivers.vantage)
Querying the station for current weather data...
2024-02-06 13:38:37 CST (1707248317) 'barometer': '30.073', 'consBatteryVoltage': '4.71', 'dateTime': '1707248317', 'dayET': '0.0', 'dayRain': '0.0', 'extraAlarm1': '0', 'extraAlarm2': '0', 'extraAlarm3': '0', 'extraAlarm4': '0', 'extraAlarm5': '0', 'extraAlarm6': '0', 'extraAlarm7': '0', 'extraAlarm8': '0', 'extraTemp1': '35.0', 'forecastIcon': '7', 'forecastRule': '60', 'inHumidity': '38.0', 'insideAlarm': '0', 'inTemp': '69.6', 'monthET': '0.0', 'monthRain': '0.01', 'outHumidity': '74.0', 'outsideAlarm1': '0', 'outsideAlarm2': '0', 'outTemp': '50.6', 'rain': 'None', 'rainAlarm': '0', 'rainRate': '0.0', 'soilLeafAlarm1': '0', 'soilLeafAlarm2': '0', 'soilLeafAlarm3': '0', 'soilLeafAlarm4': '0', 'stormRain': '0.0', 'sunrise': '1707226320', 'sunset': '1707263280', 'txBatteryStatus': '0', 'usUnits': '1', 'windDir': '156.0', 'windSpeed': '10.0', 'windSpeed10': '6.0', 'yearET': '0.0', 'yearRain': '0.02'
 
Below is an ls -l of /dev/ttyAMA0

pi@raspberrypi110:~ $ ls -l /dev/ttyAMA0
crw-rw---- 1 root dialout 204, 64 Feb  6 13:38 /dev/ttyAMA0

Original installation of weewx on this device was approximately 4.8.0.

I have tried both a "shutdown -r" and a shutdown/power-cycle in an attempt to clear the error.

- Mark

Tom Keffer

unread,
Feb 6, 2024, 3:05:09 PMFeb 6
to weewx...@googlegroups.com
I’m typing this on a phone, so my directions are necessarily incomplete, but this is probably caused by the user weewx not having the necessary permissions. Try following the instructions at this link: 


--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CA%2BTd0WR8V1c1rDesizj-FXAW7bNVXzARhCNtSYpv621quvfp5Q%40mail.gmail.com.

Mark Conner

unread,
Feb 6, 2024, 3:05:16 PMFeb 6
to weewx-user
By chance, I just read the previous message thread and was able to use that to fix my issue.  The issue for me centered around the change from running weewx as 'root' in 5.0 and before, to running as user 'weewx' in 5.0.1.  I added user 'weewx' to the group 'dialout' so it could access /dev/ttyAMA0 and everything works again.

sudo usermod -a -G dialout weewx 

I think this change in 5.0.1 from running as 'root' to running as 'weewx' needs to be more strongly advertised.  This may be problematic for users who upgraded from v4.x and still run weewx as root.

- Mark

Warren Gill

unread,
Feb 6, 2024, 3:07:20 PMFeb 6
to weewx...@googlegroups.com
Try adding weewx user to the dialout group and restarting weewx:

sudo usermod -aG dialout weewx
sudo systemctl restart weewx


Karen K

unread,
Feb 6, 2024, 3:08:23 PMFeb 6
to weewx-user
WeeWX 4.* runs as root. WeeWX 5.* does not run as root. As you write the permissions of /dev/ttyAMA0 are user root and group dialout. You may include the user weewx into group dialout or follow the instructions Tom and Matthew gave in several of the previous threads regarding this issue.

Tom Keffer

unread,
Feb 6, 2024, 5:50:38 PMFeb 6
to weewx...@googlegroups.com
See the Upgrade Guide section WeeWX runs as the weewx user.

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

Mark Conner

unread,
Feb 6, 2024, 6:11:01 PMFeb 6
to weewx...@googlegroups.com
I see now that I misread the upgrade page, and indeed it was advertised - my apologies for saying it wasn't.  When I was reading the docs prior to the 5.0 upgrade, I thought it said that it would honor previous installs running as root and so I didn't worry about it for 5.0.  But it really says it will honor previous installs for a user other than root.  

- Mark

You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/GR8Tmi8ud9g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAPq0zED0Rbg0z%2BxA8M2Z%3DwX1zutAESqaN3981syaDTRbkf-bLw%40mail.gmail.com.

Tom Keffer

unread,
Feb 6, 2024, 7:22:59 PMFeb 6
to weewx...@googlegroups.com
No, you're not hallucinating! That detail was changed between v5.0.0 and v5.0.1. We should have called that out.

Reply all
Reply to author
Forward
0 new messages