hologram-io/hologram-python

NameError: global name 'SerialError' is not defined

mattfeury opened this issue · 3 comments

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:

  • Can we get this import fixed? Seems like it should be pretty simple
  • Why would this error occur to begin with? I've tried my nova out of the box on both a Rpi B and an RPi A+, and get this everytime. I'm able to connect fine so it really just makes me want to swallow the error messages which I don't like to do.

thanks!

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.

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!)

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