Jul-25-2018, 11:02 AM
I have a GNU radio project outputing data from an FM scanner running on a raspberry pi. I also have a bluetooth service running, which should send any data outputted to stdout by the gnu radio command to any receivers. The bluetooth part is working fine.
To gather data from stdout and send it to the python bluetooth script, I thought i'd use named pipes. I run this in the following manner:
To rule out any problems with the pipe, I also tried writing to a file and tailing it, like this:
Can anyone point me in the right direction?
To gather data from stdout and send it to the python bluetooth script, I thought i'd use named pipes. I run this in the following manner:
sudo ais_rx --gain 44 --error 5 -s osmocom 2>&1 | sudo tee> /tmp/namedpipeThis should send both stdout en stderr to the pipe in the tmp folder, which was created on the python end like this:
pipe_path = "/tmp/namedpipe" if not os.path.exists(pipe_path): os.mkfifo(pipe_path)I then read and print all data in a loop like this:
with open(pipe_path) as fifo: print("FIFO opened") while True: try: data = fifo.readline() print(data) except Error: print ('error')This works ok for a minute or so, and then just seems to stall. Theres no error, it just stops responding to things written to the pipe.
To rule out any problems with the pipe, I also tried writing to a file and tailing it, like this:
sudo ais_rx --gain 44 --error 5 -s osmocom 2>&1 | sudo tee> /tmp/namedfileand I then tail it as follows:
f = subprocess.Popen(['tail','-F','/tmp/namedfile'],\ stdout=subprocess.PIPE,stderr=subprocess.PIPE) p = select.poll() p.register(f.stdout) while True: if p.poll(1): try: data = f.stdout.readline().strip() print(data) except Error: print ('error') time.sleep(1)I know the data output doesn't actually stop, because if I tail it from a terminal I can see it coming in. It's just the python side that stops reading it.
Can anyone point me in the right direction?