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
5161eb1a
Commit
5161eb1a
authored
May 22, 2011
by
kliment
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make printcore usable as a rudimentary command line print program
parent
14045828
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
10 deletions
+25
-10
printcore.py
printcore.py
+25
-10
No files found.
printcore.py
View file @
5161eb1a
#!/usr/bin/python
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
...
...
@@ -61,6 +63,8 @@ class printcore():
line
=
self
.
printer
.
readline
()
if
(
len
(
line
)
>
1
):
self
.
log
+=
[
line
]
if
loud
:
print
"RECV: "
,
line
if
(
line
.
startswith
(
'start'
)):
self
.
clear
=
True
self
.
online
=
True
...
...
@@ -76,7 +80,6 @@ class printcore():
if
"Resend"
in
line
or
"rs"
in
line
:
toresend
=
int
(
line
.
replace
(
":"
,
" "
)
.
split
()[
-
1
])
self
.
resendfrom
=
toresend
print
"TORESEND:"
,
self
.
resendfrom
self
.
clear
=
True
self
.
clear
=
True
#callback for disconnect
...
...
@@ -183,17 +186,29 @@ class printcore():
self
.
sentlines
[
lineno
]
=
command
if
(
self
.
printer
):
self
.
sent
+=
[
command
]
print
"SENT: "
,
command
self
.
printer
.
write
(
command
+
"
\n
"
)
if
__name__
==
'__main__'
:
#print "Usage: python printcore.py filename.gcode"
filename
=
"../prusamendel/sellsx_export.gcode"
if
len
(
sys
.
argv
)
>
1
:
filename
=
sys
.
argv
[
1
]
print
"Printing: "
+
filename
else
:
print
"Usage: python printcore.py filename.gcode"
loud
=
True
p
=
printcore
(
'/dev/ttyUSB0'
,
115200
)
time
.
sleep
(
2
)
testdata
=
[
i
.
replace
(
"
\n
"
,
""
)
for
i
in
open
(
"../prusamendel/sellsx_export.gcode"
)]
testdata
=
[
i
.
replace
(
"
\n
"
,
""
)
for
i
in
open
(
filename
)]
p
.
startprint
(
testdata
)
#time.sleep(1)
#p.pause()
#print "pause"
#time.sleep(5)
#p.resume()
try
:
while
(
p
.
printing
):
time
.
sleep
(
1
)
p
.
pause
()
print
"pause"
time
.
sleep
(
5
)
p
.
resume
()
time
.
sleep
(
1
)
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