mirror of
https://github.com/phooky/Apple-410.git
synced 2024-06-01 03:41:32 +00:00
adding flags for CTS-DSR hack and "safe" flow control
This commit is contained in:
parent
57474bad8c
commit
49db82f099
|
@ -11,19 +11,28 @@ def plot_to_svg(instream, outstream):
|
||||||
|
|
||||||
class Apple410:
|
class Apple410:
|
||||||
"""A simple class for queing up commands for the Apple 410"""
|
"""A simple class for queing up commands for the Apple 410"""
|
||||||
def __init__(self, portname, baud=9600):
|
def __init__(self, portname, baud=9600, flow_control_safe=False, cts_hack=False):
|
||||||
self.serial = serial.Serial(portname, baud, rtscts=True, dsrdtr=True, timeout=0.1)
|
self.serial = serial.Serial(portname, baud, rtscts=False, dsrdtr=True, timeout=0.1)
|
||||||
self.pos = (0,0)
|
self.pos = (0,0)
|
||||||
self.wd = self.vp = (0,0,2394,1759)
|
self.wd = self.vp = (0,0,2394,1759)
|
||||||
|
self.flow_control_safe = flow_control_safe
|
||||||
|
self.cts_hack = cts_hack
|
||||||
|
|
||||||
def sendchar(self, c):
|
def sendchar(self, c):
|
||||||
self.serial.flush()
|
if self.flow_control_safe:
|
||||||
while not self.serial.cts:
|
self.serial.write(c.encode('ascii'))
|
||||||
time.sleep(0.2)
|
elif self.cts_hack:
|
||||||
while not self.serial.dsr:
|
self.serial.flush()
|
||||||
time.sleep(0.2)
|
while not self.serial.cts:
|
||||||
self.serial.write(c.encode('ascii'))
|
time.sleep(0.2)
|
||||||
self.serial.flush()
|
self.serial.write(c.encode('ascii'))
|
||||||
|
self.serial.flush()
|
||||||
|
else:
|
||||||
|
self.serial.flush()
|
||||||
|
while not self.serial.dsr:
|
||||||
|
time.sleep(0.2)
|
||||||
|
self.serial.write(c.encode('ascii'))
|
||||||
|
self.serial.flush()
|
||||||
|
|
||||||
def send(self, command):
|
def send(self, command):
|
||||||
for c in command:
|
for c in command:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user