Python Forum
Reading UDP from external device without device software
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading UDP from external device without device software
#1
Hello everyone,

Before I get to my actual problem, here is some background for the project in which this problem occurs:
I am trying to control a microcontroller, based on the data coming from a sensor. This sensor is not compatible with the microcontroller, since it is a fibre optic sensor. An external device, an interrogator, has to be used to extract the data from the sensor. This interrogator will send data to an included software on my laptop.
I traced the datastream with Wireshark and decoded the sent bytes. The dataprotocol used for this data is UDP.

Now the problem: I need to read the incoming data using python so I can make the microcontroller respond to changing sensorvalues. The interrogator sends the data to 10.0.0.37 port 30002 from 10.0.0.150 port 30071. If I kill the included software with taskmanager, the port opens up for python and the datastream continues according to Wireshark. However, my code does not read the data. (code below). The incoming data are UDP packets of 1488 bytes for the total package and 1444 bytes for the actual data.

import socket
import time
 
port = 30002  # Port to receive data on

bufferSize = 2048 # buffer size
 
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(('',port))
s.setblocking(0)
 
while(1):
    try:
        result = select.select([s],[],[])
        msg = result[0][0].recv(bufferSize) 
        print (msg)
        time.sleep(1)
    except:
        print('failed to receive data')
        time.sleep(1)
Does anybody have any suggestions how to collect the data from port 30002?
Reply


Messages In This Thread
Reading UDP from external device without device software - by ikdemartijn - Dec-03-2019, 09:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Input network device connection info from data file edroche3rd 6 1,048 Oct-12-2023, 02:18 AM
Last Post: edroche3rd
  How to automate loop test check on Network device jpc230 1 587 Oct-09-2023, 09:54 PM
Last Post: Larz60+
  Name of USB device on Anodrid frohr 0 701 Aug-14-2023, 06:36 AM
Last Post: frohr
  Help with bleak - how to send test to BLE device? korenron 1 1,731 Aug-28-2022, 11:28 PM
Last Post: Larz60+
  Scan for Bluetooth device korenron 0 2,627 Jan-10-2022, 01:06 PM
Last Post: korenron
  Sending string commands from Python to a bluetooth device Rovelin 13 9,487 Aug-31-2021, 06:40 PM
Last Post: deanhystad
  Python BLE Scanner not detecting device alexanderDennisEnviro500 0 2,012 Aug-01-2021, 02:29 AM
Last Post: alexanderDennisEnviro500
  Real Time Audio Processing with Python Sound-Device not working Slartybartfast 2 3,990 Mar-14-2021, 07:20 PM
Last Post: Slartybartfast
  Connect device using Visa TCP Socket connection d777py 1 3,431 Jan-08-2021, 05:08 PM
Last Post: d777py
  bluetooth device inquiry anne 0 2,343 Aug-01-2020, 12:24 AM
Last Post: anne

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020