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
b679451a
Commit
b679451a
authored
May 26, 2011
by
kliment
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add callback support
parent
a1cbd121
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
printcore.py
printcore.py
+25
-0
No files found.
printcore.py
View file @
b679451a
...
...
@@ -22,6 +22,13 @@ class printcore():
self
.
sentlines
=
{}
self
.
log
=
[]
self
.
sent
=
[]
self
.
tempcb
=
None
#impl (wholeline)
self
.
recvcb
=
None
#impl (wholeline)
self
.
sendcb
=
None
#impl (wholeline)
self
.
errorcb
=
None
#impl (wholeline)
self
.
startcb
=
None
#impl ()
self
.
endcb
=
None
#impl ()
self
.
onlinecb
=
None
#impl ()
self
.
loud
=
False
#emit sent and received lines to terminal
if
port
is
not
None
and
baud
is
not
None
:
#print port, baud
...
...
@@ -63,18 +70,30 @@ class printcore():
line
=
self
.
printer
.
readline
()
if
(
len
(
line
)
>
1
):
self
.
log
+=
[
line
]
if
self
.
recvcb
is
not
None
:
self
.
recvcb
(
line
)
if
self
.
loud
:
print
"RECV: "
,
line
if
(
line
.
startswith
(
'start'
)):
self
.
clear
=
True
if
not
self
.
online
and
self
.
onlinecb
is
not
None
:
self
.
onlinecb
()
self
.
online
=
True
elif
(
line
.
startswith
(
'ok'
)):
self
.
clear
=
True
if
not
self
.
online
and
self
.
onlinecb
is
not
None
:
self
.
onlinecb
()
self
.
online
=
True
self
.
resendfrom
=-
1
#put temp handling here
if
"T:"
in
line
and
self
.
tempcb
is
not
None
:
self
.
tempcb
(
line
)
#callback for temp, status, whatever
elif
(
line
.
startswith
(
'Error'
)):
if
self
.
errorcb
is
not
None
:
self
.
errorcb
(
line
)
#callback for errors
pass
if
"Resend"
in
line
or
"rs"
in
line
:
...
...
@@ -143,8 +162,12 @@ class printcore():
def
_print
(
self
):
#callback for printing started
if
self
.
startcb
is
not
None
:
self
.
startcb
()
while
(
self
.
printing
and
self
.
printer
and
self
.
online
):
self
.
_sendnext
()
if
self
.
endcb
is
not
None
:
self
.
endcb
()
#callback for printing done
def
_sendnext
(
self
):
...
...
@@ -188,6 +211,8 @@ class printcore():
self
.
sent
+=
[
command
]
if
self
.
loud
:
print
"SENT: "
,
command
if
self
.
sendcb
is
not
None
:
self
.
sendcb
(
command
)
self
.
printer
.
write
(
command
+
"
\n
"
)
if
__name__
==
'__main__'
:
...
...
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