I'm sending data in python between two connect machines within the same network (successfully connected).
The publisher code is defined as:
def senderzmq(self, lat, lon):
sock = zmq.Context().socket(zmq.PUB)
sock.bind("tcp://*:10000")
running = True
while running:
sock.send_string(f"Lat {lat}, Lon={lon}")
The receiver has the following format:
import zmq
context=zmq.Context()
socket=context.socket(zmq.SUB)
socket.connect("tcp://192.168.1.35:10000")
while True:
message=socket.recv_string()
print(message)
The function senderzmq is trigger by:
print(f"Lat {self.lat}, Lon={self.lon}")
self.senderzmq(self.lat, self.lon)
self.lat and self.lon are updated from this static method:
@staticmethod
def gnss(event):
self.lat = event.latitude + LAT0
self.lon = event.longitude + LON0
both LAT0 and LON0 are manually configured.
The above development works, however, the sender always sends the same data, it looks the sender remains within the while True state not listening new data. If I remove the while True, the above doesn't work. Any idea how to exit the while True but transmitting new data at each loop?
Thanks. Raúl
while runningloop never seems to pause or end)senderzmq(self ...)method.selfcoming from where you have:self.lat = event.lat ...?