Skip to content

Commit

Permalink
Fix for MacOS 10.11.1 serial timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
oskay committed Nov 12, 2015
1 parent 887cd7f commit eae9a7d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 32 deletions.
4 changes: 2 additions & 2 deletions inkscape_driver/eggbot.inx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<_name>EggBot Control</_name>
<id>command.evilmadscientist.eggbot.rev260b3</id>
<id>command.evilmadscientist.eggbot.rev263b1</id>
<dependency type="extension">org.inkscape.output.svg.inkscape</dependency>
<dependency type="executable" location="extensions">eggbot.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
Expand Down Expand Up @@ -156,7 +156,7 @@ selected number, which can be up to 100.
<_param name="instructions_general" type="description"
xml:space="preserve">
EggBot Control Inkscape extension
Release 2.6.1, dated 2015-10-25
Release 2.6.3, dated 2015-11-12

*EBB Firmware 1.96 or newer required for certain
functions.
Expand Down
39 changes: 9 additions & 30 deletions inkscape_driver/eggbot.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# eggbot.py
# Part of the Eggbot driver for Inkscape
# http://code.google.com/p/eggbotcode/
# https://github.com/evil-mad/EggBot
#
# Version 2.6.1, dated 2015-10-25
# REQUIRES: Pyserial version 2.7.0
# Version 2.6.3, dated 2015-11-12
# Tested with pyserial v 2.5.0 and v 2.7.0
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -479,7 +479,7 @@ def setupCommand( self ):
self.sendDisableMotors()

elif self.options.setupType == "toggle-pen":
self.doCommand( 'TP\r' ) #Toggle pen
self.doRequest( 'TP\r' ) #Toggle pen



Expand Down Expand Up @@ -1287,7 +1287,7 @@ def EggbotOpenSerial( self ):
def EggbotCloseSerial( self ):
try:
if self.serialPort:
self.serialPort.flush()
self.doRequest( 'v\r' ) # Final read to leave port in good state
self.serialPort.close()
if bDebug:
self.debugOut.close()
Expand All @@ -1297,31 +1297,21 @@ def EggbotCloseSerial( self ):

def testSerialPort( self, strComPort ):
'''
look at COM1 to COM20 and return a SerialPort object
Return a SerialPort object
for the first port with an EBB (EggBot controller board).
YOU are responsible for closing this serial port!
'''

try:
serialPort = serial.Serial( strComPort, timeout=1 ) # 1 second timeout!

serialPort.setRTS() # ??? remove
serialPort.setDTR() # ??? remove
serialPort = serial.Serial( strComPort, timeout=1.0 ) # 1 second timeout!
serialPort.flushInput()
serialPort.flushOutput()

time.sleep( 0.1 )

serialPort.write( 'v\r' )
strVersion = serialPort.readline()

if strVersion and strVersion.startswith( 'EBB' ):
# do version control here to check the firmware...
return serialPort

serialPort.write( 'v\r' )
strVersion = serialPort.readline() #Try a second query for El Capitan
# time.sleep( 0.1 )
strVersion = serialPort.readline() #Second query for El Capitan

if strVersion and strVersion.startswith( 'EBB' ):
# do version control here to check the firmware...
Expand All @@ -1332,28 +1322,18 @@ def testSerialPort( self, strComPort ):
return None

def getSerialPort( self ):

# Before searching, first check to see if the last known
# serial port is still good.

# serialPort = self.testSerialPort( self.svgSerialPort )
# if serialPort:
# return serialPort

# Try any devices which seem to have EBB boards attached
for strComPort in eggbot_scan.findEiBotBoards():
serialPort = self.testSerialPort( strComPort )
if serialPort:
self.svgSerialPort = strComPort
return serialPort

# Try any likely ports
for strComPort in eggbot_scan.findPorts():
serialPort = self.testSerialPort( strComPort )
if serialPort:
self.svgSerialPort = strComPort
return serialPort

return None

def doCommand( self, cmd ):
Expand Down Expand Up @@ -1390,5 +1370,4 @@ def distance( x, y ):
return sqrt( x * x + y * y )

e = EggBot()
#e.affect(output=False)
e.affect()

0 comments on commit eae9a7d

Please sign in to comment.