hologram-io / hologram-python

Hologram device-side Python SDK - Send messages to the cloud in just 3 lines of code!
https://hologram.io/
MIT License
89 stars 47 forks source link

NameError: global name 'SerialError' is not defined #5

Closed mattfeury closed 6 years ago

mattfeury commented 6 years ago

Hello, I am seeing an issue on top of probably another issue. See the stacktrace below from when I try to do a basic sudo hologram modem connect. It actually connects fine, but for some reason it is unable to move the serial port. However, in an attempt to trigger this error, it actually causes another error due to what looks like a missing import.

  File "/usr/local/lib/python2.7/dist-packages/scripts/hologram_modem.py", line 43, in run_modem_connect
    cloud.network.connect()
  File "/usr/local/lib/python2.7/dist-packages/Hologram/Network/Cellular.py", line 60, in connect
    success = self.modem.connect(timeout = timeout)
  File "/usr/local/lib/python2.7/dist-packages/Hologram/Network/Modem/Nova.py", line 39, in connect
    raise SerialError('Not enough serial ports detected for Nova')
NameError: global name 'SerialError' is not defined

So two questions:

thanks!

ATLUSio commented 6 years ago

The import error is peculiar. What if you add onto line 14:

from Exceptions.HologramError import SerialError

Also, the error occurs because there aren't enough serial ports, quite literally. The code:

devices = self.detect_usable_serial_port()
if not devices:
    raise SerialError('Not enough serial ports detected for Nova')

It basically tries to see if there are any usable serial ports, and since there are none it raises that error. I would expect it to inherit the import from Modem since it's properly imported there, but I guess that's not the case. Make sure you've got more serial ports because it clearly looks like you've got one serial port open, but need another, as well.

mattfeury commented 6 years ago

Hi thanks for the quick response. it actually looks like this issue may have been caused by NetworkManager/ModemManager. I had that enabled because I was using other modems, but it was causing me a lot of inconsistencies with Nova. Now that i've got that disabled, i'm not seeing the "Not enough serial ports detected for Nova" error anymore. NM/MM has been a real pain in the ass so glad to be able to use this repo directly and ditch that. (thanks!)

tzhenghao commented 6 years ago

Hi @mattfeury, whatever @ATLUSio said is true. I'll work on a patch and hope to release it soon.