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
d9018826
Commit
d9018826
authored
Apr 01, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factorize connection handling to pronsole
parent
d95bd881
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
20 deletions
+26
-20
pronsole.py
printrun/pronsole.py
+25
-1
pronterface.py
printrun/pronterface.py
+1
-19
No files found.
printrun/pronsole.py
View file @
d9018826
...
...
@@ -28,6 +28,8 @@ import logging
import
traceback
import
re
from
serial
import
SerialException
from
.
import
printcore
from
.utils
import
install_locale
,
run_command
,
get_command_output
,
\
format_time
,
format_duration
,
RemainingTimeEstimator
,
\
...
...
@@ -1006,6 +1008,28 @@ class pronsole(cmd.Cmd):
# Printer connection handling
# --------------------------------------------------------------
def
connect_to_printer
(
self
,
port
,
baud
):
try
:
self
.
p
.
connect
(
port
,
baud
)
return
True
except
SerialException
as
e
:
# Currently, there is no errno, but it should be there in the future
if
e
.
errno
==
2
:
self
.
logError
(
_
(
"Error: You are trying to connect to a non-existing port."
))
elif
e
.
errno
==
8
:
self
.
logError
(
_
(
"Error: You don't have permission to open
%
s."
)
%
port
)
self
.
logError
(
_
(
"You might need to add yourself to the dialout group."
))
else
:
self
.
logError
(
traceback
.
format_exc
())
# Kill the scope anyway
return
False
except
OSError
as
e
:
if
e
.
errno
==
2
:
self
.
logError
(
_
(
"Error: You are trying to connect to a non-existing port."
))
else
:
self
.
logError
(
traceback
.
format_exc
())
return
False
def
do_connect
(
self
,
l
):
a
=
l
.
split
()
p
=
self
.
scanserial
()
...
...
@@ -1031,7 +1055,7 @@ class pronsole(cmd.Cmd):
if
baud
!=
self
.
settings
.
baudrate
:
self
.
settings
.
baudrate
=
baud
self
.
save_in_rc
(
"set baudrate"
,
"set baudrate
%
d"
%
baud
)
self
.
p
.
connect
(
port
,
baud
)
self
.
connect_to_printer
(
port
,
baud
)
def
help_connect
(
self
):
self
.
log
(
"Connect to printer"
)
...
...
printrun/pronterface.py
View file @
d9018826
...
...
@@ -47,7 +47,6 @@ except:
from
printrun.gui.widgets
import
SpecialButton
,
MacroEditor
,
\
PronterOptions
,
ButtonEdit
from
serial
import
SerialException
winsize
=
(
800
,
500
)
layerindex
=
0
...
...
@@ -1017,24 +1016,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self
.
paused
=
0
if
self
.
sdprinting
:
self
.
p
.
send_now
(
"M26 S0"
)
try
:
self
.
p
.
connect
(
port
,
baud
)
except
SerialException
as
e
:
# Currently, there is no errno, but it should be there in the future
if
e
.
errno
==
2
:
self
.
logError
(
_
(
"Error: You are trying to connect to a non-existing port."
))
elif
e
.
errno
==
8
:
self
.
logError
(
_
(
"Error: You don't have permission to open
%
s."
)
%
port
)
self
.
logError
(
_
(
"You might need to add yourself to the dialout group."
))
else
:
self
.
logError
(
traceback
.
format_exc
())
# Kill the scope anyway
return
except
OSError
as
e
:
if
e
.
errno
==
2
:
self
.
logError
(
_
(
"Error: You are trying to connect to a non-existing port."
))
else
:
self
.
logError
(
traceback
.
format_exc
())
if
not
self
.
connect_to_printer
(
port
,
baud
):
return
self
.
statuscheck
=
True
if
port
!=
self
.
settings
.
port
:
...
...
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