Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mods
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
mods
Commits
389e18eb
Commit
389e18eb
authored
5 years ago
by
Neil Gershenfeld
Browse files
Options
Downloads
Patches
Plain Diff
test py serial
parent
2a2b2ad2
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
modules/socket/server/serialpy
+3
-2
3 additions, 2 deletions
modules/socket/server/serialpy
programs/machines/Roland/mill/MDX-20/PCB png
+1
-1
1 addition, 1 deletion
programs/machines/Roland/mill/MDX-20/PCB png
py/serialserver.py
+9
-10
9 additions, 10 deletions
py/serialserver.py
with
13 additions
and
13 deletions
modules/socket/server/serialpy
+
3
−
2
View file @
389e18eb
...
@@ -28,7 +28,7 @@ var init = function() {
...
@@ -28,7 +28,7 @@ var init = function() {
mod.address.value = '127.0.0.1'
mod.address.value = '127.0.0.1'
mod.port.value = 1234
mod.port.value = 1234
mod.device.value = '/dev/ttyUSB0'
mod.device.value = '/dev/ttyUSB0'
mod.baud.value =
1152
00
mod.baud.value =
96
00
mod.flow_dsrdtr.checked = true
mod.flow_dsrdtr.checked = true
mod.socket = null
mod.socket = null
socket_open()
socket_open()
...
@@ -216,7 +216,8 @@ var interface = function(div){
...
@@ -216,7 +216,8 @@ var interface = function(div){
}
}
else if (mod.label.nodeValue == 'send file') {
else if (mod.label.nodeValue == 'send file') {
socket_send(JSON.stringify(mod.job))
socket_send(JSON.stringify(mod.job))
mod.label.nodeValue = 'cancel'
//mod.label.nodeValue = 'cancel'
mod.label.nodeValue = 'sending ...'
}
}
else if (mod.label.nodeValue == 'cancel') {
else if (mod.label.nodeValue == 'cancel') {
mod.command = {}
mod.command = {}
...
...
This diff is collapsed.
Click to expand it.
programs/machines/Roland/mill/MDX-20/PCB png
+
1
−
1
View file @
389e18eb
Source diff could not be displayed: it is too large. Options to address this:
view the blob
.
This diff is collapsed.
Click to expand it.
py/serialserver.py
100755 → 100644
+
9
−
10
View file @
389e18eb
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
#
#
# imports
# imports
#
#
import
sys
,
serial
,
asyncio
,
websockets
,
json
import
sys
,
serial
,
asyncio
,
websockets
,
json
,
time
#
#
# command line
# command line
#
#
...
@@ -50,7 +50,6 @@ async def receive(websocket,path):
...
@@ -50,7 +50,6 @@ async def receive(websocket,path):
device
=
vars
[
'
device
'
]
device
=
vars
[
'
device
'
]
speed
=
int
(
vars
[
'
baud
'
])
speed
=
int
(
vars
[
'
baud
'
])
flow
=
vars
[
'
flow
'
]
flow
=
vars
[
'
flow
'
]
print
(
f
"
open
{
device
}
at
{
speed
}
with
{
flow
}
"
)
try
:
try
:
if
(
flow
==
"
xonxoff
"
):
if
(
flow
==
"
xonxoff
"
):
s
=
serial
.
Serial
(
s
=
serial
.
Serial
(
...
@@ -66,25 +65,26 @@ async def receive(websocket,path):
...
@@ -66,25 +65,26 @@ async def receive(websocket,path):
device
,
baudrate
=
speed
,
timeout
=
0
)
device
,
baudrate
=
speed
,
timeout
=
0
)
s
.
flushInput
()
s
.
flushInput
()
s
.
flushOutput
()
s
.
flushOutput
()
await
websocket
.
send
(
f
"
open
{
device
}
at
{
speed
}
with
{
flow
}
"
)
except
serial
.
SerialException
as
err
:
except
serial
.
SerialException
as
err
:
print
(
err
)
await
websocket
.
send
(
str
(
err
))
await
websocket
.
send
(
str
(
err
))
elif
(
vars
[
'
type
'
]
==
'
close
'
):
await
websocket
.
send
(
f
"
close
{
device
}
"
)
s
.
close
()
elif
(
vars
[
'
type
'
]
==
'
command
'
):
elif
(
vars
[
'
type
'
]
==
'
command
'
):
#
#
# send command
# send command
#
#
print
(
'
send command
'
)
data
=
vars
[
'
contents
'
]
data
=
vars
[
'
contents
'
]
n
=
0
n
=
0
for
c
in
data
:
for
c
in
data
:
print
(
c
)
if
(
flow
==
"
dsrdtr
"
):
if
(
flow
==
"
dsrdtr
"
):
while
(
s
.
getDSR
()
!=
True
):
while
(
s
.
getDSR
()
!=
True
):
time
.
sleep
(
0.001
)
time
.
sleep
(
0.001
)
elif
(
flow
==
"
rtscts
"
):
elif
(
flow
==
"
rtscts
"
):
while
(
s
.
getCTS
()
!=
True
):
while
(
s
.
getCTS
()
!=
True
):
time
.
sleep
(
0.001
)
time
.
sleep
(
0.001
)
s
.
write
(
c
)
s
.
write
(
c
.
encode
(
'
ascii
'
)
)
s
.
flush
()
s
.
flush
()
n
+=
1
n
+=
1
percent
=
(
100.0
*
n
)
/
len
(
data
)
percent
=
(
100.0
*
n
)
/
len
(
data
)
...
@@ -93,22 +93,21 @@ async def receive(websocket,path):
...
@@ -93,22 +93,21 @@ async def receive(websocket,path):
#
#
# send file
# send file
#
#
print
(
'
send file
'
)
data
=
vars
[
'
contents
'
]
data
=
vars
[
'
contents
'
]
n
=
0
n
=
0
for
c
in
data
:
for
c
in
data
:
print
(
c
)
if
(
flow
==
"
dsrdtr
"
):
if
(
flow
==
"
dsrdtr
"
):
while
(
s
.
getDSR
()
!=
True
):
while
(
s
.
getDSR
()
!=
True
):
time
.
sleep
(
0.001
)
time
.
sleep
(
0.001
)
elif
(
flow
==
"
rtscts
"
):
elif
(
flow
==
"
rtscts
"
):
while
(
s
.
getCTS
()
!=
True
):
while
(
s
.
getCTS
()
!=
True
):
time
.
sleep
(
0.001
)
time
.
sleep
(
0.001
)
s
.
write
(
c
)
s
.
write
(
c
.
encode
(
'
ascii
'
)
)
s
.
flush
()
s
.
flush
()
n
+=
1
n
+=
1
percent
=
(
100.0
*
n
)
/
len
(
data
)
percent
=
(
100.0
*
n
)
/
len
(
data
)
await
websocket
.
send
(
str
(
percent
))
await
websocket
.
send
(
str
(
round
(
percent
))
+
'
%
'
)
await
websocket
.
send
(
"
done
"
)
#
#
# start server
# start server
#
#
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment