aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-05-20 09:42:21 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-05-20 09:42:21 +0200
commita9d48bb623cd51f0641d075fb9e953ddb3c80c10 (patch)
treecbdee3041e2e2e51a8dcab579efd3f1820ee741f
parentb6bb4f06bbd92de561be5f71884f2c1a2e0339b7 (diff)
downloadmmbtools-aux-a9d48bb623cd51f0641d075fb9e953ddb3c80c10.tar.gz
mmbtools-aux-a9d48bb623cd51f0641d075fb9e953ddb3c80c10.tar.bz2
mmbtools-aux-a9d48bb623cd51f0641d075fb9e953ddb3c80c10.zip
Use a UDP socket instead of a pipe in uecp_parse
-rwxr-xr-xuecpparse/uecp_parse.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/uecpparse/uecp_parse.py b/uecpparse/uecp_parse.py
index d586252..b0d8822 100755
--- a/uecpparse/uecp_parse.py
+++ b/uecpparse/uecp_parse.py
@@ -24,12 +24,13 @@
# THE SOFTWARE.
#
#
-# A UECP decoder, reading from a file generated by
-# my patched VLC, from ancillary MP2 bytes in a MPEG-TS
+# A UECP decoder, reading from a UDP socket, receiving
+# data generated by my patched VLC, from ancillary MP2 bytes in a MPEG-TS
#
# Please refer to RDS UECP specification
import sys
+import socket
import struct
import crc
@@ -62,7 +63,7 @@ uecp_mec_names = {
0x2C: "SET_COMM_MODE" } # Set communication mode for the encoder
def usage():
- print("Usage:\n{} <filename>".format(sys.argv[0]))
+ print("Usage:\n{} <port>".format(sys.argv[0]))
if len(sys.argv) < 2:
usage()
@@ -169,8 +170,6 @@ class UECP_Frame_Decoder():
UECP_Message_Decoder(self.msg)
-in_fd = open(sys.argv[1], "r")
-
uecp = UECP_Frame_Decoder()
def parse_anc_bytes(anc_bytes):
@@ -186,8 +185,21 @@ def parse_anc_bytes(anc_bytes):
uecp.msg, uecp.crc, uecp.crc_calc, uecp.crc_ok))
uecp = UECP_Frame_Decoder()
-for line_nr, line in enumerate(in_fd):
- line_bytes = [int(i, 16) for i in line.split()]
+UDP_IP = "127.0.0.1"
+port = int(sys.argv[1])
+
+sock = socket.socket(socket.AF_INET, # Internet
+ socket.SOCK_DGRAM) # UDP
+sock.bind((UDP_IP, port))
+
+
+while True:
+ data, addr = sock.recvfrom(1024)
+
+ if not data:
+ break
+
+ line_bytes = [int(i) for i in data]
line_bytes.reverse()