File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 3
3
"""
4
4
import json
5
5
from myDevices .plugins .manager import PluginManager
6
- from myDevices .utils .logger import info
6
+ from myDevices .utils .logger import info , debug
7
7
8
8
9
9
class AnalogInput ():
10
10
"""Reads data from an analog input."""
11
11
12
- def __init__ (self , adc_name ):
12
+ def __init__ (self , adc ):
13
13
"""Initializes the analog input.
14
14
15
15
Arguments:
16
- adc_name: Name of analog -to-digital converter plugin in the format 'plugin_name:section'
16
+ adc: Analog -to-digital converter plugin ID in the format 'plugin_name:section', e.g. 'cayenne-mcp3xxx:MCP '
17
17
"""
18
- self .adc_name = adc_name
18
+ self .adc_name = adc
19
19
self .adc = None
20
20
self .read_args = {}
21
21
self .pluginManager = PluginManager ()
@@ -30,7 +30,11 @@ def set_adc(self):
30
30
def read_value (self , channel , data_type = None ):
31
31
"""Read the data value on the specified channel."""
32
32
self .set_adc ()
33
- value = getattr (self .adc ['instance' ], self .adc ['read' ])(channel , data_type = data_type , ** self .read_args )
33
+ try :
34
+ value = getattr (self .adc ['instance' ], self .adc ['read' ])(channel , data_type = data_type , ** self .read_args )
35
+ except ValueError as e :
36
+ debug (e )
37
+ value = None
34
38
return value
35
39
36
40
def read_float (self , channel ):
You can’t perform that action at this time.
0 commit comments