Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
html
/
MeteorologicalBureau
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
39204c49
authored
Mar 13, 2020
by
fengfan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of gitlab.maxrocky.com:hanjixin/MeteorologicalBureau
parents
49a2e600
37fa3bbc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
9 deletions
+26
-9
c.py
+22
-5
osc.py
+4
-4
No files found.
c.py
View file @
39204c49
import
argparse
import
json
import
socket
from
pythonosc
import
osc_message_builder
from
pythonosc
import
udp_client
if
__name__
==
"__main__"
:
def
sendUdp
(
data
):
print
(
data
.
encode
(
'utf-16be'
),
'utf-16be'
)
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
s
.
sendto
(
data
.
encode
(
'utf-16be'
),
(
'127.0.0.1'
,
7000
))
s
.
close
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"--ip"
,
default
=
"1
92.168.43.44
"
,
parser
.
add_argument
(
"--ip"
,
default
=
"1
27.0.0.1
"
,
help
=
"The ip of the OSC server"
)
parser
.
add_argument
(
"--port"
,
type
=
int
,
default
=
5006
,
parser
.
add_argument
(
"--port"
,
type
=
int
,
default
=
7000
,
help
=
"The port the OSC server is listening on"
)
args
=
parser
.
parse_args
()
client
=
udp_client
.
SimpleUDPClient
(
args
.
ip
,
args
.
port
)
client
.
send_message
(
"/section"
,
[
0
])
\ No newline at end of file
str
=
"/首页/全国/省级/联络人/信息员"
b
=
bytes
(
str
,
'utf-8'
)
.
decode
()
.
encode
(
'utf-16be'
)
arr
=
[[
0
]
*
(
4
+
len
(
b
))][
0
]
arr
[
0
]
=
66
arr
[
1
]
=
69
arr
[
2
]
=
85
arr
[
3
]
=
67
for
index
in
range
(
len
(
b
)):
arr
[
index
+
4
]
=
b
[
index
]
client
.
send_message
(
"/route"
,
[
bytes
(
arr
)])
client
.
send_message
(
"/首页/全国"
,
[
0
,
1
])
\ No newline at end of file
osc.py
View file @
39204c49
...
...
@@ -3,7 +3,7 @@ import math
import
json
from
pythonosc
import
dispatcher
from
pythonosc
import
osc_server
import
requests
#
import requests
import
socket
import
os
print
(
socket
.
gethostname
())
...
...
@@ -33,7 +33,7 @@ def ctrLamp(id, open):
'Content-Type'
:
"application/json"
,
'Access-Token'
:
"OTZDOEQwREZBN0Y4RjY0NUFGRkY0NzQwMUU1NjFDNjQxNUM3MEE4QzY4N0E1QjBFQTNBM0U2QzU5OUVGNENGQw=="
}
response
=
requests
.
request
(
"POST"
,
url
,
data
=
payload
,
headers
=
headers
)
response
=
''
print
(
response
.
text
)
...
...
@@ -86,14 +86,14 @@ if __name__ == "__main__":
parser
.
add_argument
(
"--ip"
,
default
=
'127.0.0.1'
,
help
=
"The ip to listen on"
)
parser
.
add_argument
(
"--port"
,
type
=
int
,
default
=
7
000
,
help
=
"The port to listen on"
)
type
=
int
,
default
=
9
000
,
help
=
"The port to listen on"
)
args
=
parser
.
parse_args
()
dispatcher
=
dispatcher
.
Dispatcher
()
# dispatcher.map("/Page", print)
# dispatcher.map("/section", print)
dispatcher
.
map
(
"/
section
"
,
print
)
dispatcher
.
map
(
"/
待机
"
,
print
)
print
(
args
)
server
=
osc_server
.
ThreadingOSCUDPServer
(
...
...
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