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
f32c5868
Commit
f32c5868
authored
May 30, 2011
by
kliment
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tab completion and serial port detection on windows
parent
62515bed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
3 deletions
+31
-3
pronsole.py
pronsole.py
+31
-3
No files found.
pronsole.py
View file @
f32c5868
import
cmd
,
printcore
,
sys
import
cmd
,
printcore
,
sys
#help(cmd)
#help(cmd)
import
glob
,
os
,
time
import
glob
,
os
,
time
if
os
.
name
==
"nt"
:
try
:
import
_winreg
except
:
pass
READLINE
=
True
try
:
import
readline
except
:
try
:
import
pyreadline
except
:
READLINE
=
False
#neither readline module is available
def
dosify
(
name
):
def
dosify
(
name
):
return
name
.
split
(
"."
)[
0
][:
8
]
+
".g"
return
name
.
split
(
"."
)[
0
][:
8
]
+
".g"
...
@@ -10,6 +22,8 @@ def dosify(name):
...
@@ -10,6 +22,8 @@ def dosify(name):
class
pronsole
(
cmd
.
Cmd
):
class
pronsole
(
cmd
.
Cmd
):
def
__init__
(
self
):
def
__init__
(
self
):
cmd
.
Cmd
.
__init__
(
self
)
cmd
.
Cmd
.
__init__
(
self
)
if
not
READLINE
:
self
.
completekey
=
None
self
.
p
=
printcore
.
printcore
()
self
.
p
=
printcore
.
printcore
()
self
.
prompt
=
"PC>"
self
.
prompt
=
"PC>"
self
.
p
.
onlinecb
=
self
.
online
self
.
p
.
onlinecb
=
self
.
online
...
@@ -18,8 +32,18 @@ class pronsole(cmd.Cmd):
...
@@ -18,8 +32,18 @@ class pronsole(cmd.Cmd):
def
scanserial
(
self
):
def
scanserial
(
self
):
"""scan for available ports. return a list of device names."""
"""scan for available ports. return a list of device names."""
#TODO: Add windows port detection
baselist
=
[]
return
glob
.
glob
(
'/dev/ttyUSB*'
)
+
glob
.
glob
(
'/dev/ttyACM*'
)
+
glob
.
glob
(
"/dev/tty.*"
)
+
glob
.
glob
(
"/dev/cu.*"
)
+
glob
.
glob
(
"/dev/rfcomm*"
)
if
os
.
name
==
"nt"
:
try
:
key
=
_winreg
.
OpenKey
(
_winreg
.
HKEY_LOCAL_MACHINE
,
"HARDWARE
\\
DEVICEMAP
\\
SERIALCOMM"
)
i
=
0
while
(
1
):
baselist
+=
[
_winreg
.
EnumValue
(
key
,
i
)[
1
]]
i
+=
1
except
:
pass
return
baselist
+
glob
.
glob
(
'/dev/ttyUSB*'
)
+
glob
.
glob
(
'/dev/ttyACM*'
)
+
glob
.
glob
(
"/dev/tty.*"
)
+
glob
.
glob
(
"/dev/cu.*"
)
+
glob
.
glob
(
"/dev/rfcomm*"
)
def
online
(
self
):
def
online
(
self
):
print
"Printer is now online"
print
"Printer is now online"
...
@@ -106,6 +130,7 @@ class pronsole(cmd.Cmd):
...
@@ -106,6 +130,7 @@ class pronsole(cmd.Cmd):
def
help_load
(
self
):
def
help_load
(
self
):
print
"Loads a gcode file (with tab-completion)"
print
"Loads a gcode file (with tab-completion)"
def
do_upload
(
self
,
l
):
def
do_upload
(
self
,
l
):
if
len
(
l
)
==
0
:
if
len
(
l
)
==
0
:
print
"No file name given."
print
"No file name given."
...
@@ -242,6 +267,9 @@ class pronsole(cmd.Cmd):
...
@@ -242,6 +267,9 @@ class pronsole(cmd.Cmd):
def
do_EOF
(
self
,
l
):
def
do_EOF
(
self
,
l
):
print
"Use ^C to exit."
print
"Use ^C to exit."
def
help_eof
(
self
):
self
.
do_EOF
(
""
)
def
help_help
(
self
):
def
help_help
(
self
):
self
.
do_help
(
""
)
self
.
do_help
(
""
)
...
...
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