Skip to content

Commit

Permalink
Fix port inconsistency for weatherstation
Browse files Browse the repository at this point in the history
* `port` to `serial_port` consistently.
  • Loading branch information
wtgee committed May 2, 2024
1 parent 6bdacc8 commit 3c04b16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/panoptes/pocs/sensor/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ class WeatherStation(PanBase):
"""

def __init__(self,
port: str = None,
serial_port: str = None,
name: str = 'Weather Station',
db_collection: str = 'weather',
*args, **kwargs):
"""Initialize the weather station.
Args:
port (str, optional): The dev port for the mount, usually the usb-serial converter.
serial_port (str, optional): The dev port for the mount, usually the usb-serial converter.
name (str): The user-friendly name for the weather station.
db_collection (str): Which collection (i.e. table) to store the values in, default 'weather'.
"""
Expand All @@ -29,12 +29,12 @@ def __init__(self,
conf.update(kwargs)
conf.pop('auto_detect', None)

self.port = port or conf.get('port', '/dev/ttyUSB0')
self.serial_port = serial_port or conf.get('serial_port', '/dev/ttyUSB0')

Check warning on line 32 in src/panoptes/pocs/sensor/weather.py

View check run for this annotation

Codecov / codecov/patch

src/panoptes/pocs/sensor/weather.py#L32

Added line #L32 was not covered by tests
self.name = name
self.collection_name = db_collection

self.logger.debug(f'Setting up weather station connection for {name=} on {self.port}')
self.weather_station = CloudSensor(serial_port=self.port, **conf)
self.logger.debug(f'Setting up weather station connection for {name=} on {self.serial_port}')
self.weather_station = CloudSensor(serial_port=self.serial_port, **conf)

Check warning on line 37 in src/panoptes/pocs/sensor/weather.py

View check run for this annotation

Codecov / codecov/patch

src/panoptes/pocs/sensor/weather.py#L36-L37

Added lines #L36 - L37 were not covered by tests

self.logger.debug(f'Weather station config: {self.weather_station.config}')
self.logger.info(f'{self.weather_station} initialized')
Expand Down
4 changes: 2 additions & 2 deletions src/panoptes/pocs/utils/service/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ async def startup():
if conf.get('auto_detect', False) is True:
ports = [p.device for p in get_comports()]
else:
ports = [conf['port']]
ports = [conf['serial_port']]

Check warning on line 24 in src/panoptes/pocs/utils/service/weather.py

View check run for this annotation

Codecov / codecov/patch

src/panoptes/pocs/utils/service/weather.py#L24

Added line #L24 was not covered by tests

# Try to connect to the weather station.
for port in ports:
if 'ioptron' in port:
continue

conf['port'] = port
conf['serial_port'] = port

Check warning on line 31 in src/panoptes/pocs/utils/service/weather.py

View check run for this annotation

Codecov / codecov/patch

src/panoptes/pocs/utils/service/weather.py#L31

Added line #L31 was not covered by tests
try:
weather_station = WeatherStation(**conf)
break
Expand Down

0 comments on commit 3c04b16

Please sign in to comment.