Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lu Xu
slapos
Commits
cfbef55a
Commit
cfbef55a
authored
Oct 26, 2023
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/js-drone: process all logs
Process all available logs to avoid delay in log printing.
parent
0e9402eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
83 deletions
+57
-83
software/js-drone/buildout.hash.cfg
software/js-drone/buildout.hash.cfg
+1
-1
software/js-drone/drone-scripts/worker.js.jinja2
software/js-drone/drone-scripts/worker.js.jinja2
+2
-1
software/js-drone/test/test.py
software/js-drone/test/test.py
+54
-81
No files found.
software/js-drone/buildout.hash.cfg
View file @
cfbef55a
...
@@ -42,4 +42,4 @@ md5sum = dfa140d70d8a9cadc6cee865be4e8c26
...
@@ -42,4 +42,4 @@ md5sum = dfa140d70d8a9cadc6cee865be4e8c26
[worker]
[worker]
_update_hash_filename_ = drone-scripts/worker.js.jinja2
_update_hash_filename_ = drone-scripts/worker.js.jinja2
md5sum =
5e642dc35d86b7d7636532ffc9cc2bdb
md5sum =
39c25f9083151a18318ed8ee4ad4fdbe
software/js-drone/drone-scripts/worker.js.jinja2
View file @
cfbef55a
...
@@ -235,8 +235,9 @@ import { evalScript, fdopen, loadFile, open } from "std";
...
@@ -235,8 +235,9 @@ import { evalScript, fdopen, loadFile, open } from "std";
if (clientId !== undefined) {
if (clientId !== undefined) {
log = getLog();
log = getLog();
if
(log.length > 0) {
while
(log.length > 0) {
user_me.writeWebsocketMessage(JSON.stringify({log: log}));
user_me.writeWebsocketMessage(JSON.stringify({log: log}));
log = getLog();
}
}
}
}
...
...
software/js-drone/test/test.py
View file @
cfbef55a
...
@@ -31,7 +31,9 @@ import os
...
@@ -31,7 +31,9 @@ import os
import
socket
import
socket
import
struct
import
struct
import
time
import
time
import
websocket
from
contextlib
import
closing
from
websocket
import
create_connection
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
...
@@ -277,83 +279,54 @@ class SubscriberTestCase(SlapOSInstanceTestCase):
...
@@ -277,83 +279,54 @@ class SubscriberTestCase(SlapOSInstanceTestCase):
self
.
assertIn
(
expected_string
,
f
.
readlines
())
self
.
assertIn
(
expected_string
,
f
.
readlines
())
def
test_pubsub_subscription
(
self
):
def
test_pubsub_subscription
(
self
):
ws
=
websocket
.
WebSocket
()
with
closing
(
create_connection
(
self
.
websocket_server_address
,
timeout
=
5
))
as
conn
:
ws
.
connect
(
self
.
websocket_server_address
,
timeout
=
5
)
# Check if first message is 'Unknown instruction IP' where IP is client IPv6 address
# Check if first message is 'Unknown instruction IP' where IP is client IPv6 address
self
.
assertIn
(
self
.
assertIn
(
b'Unknown instruction %s'
%
conn
.
sock
.
getsockname
()[
0
].
encode
(),
b'Unknown instruction %s'
%
ws
.
sock
.
getsockname
()[
0
].
encode
(),
conn
.
recv_frame
().
data
,
ws
.
recv_frame
().
data
,
)
)
self
.
assertIn
(
self
.
assertIn
(
b'
\
\
u001b[32minfo/userland
\
\
u001b[0m
\
\
tfieldsSize 3
\
\
n"}'
,
b'
\
\
u001b[32minfo/userland
\
\
u001b[0m
\
\
tfieldsSize 3
\
\
n"}'
,
ws
.
recv_frame
().
data
,
ws
.
recv_frame
().
data
,
)
)
self
.
assertIn
(
self
.
assertEqual
(
b'
\
\
u001b[32minfo/client
\
\
u001b[0m
\
\
tReceived position of drone 0: %.6f ? %.6f ? %.2f m %.2f m
\
\
n"}'
%
(
0
,
0
,
0
,
0
),
ws
.
recv_frame
().
data
,
ws
.
recv_frame
().
data
,
b''
.
join
((
)
b'{"drone_dict":{"0":{"latitude":'
,
self
.
assertIn
(
b'"%.6f","longitude":"%.6f","altitude":"%.2f",'
%
(
0
,
0
,
0
),
b'
\
\
u001b[32minfo/client
\
\
u001b[0m
\
\
tReceived speed of drone 0: %.2f ? %.2f m/s %.2f m/s
\
\
n"}'
%
(
0
,
0
,
0
),
b'"yaw":"%.2f","speed":"%.2f","climbRate":"%.2f",'
%
(
0
,
0
,
0
),
ws
.
recv_frame
().
data
,
b'"timestamp":%d}}}'
%
0
,
)
)),
self
.
assertIn
(
)
b'
\
\
u001b[32minfo/userland
\
\
u001b[0m
\
\
tfieldsSize 1
\
\
n"}'
,
self
.
assertIn
(
ws
.
recv_frame
().
data
,
b'
\
\
u001b[32minfo/client
\
\
u001b[0m
\
\
tReceived position of drone 0: %.6f ? %.6f ? %.2f m %.2f m
\
\
n"}'
%
(
0
,
0
,
0
,
0
),
)
ws
.
recv_frame
().
data
,
self
.
assertEqual
(
)
conn
.
recv_frame
().
data
,
self
.
assertEqual
(
b''
.
join
((
ws
.
recv_frame
().
data
,
b'{"drone_dict":{"0":{"latitude":'
,
b''
.
join
((
b'"%.6f","longitude":"%.6f","altitude":"%.2f",'
%
(
0
,
0
,
0
),
b'{"drone_dict":{"0":{"latitude":'
,
b'"yaw":"%.2f","speed":"%.2f","climbRate":"%.2f",'
%
(
0
,
0
,
0
),
b'"%.6f","longitude":"%.6f","altitude":"%.2f",'
%
(
0
,
0
,
0
),
b'"timestamp":%d}}}'
%
0
,
b'"yaw":"%.2f","speed":"%.2f","climbRate":"%.2f",'
%
(
0
,
0
,
0
),
)),
b'"timestamp":%d}}}'
%
0
,
)
)),
self
.
send_ua_networkMessage
()
)
time
.
sleep
(
0.1
)
self
.
assertIn
(
self
.
assertEqual
(
conn
.
recv_frame
().
data
,
MESSAGE_CONTENT
.
replace
(
b'
\
\
'
,
b''
))
b'
\
\
u001b[32minfo/client
\
\
u001b[0m
\
\
tReceived speed of drone 0: %.2f ? %.2f m/s %.2f m/s
\
\
n"}'
%
(
0
,
0
,
0
),
self
.
assertIn
(
ws
.
recv_frame
().
data
,
b'
\
\
u001b[32minfo/client
\
\
u001b[0m
\
\
tReceived position of drone 0: %.6f ? %.6f ? %.2f m %.2f m
\
\
n"}'
%
POSITION_ARRAY_OUTPUT_VALUES
,
)
conn
.
recv_frame
().
data
,
self
.
assertEqual
(
)
ws
.
recv_frame
().
data
,
self
.
assertIn
(
b''
.
join
((
b'
\
\
u001b[32minfo/client
\
\
u001b[0m
\
\
tReceived speed of drone 0: %.2f ? %.2f m/s %.2f m/s
\
\
n"}'
%
SPEED_ARRAY_VALUES
,
b'{"drone_dict":{"0":{"latitude":'
,
conn
.
recv_frame
().
data
,
b'"%.6f","longitude":"%.6f","altitude":"%.2f",'
%
(
0
,
0
,
0
),
)
b'"yaw":"%.2f","speed":"%.2f","climbRate":"%.2f",'
%
(
0
,
0
,
0
),
self
.
assertEqual
(
b'"timestamp":%d}}}'
%
0
,
conn
.
recv_frame
().
data
,
)),
b''
.
join
((
)
b'{"drone_dict":{"0":{"latitude":'
,
self
.
assertIn
(
b'"%.6f","longitude":"%.6f","altitude":"%.2f",'
%
POSITION_ARRAY_OUTPUT_VALUES
[:
-
1
],
b'
\
\
u001b[32minfo/userland
\
\
u001b[0m
\
\
tfieldsSize 1
\
\
n"}'
,
b'"yaw":"%.2f","speed":"%.2f","climbRate":"%.2f",'
%
SPEED_ARRAY_VALUES
,
ws
.
recv_frame
().
data
,
b'"timestamp":%d}}}'
%
POSITION_ARRAY_INPUT_VALUES
[
-
1
],
)
)),
self
.
assertEqual
(
)
ws
.
recv_frame
().
data
,
b''
.
join
((
b'{"drone_dict":{"0":{"latitude":'
,
b'"%.6f","longitude":"%.6f","altitude":"%.2f",'
%
(
0
,
0
,
0
),
b'"yaw":"%.2f","speed":"%.2f","climbRate":"%.2f",'
%
(
0
,
0
,
0
),
b'"timestamp":%d}}}'
%
0
,
)),
)
self
.
send_ua_networkMessage
()
time
.
sleep
(
0.1
)
self
.
assertEqual
(
ws
.
recv_frame
().
data
,
MESSAGE_CONTENT
.
replace
(
b'
\
\
'
,
b''
))
self
.
assertIn
(
b'
\
\
u001b[32minfo/client
\
\
u001b[0m
\
\
tReceived position of drone 0: %.6f ? %.6f ? %.2f m %.2f m
\
\
n"}'
%
POSITION_ARRAY_OUTPUT_VALUES
,
ws
.
recv_frame
().
data
,
)
self
.
assertEqual
(
ws
.
recv_frame
().
data
,
b''
.
join
((
b'{"drone_dict":{"0":{"latitude":'
,
b'"%.6f","longitude":"%.6f","altitude":"%.2f",'
%
POSITION_ARRAY_OUTPUT_VALUES
[:
-
1
],
b'"yaw":"%.2f","speed":"%.2f","climbRate":"%.2f",'
%
SPEED_ARRAY_VALUES
,
b'"timestamp":%d}}}'
%
POSITION_ARRAY_INPUT_VALUES
[
-
1
],
)),
)
self
.
assertIn
(
b'
\
\
u001b[32minfo/client
\
\
u001b[0m
\
\
tReceived speed of drone 0: %.2f ? %.2f m/s %.2f m/s
\
\
n"}'
%
SPEED_ARRAY_VALUES
,
ws
.
recv_frame
().
data
,
)
ws
.
close
()
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