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
a1fbee42
Commit
a1fbee42
authored
Jun 05, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disconnect Pronterface after 4 write failures
parent
126720a5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
printcore.py
printcore.py
+6
-0
pronterface.py
pronterface.py
+7
-1
No files found.
printcore.py
View file @
a1fbee42
...
@@ -70,6 +70,7 @@ class printcore():
...
@@ -70,6 +70,7 @@ class printcore():
self
.
sentlines
=
{}
self
.
sentlines
=
{}
self
.
log
=
deque
(
maxlen
=
10000
)
self
.
log
=
deque
(
maxlen
=
10000
)
self
.
sent
=
[]
self
.
sent
=
[]
self
.
writefailures
=
0
self
.
tempcb
=
None
#impl (wholeline)
self
.
tempcb
=
None
#impl (wholeline)
self
.
recvcb
=
None
#impl (wholeline)
self
.
recvcb
=
None
#impl (wholeline)
self
.
sendcb
=
None
#impl (wholeline)
self
.
sendcb
=
None
#impl (wholeline)
...
@@ -134,6 +135,7 @@ class printcore():
...
@@ -134,6 +135,7 @@ class printcore():
is_serial
=
False
is_serial
=
False
except
:
except
:
pass
pass
self
.
writefailures
=
0
if
not
is_serial
:
if
not
is_serial
:
self
.
printer_tcp
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
printer_tcp
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
timeout
=
0.25
self
.
timeout
=
0.25
...
@@ -502,12 +504,16 @@ class printcore():
...
@@ -502,12 +504,16 @@ class printcore():
try
:
try
:
self
.
printer
.
write
(
str
(
command
+
"
\n
"
))
self
.
printer
.
write
(
str
(
command
+
"
\n
"
))
self
.
printer
.
flush
()
self
.
printer
.
flush
()
self
.
writefailures
=
0
except
socket
.
error
as
e
:
except
socket
.
error
as
e
:
print
"Can't write to printer (disconnected?) (Socket error {0}): {1}"
.
format
(
e
.
errno
,
e
.
strerror
)
print
"Can't write to printer (disconnected?) (Socket error {0}): {1}"
.
format
(
e
.
errno
,
e
.
strerror
)
self
.
writefailures
+=
1
except
SerialException
as
e
:
except
SerialException
as
e
:
print
"Can't write to printer (disconnected?) (SerialException): {0}"
.
format
(
e
)
print
"Can't write to printer (disconnected?) (SerialException): {0}"
.
format
(
e
)
self
.
writefailures
+=
1
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
"Socket connection broken, disconnected. ({0}): {1}"
.
format
(
e
.
errno
,
e
.
strerror
)
print
"Socket connection broken, disconnected. ({0}): {1}"
.
format
(
e
.
errno
,
e
.
strerror
)
self
.
writefailures
+=
1
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
baud
=
115200
baud
=
115200
...
...
pronterface.py
View file @
a1fbee42
...
@@ -1229,6 +1229,12 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -1229,6 +1229,12 @@ class PronterWindow(MainWindow, pronsole.pronsole):
string
+=
_
(
" Z:
%.3
f mm"
)
%
self
.
curlayer
string
+=
_
(
" Z:
%.3
f mm"
)
%
self
.
curlayer
wx
.
CallAfter
(
self
.
statusbar
.
SetStatusText
,
string
)
wx
.
CallAfter
(
self
.
statusbar
.
SetStatusText
,
string
)
wx
.
CallAfter
(
self
.
gviz
.
Refresh
)
wx
.
CallAfter
(
self
.
gviz
.
Refresh
)
if
self
.
p
.
online
:
if
self
.
p
.
writefailures
>=
4
:
print
_
(
"Disconnecting after 4 failed writes."
)
self
.
status_thread
=
None
self
.
disconnect
()
return
if
self
.
monitor
and
self
.
p
.
online
:
if
self
.
monitor
and
self
.
p
.
online
:
if
self
.
sdprinting
:
if
self
.
sdprinting
:
self
.
p
.
send_now
(
"M27"
)
self
.
p
.
send_now
(
"M27"
)
...
@@ -1614,7 +1620,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -1614,7 +1620,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self
.
predisconnect_queueindex
=
self
.
p
.
queueindex
self
.
predisconnect_queueindex
=
self
.
p
.
queueindex
self
.
predisconnect_layer
=
self
.
curlayer
self
.
predisconnect_layer
=
self
.
curlayer
def
disconnect
(
self
,
event
):
def
disconnect
(
self
,
event
=
None
):
print
_
(
"Disconnected."
)
print
_
(
"Disconnected."
)
if
self
.
p
.
printing
or
self
.
p
.
paused
or
self
.
paused
:
if
self
.
p
.
printing
or
self
.
p
.
paused
or
self
.
paused
:
self
.
store_predisconnect_state
()
self
.
store_predisconnect_state
()
...
...
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