Jul-29-2022, 09:40 AM
I am a beginner in Python programming.
I wrote a short program that decodes the data received on the UDP port and starts playing the mp3 file on the Raspberry Pi Speaker output. "netstat -lnu" shows that the UDP port is open, ready to receive. The data does not arrive, so I checked the data arriving on the UDP port with Wireshark. The data is fine, and when Wireshark is running, the program works. If I stop Wireshark, the program does not work. How is it possible? What might be the problem?
I wrote a short program that decodes the data received on the UDP port and starts playing the mp3 file on the Raspberry Pi Speaker output. "netstat -lnu" shows that the UDP port is open, ready to receive. The data does not arrive, so I checked the data arriving on the UDP port with Wireshark. The data is fine, and when Wireshark is running, the program works. If I stop Wireshark, the program does not work. How is it possible? What might be the problem?
import socket import pygame pygame.mixer.init() UDP_IP = "" UDP_PORT = 6767 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.bind((UDP_IP, UDP_PORT)) while True : rec, addr = sock.recvfrom(7) data = [x for x in rec] if data[0] == 170 and data[1] == 85 and data[2] == 133 and sum(data[2:6]) % 256 == data[6] : if data[4] == 109 and data[5] == 105 : pygame.mixer.music.load('/home/pi/Audio/1m.mp3') pygame.mixer.music.play()