Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
99ec219e
Commit
99ec219e
authored
Aug 02, 2012
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improvements to connect and disconnect
parent
b4cc74f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
printcore.py
printrun/printcore.py
+14
-4
No files found.
printrun/printcore.py
View file @
99ec219e
...
...
@@ -49,6 +49,8 @@ class printcore():
self
.
loud
=
False
#emit sent and received lines to terminal
self
.
greetings
=
[
'start'
,
'Grbl '
]
self
.
wait
=
0
# default wait period for send(), send_now()
self
.
read_thread
=
None
self
.
stop_read_thread
=
False
if
port
is
not
None
and
baud
is
not
None
:
#print port, baud
self
.
connect
(
port
,
baud
)
...
...
@@ -58,7 +60,11 @@ class printcore():
def
disconnect
(
self
):
"""Disconnects from printer and pauses the print
"""
if
(
self
.
printer
):
if
self
.
printer
:
if
self
.
read_thread
:
self
.
stop_read_thread
=
True
self
.
read_thread
.
join
()
self
.
read_thread
=
None
self
.
printer
.
close
()
self
.
printer
=
None
self
.
online
=
False
...
...
@@ -74,13 +80,15 @@ class printcore():
if
baud
is
not
None
:
self
.
baud
=
baud
if
self
.
port
is
not
None
and
self
.
baud
is
not
None
:
self
.
printer
=
Serial
(
port
=
self
.
port
,
baudrate
=
self
.
baud
,
timeout
=
5
)
Thread
(
target
=
self
.
_listen
)
.
start
()
self
.
printer
=
Serial
(
port
=
self
.
port
,
baudrate
=
self
.
baud
,
timeout
=
1
,
dsrdtr
=
True
)
self
.
stop_read_thread
=
False
self
.
read_thread
=
Thread
(
target
=
self
.
_listen
)
self
.
read_thread
.
start
()
def
reset
(
self
):
"""Reset the printer
"""
if
(
self
.
printer
)
:
if
self
.
printer
:
self
.
printer
.
setDTR
(
1
)
self
.
printer
.
setDTR
(
0
)
...
...
@@ -96,6 +104,8 @@ class printcore():
if
(
not
self
.
online
and
not
self
.
printing
):
# send M105 to initiate connection
self
.
_send
(
"M105"
)
while
(
True
):
if
self
.
stop_read_thread
:
return
if
(
not
self
.
printer
or
not
self
.
printer
.
isOpen
):
break
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment