arachnidlabs / minishift-python

Python library for interfacing with the minishift.
BSD 3-Clause "New" or "Revised" License
3 stars 4 forks source link

Web Server (minishiftd) hangs on RaspberryPi #3

Closed adamboutcher closed 9 years ago

adamboutcher commented 9 years ago

The minishiftd web server crashes after a period of time (between 15 seconds and 1 minute) without any error on stdout or stderr. (Nothing in any logs either). More noticeable with scrolling.

The daemon hangs the whole terminal unless the device is unplugged and then you can kill the daemon with CTRL+C which causes the error below:

$ python -m minishift.minishiftd 72
INFO:root:Serving on 8000
/set?text=To%20be%20or%20not%20to%20be%2C%20that%20is%20the%20question&interval=0.05
127.0.0.1 - - [17/Jun/2014 16:38:00] "GET /set?text=To%20be%20or%20not%20to%20be%2C%20that%20is%20the%20question&interval=0.05 HTTP/1.1" 200 -
/set?text=Carrot%20and%20cheese%2C%20thats%20what%20we%20need&interval=0.05
127.0.0.1 - - [17/Jun/2014 16:39:00] "GET /set?text=Carrot%20and%20cheese%2C%20thats%20what%20we%20need&interval=0.05 HTTP/1.1" 200 -
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/local/lib/python2.7/dist-packages/minishift/minishiftd.py", line 41, in run
    self.do_scroll_text(self.text, self.scroll_interval, self.scroll_times)
  File "/usr/local/lib/python2.7/dist-packages/minishift/minishiftd.py", line 51, in do_scroll_text
    self.minishift.update(col)
  File "/usr/local/lib/python2.7/dist-packages/minishift/draw.py", line 192, in update
    self.interface.send(canvas.to_bytes())
  File "/usr/local/lib/python2.7/dist-packages/minishift/draw.py", line 25, in send
    self.device.transfer(data)
  File "/usr/local/lib/python2.7/dist-packages/mcp2210/device.py", line 214, in transfer
    response += self.sendCommand(commands.SPITransferCommand(data[i:i + 60])).data
  File "/usr/local/lib/python2.7/dist-packages/mcp2210/device.py", line 137, in sendCommand
    response = command.RESPONSE.from_buffer_copy(response_data)
ValueError: Buffer size too small (0 instead of at least 64 bytes)

^CTraceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/minishift/minishiftd.py", line 156, in <module>
    main(args)
  File "/usr/local/lib/python2.7/dist-packages/minishift/minishiftd.py", line 146, in main
    httpd.serve_forever()
  File "/usr/lib/python2.7/SocketServer.py", line 236, in serve_forever
    poll_interval)
  File "/usr/lib/python2.7/SocketServer.py", line 155, in _eintr_retry
    return func(*args)
KeyboardInterrupt

This doesn't seem to happen on a traditional x86/64 CPU based system.

Arachnid commented 9 years ago

The error it's showing is simply what you get if you cancel a receive partway through, so it's not telling us much about what's going wrong, unfortunately.

Does the daemon crash if it's not being instructed to do anything? Do you have any way to debug USB bus transactions?

adamboutcher commented 9 years ago

not any hardware but I can install any FOSS software on the pi, I'm not great at debugging code though.

Arachnid commented 9 years ago

I'll have a go at it on my own RPi when I get a chance. Anything you can do to narrow down the circumstances that cause it to crash would be hugely useful, though.

adamboutcher commented 9 years ago

Literally just calling up the web server and running it, it eventually crashes...

Arachnid commented 9 years ago

Even if you don't send any requests to it?

adamboutcher commented 9 years ago

I can't tell, I send one request and it tends to die

typically text=test interval=0.05

Arachnid commented 9 years ago

Can you try it and see if it locks up without any requests? Also, if it locks up with a non-scrolling request, and if it locks up with a scrolling request with a longer message (Eg, longer than the display).

adamboutcher commented 9 years ago

It locks up with any size length request and it doesn't have to be scrolling although scrolling seems to make the issue more noticable; once I'm back tinkering I'll try without any requests

ComputerSmiths commented 9 years ago

This works on a Raspberry Pi 2 on top of NOOBS 1.4.0:

2 apt-get update 3 apt-get upgrade 4 apt-get install python-dev 5 pip install cython 6 wget https://bootstrap.pypa.io/get-pip.py 7 python get-pip.py 8 pip install cython 9 apt-get install libusb-1.0-0-dev 10 apt-get install libudev-dev libudev0 11 pip install hidapi 12 git clone https://github.com/arachnidlabs/minishift-python.git 13 cd minishift-python 14 python setup.py install 15 cd 16 pip install mcp2210

Arachnid commented 9 years ago

Closing as fixed. Thanks for the help!