plotjuggler_plugins
DataStreamUDP
udp_client.py
Go to the documentation of this file.
1
#!/usr/bin/python
2
3
import
socket
4
import
math
5
import
json
6
from
time
import
sleep
7
8
sock = socket.socket(socket.AF_INET,
# Internet
9
socket.SOCK_DGRAM)
# UDP
10
time = 0.0
11
12
while
True
:
13
sleep(0.05)
14
time += 0.05
15
16
data = {
17
"timestamp"
: time,
18
"test_data"
: {
19
"cos"
: math.cos(time),
20
"sin"
: math.sin(time)
21
}
22
}
23
sock.sendto( json.dumps(data).encode(), (
"127.0.0.1"
, 9870) )
24
25
test_str =
"{ \
26
\"1252\": { \
27
\"timestamp\": { \
28
\"microsecond\": 0 \
29
}, \
30
\"value\": { \
31
\"current\": { \
32
\"ampere\": null \
33
}, \
34
\"voltage\": { \
35
\"volt\": 24.852617263793945 \
36
}\
37
}\
38
} }"
39
40
sock.sendto( test_str.encode(
'utf-8'
), (
"127.0.0.1"
, 9870) )
41
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Jun 19 2023 03:12:53