Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions silhouette/Graphtec.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def __init__(self, log=sys.stderr):
print("Searching for bt devices on OSX", file=log)
# on osx a rfcomm port is created and linked automatically when the cameo is connected
# TODO add support for other machines. I would expect files like CAMEO3-... and PORTRAIT2-...
pat = re.compile("tty\.(PORTRAIT2|CAMEO3|CAMEO4)-.*")

@FlyingSamson FlyingSamson Sep 27, 2020

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about this? Normally I would expect the old code to match a dot character (".") whereas the new code would match any character but newlines?

We probably should use a raw string here, too. However, the current branch version using PyBluez does not have this problem anyways.

pat = re.compile("tty.(PORTRAIT2|CAMEO3|CAMEO4)-.*")
# get first matching port
rfcomms = [f for f in os.listdir("/dev/") if pat.match(f)]
rfcomm = rfcomms[0] if rfcomms else None
Expand All @@ -414,7 +414,7 @@ def __init__(self, log=sys.stderr):
else: # linux
print("Searching for bt devices on Linux", file=log)

pat = re.compile("tty\.(PORTRAIT2|CAMEO3|CAMEO4)-?.*")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

pat = re.compile("tty.(PORTRAIT2|CAMEO3|CAMEO4)-?.*")
# get first matching port
rfcomms = [f for f in os.listdir("/dev/") if pat.match(f)]
rfcomm = rfcomms[0] if rfcomms else None
Expand Down Expand Up @@ -1125,7 +1125,7 @@ def draw_mm_cmd(self, mmy, mmx):
return "D%d,%d" % (_mm_2_SU(mmy), _mm_2_SU(mmx))

def upper_left_mm_cmd(self, mmy, mmx):
""" \y,x """
r""" \y,x """
return "\\%d,%d" % (_mm_2_SU(mmy), _mm_2_SU(mmx))

def lower_right_mm_cmd(self, mmy, mmx):
Expand Down Expand Up @@ -1398,7 +1398,8 @@ def plot(self, mediawidth=210.0, mediaheight=297.0, margintop=None,
self.draw_mm_cmd(bbox['ury'], bbox['llx'])]

# potentially long command string needs extra care
self.safe_send_command(cmd_list)

@FlyingSamson FlyingSamson Sep 27, 2020

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I also stumbled over that one, but I think it only occurs if sending nothing to the device, no? If that were the case, this should probably be handled from the plugin itself, i.e. we should test directly when the extensions is launched, whether a object/path was currently selected.

But it probably doesn't hurt to catch it here also. Just saying.

if cmd_list:
self.safe_send_command(cmd_list)

self.wait_for_ready()

Expand Down