Skip to content

Commit de20c93

Browse files
author
James Ward
committedOct 5, 2014
Trivial Python UDP client to receive and print split packets.
1 parent 3eef133 commit de20c93

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
 

‎teapot/udp.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from socket import socket, AF_INET, SOCK_DGRAM
2+
3+
def main():
4+
sock = socket(AF_INET, SOCK_DGRAM)
5+
sock.bind(('', 4774)) # bind to all interfaces/addresses by default
6+
while True:
7+
packet = sock.recv(1024)
8+
exploded = [float(val) for val in packet.split(',')]
9+
print exploded
10+
11+
if __name__ == '__main__':
12+
main()

‎udp-test.c

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <stdio.h>
2+
#include <unistd.h>
3+
#include "udp.h"
4+
5+
int main(void) {
6+
float euler[] = {0, 0, 0};
7+
while (1) {
8+
euler[0] += 1.0/180.0*3.14159; //yaw
9+
//euler[1] += 1.0/180.0*3.14159; //roll
10+
//euler[2] += 1.0/180.0*3.14159; //pitch
11+
12+
udp_send(euler, 3);
13+
usleep(100000);
14+
}
15+
}

0 commit comments

Comments
 (0)