brianinnes / vPiP

A python library with accompanying Arduino code to drive a vertical plotter from a Raspberry Pi. This project is targeted to drive the driver board created by makeBournemouth, but will work with any system capable of running Python and connecting to an Arduino/Genuino to drive the stepper motors
https://github.com/brianinnes/vPiP/wiki
Apache License 2.0
16 stars 11 forks source link

Glitchy, stop/start steppers #13

Closed MarkJB closed 7 years ago

MarkJB commented 7 years ago

I thought this was only affecting my machine, but we were seeing this at the last meetup on another machine.

The steppers are stop-start with the following error repeatedly shown on the console:

Step handler thread exception : <class 'serial.serialutil.SerialException'> File "/home/mark/Documents/github/vPiP/python/vPiP/serialHandler.py", line 106, in _stepHandlerThread dataRead = self.serialPort.read() File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 495, in read raise SerialException('device reports readiness to read but returned no data (device disconnected or multiple access on port?)')

I'm also seeing this when run from Linux Mint 18.1

I found the issue mentioned here: https://github.com/pyserial/pyserial/issues/17

MarkJB commented 7 years ago

If I use alt:///dev/usbX?class=VTIMESerial then the errors stop, but the steppers are still glitchy...

I changed the following (in serialHandler.py): #from serial import Serial import serial

def connect(self): # self.serialPort = Serial(self.config.serialPort, self.config.baud, timeout=10) self.serialPort = serial.serial_for_url('alt://' + self.config.serialPort + '?class=VTIMESerial', timeout=10) self.serialPort.baudrate = self.config.baud

When I run it I see two instances of Starting stepHandlerThread ?!?

Starting stepHandlerThread Connected to Vpip Starting stepHandlerThread Connected to Vpip Vpip __exit__

MarkJB commented 7 years ago

The issue wasn't pyserial, it was due to multiple serial processes starting up.

One created by a line in the config: polardraw = True The other in the calling python script: p.setPlotting(True)

Added Brians 'on the fly' fix to stop this happening in commit 153e3c0b294d1045a9eb5ccc3e128b42176718a8