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
7113ab99
Commit
7113ab99
authored
May 23, 2011
by
kliment
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add quiet option if statusrepor=True.
parent
5161eb1a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
10 deletions
+20
-10
printcore.py
printcore.py
+20
-10
No files found.
printcore.py
View file @
7113ab99
...
...
@@ -3,26 +3,26 @@ from serial import Serial
from
threading
import
Thread
import
time
import
getopt
,
sys
loud
=
False
class
printcore
():
def
__init__
(
self
,
port
=
None
,
baud
=
None
):
"""Initializes a printcore instance. Pass the port and baud rate to connect immediately
"""
self
.
baud
=
None
self
.
port
=
None
self
.
printer
=
None
self
.
clear
=
0
self
.
printer
=
None
#Serial instance connected to the printer, None when disconnected
self
.
clear
=
0
#clear to send, enabled after responses
self
.
online
=
False
#The printer has responded to the initial command and is active
self
.
printing
=
False
#is a print currently running, true if printing, false if paused
self
.
mainqueue
=
[]
self
.
priqueue
=
[]
self
.
readthread
=
None
self
.
queueindex
=
0
self
.
lineno
=
0
self
.
resendfrom
=-
1
self
.
online
=
False
self
.
printing
=
False
self
.
sentlines
=
{}
self
.
log
=
[]
self
.
sent
=
[]
self
.
loud
=
False
#emit sent and received lines to terminal
if
port
is
not
None
and
baud
is
not
None
:
#print port, baud
self
.
connect
(
port
,
baud
)
...
...
@@ -63,7 +63,7 @@ class printcore():
line
=
self
.
printer
.
readline
()
if
(
len
(
line
)
>
1
):
self
.
log
+=
[
line
]
if
loud
:
if
self
.
loud
:
print
"RECV: "
,
line
if
(
line
.
startswith
(
'start'
)):
self
.
clear
=
True
...
...
@@ -186,6 +186,7 @@ class printcore():
self
.
sentlines
[
lineno
]
=
command
if
(
self
.
printer
):
self
.
sent
+=
[
command
]
if
self
.
loud
:
print
"SENT: "
,
command
self
.
printer
.
write
(
command
+
"
\n
"
)
...
...
@@ -197,8 +198,10 @@ if __name__ == '__main__':
print
"Printing: "
+
filename
else
:
print
"Usage: python printcore.py filename.gcode"
loud
=
True
#sys.exit(2)
p
=
printcore
(
'/dev/ttyUSB0'
,
115200
)
p
.
loud
=
True
statusreport
=
False
time
.
sleep
(
2
)
testdata
=
[
i
.
replace
(
"
\n
"
,
""
)
for
i
in
open
(
filename
)]
p
.
startprint
(
testdata
)
...
...
@@ -208,7 +211,14 @@ if __name__ == '__main__':
#time.sleep(5)
#p.resume()
try
:
if
statusreport
:
p
.
loud
=
False
sys
.
stdout
.
write
(
"Progress: 00.0
%
"
)
sys
.
stdout
.
flush
()
while
(
p
.
printing
):
time
.
sleep
(
1
)
if
statusreport
:
sys
.
stdout
.
write
(
"
\b\b\b\b
%02.1
f
%%
"
%
(
100
*
float
(
p
.
queueindex
)
/
len
(
p
.
mainqueue
),)
)
sys
.
stdout
.
flush
()
except
:
p
.
disconnect
()
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