smarthomeNG / smarthome

Device integration platform for your smart home
https://www.smarthomeNG.de
GNU General Public License v3.0
122 stars 92 forks source link

plugins/dlms wrong serialport error #203

Closed lgb-this closed 7 years ago

lgb-this commented 7 years ago

I started with the dlms plugin (develop) with a wrong serialport. The code crashed with the line:

self._serial = serial.Serial(serialport, 300, bytesize=serial.SEVENBITS, parity=serial.PARITY_EVEN, timeout=2)

bmxp commented 7 years ago

You should have got an error message as this error should be caught and reported. What else would you expect how it should behave?

lgb-this commented 7 years ago

The code crashs and does not show an error message.

bmxp commented 7 years ago

Did you test in standalone mode oder as plugin in SmartHomeNG? If SmartHomeNG: What does it tell with SmartHomeNG in Debug Mode?

lgb-this commented 7 years ago

Here the error (plugin in SmartHomeNG Develop): `2017-03-10 20:30:47 ERROR Main Plugin dlmsx exception: could not open port /dev/ttyUSB4: [Errno 2] No such file or directory: '/dev/ttyUSB4' Traceback (most recent call last): File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 275, in open self.fd = os.open(self.portstr, os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK) FileNotFoundError: [Errno 2] No such file or directory: '/dev/ttyUSB4'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/smarthome/lib/plugin.py", line 90, in init plugin_thread = PluginWrapper(smarthome, plugin, classname, classpath, args, instance) File "/usr/local/smarthome/lib/plugin.py", line 144, in init exec("self.plugin.init(smarthome{0}{1})".format("," if len(arglist) else "", argstring)) File "", line 1, in File "/usr/local/smarthome/plugins/dlms/init.py", line 49, in init self._serial = serial.Serial(serialport, 300, bytesize=serial.SEVENBITS, parity=serial.PARITY_EVEN, timeout=2) File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 261, in init self.open() File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 278, in open raise SerialException("could not open port %s: %s" % (self._port, msg)) serial.serialutil.SerialException: could not open port /dev/ttyUSB4: [Errno 2] No such file or directory: '/dev/ttyUSB4' `

bmxp commented 7 years ago

Ok, some stacked exceptions. I'll change it to give some better error message. But anyhow it should not simply crash and say nothing...

bmxp commented 7 years ago

I've fixed this and some other minor annoyance. Have to make a PR somehow ...

ohinckel commented 7 years ago

@bmxp / @lgb-this, is here still something open?

lgb-this commented 7 years ago

Solved for me.

bmxp commented 7 years ago

I pushed the latest changes to develop. Please reopen if you find anything else.