Error on windows util/bridge.py "MSG_DONTWAIT" #2

Closed
opened 2024-06-20 23:32:20 +02:00 by prowindowsuser · 2 comments

util/bridge.py doesnt work on windows because "MSG_DONTWAIT" doesnt exist on windows
i tried to delete it & fix the code but

sdrpp: doesnt show anything

gnu radio:

Traceback (most recent call last):
  File "C:\Users\TOSHIBA\Documents\aa\untitled.py", line 158, in <module>
    main()
  File "C:\Users\TOSHIBA\Documents\aa\untitled.py", line 136, in main
    tb = top_block_cls()
         ^^^^^^^^^^^^^^^
  File "C:\Users\TOSHIBA\Documents\aa\untitled.py", line 104, in __init__
    self.network_tcp_source_0 = network.tcp_source.tcp_source(itemsize=gr.sizeof_short*1,addr='127.0.0.1',port=1234,server=False)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\TOSHIBA\radioconda\Lib\site-packages\gnuradio\network\tcp_source.py", line 87, in __init__
    fd = _get_sock_fd(addr, port, server)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\TOSHIBA\radioconda\Lib\site-packages\gnuradio\network\tcp_source.py", line 76, in _get_sock_fd
    return os.dup(sock.fileno())
           ^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 9] Bad file descriptor`

gqrx: freezes & crashes

i did million things to get here on windows and 100 lines of python blocking me :( help would be awesome

edit: running grc/PicoSDR.grc or PicoSDR-WBFM.grc output:

Executing: C:\Users\TOSHIBA\radioconda\python.exe -u C:\Users\TOSHIBA\Desktop\picosdr\pico-sdr\grc\PicoSDR.py
gr-osmosdr 0.2.0.0 (0.2.0) gnuradio 3.10.9.2
built-in source types: file rtl rtl_tcp uhd miri hackrf bladerf airspy airspyhf soapy redpitaya 

and it just waits until i stop it. no waterfall etc shows up


tips for fellow windows users; install arm-gnu-toolchain, libusb, pico-sdk, picotool and you need mingw, dont dorget to set all their paths, follow this for compiling picotool

util/bridge.py doesnt work on windows because "MSG_DONTWAIT" doesnt exist on windows i tried to delete it & fix the code but sdrpp: doesnt show anything gnu radio: ``` Traceback (most recent call last): File "C:\Users\TOSHIBA\Documents\aa\untitled.py", line 158, in <module> main() File "C:\Users\TOSHIBA\Documents\aa\untitled.py", line 136, in main tb = top_block_cls() ^^^^^^^^^^^^^^^ File "C:\Users\TOSHIBA\Documents\aa\untitled.py", line 104, in __init__ self.network_tcp_source_0 = network.tcp_source.tcp_source(itemsize=gr.sizeof_short*1,addr='127.0.0.1',port=1234,server=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\TOSHIBA\radioconda\Lib\site-packages\gnuradio\network\tcp_source.py", line 87, in __init__ fd = _get_sock_fd(addr, port, server) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\TOSHIBA\radioconda\Lib\site-packages\gnuradio\network\tcp_source.py", line 76, in _get_sock_fd return os.dup(sock.fileno()) ^^^^^^^^^^^^^^^^^^^^^ OSError: [Errno 9] Bad file descriptor` ``` gqrx: freezes & crashes i did million things to get here on windows and 100 lines of python blocking me :( help would be awesome edit: running grc/PicoSDR.grc or PicoSDR-WBFM.grc output: ``` Executing: C:\Users\TOSHIBA\radioconda\python.exe -u C:\Users\TOSHIBA\Desktop\picosdr\pico-sdr\grc\PicoSDR.py gr-osmosdr 0.2.0.0 (0.2.0) gnuradio 3.10.9.2 built-in source types: file rtl rtl_tcp uhd miri hackrf bladerf airspy airspyhf soapy redpitaya ``` and it just waits until i stop it. no waterfall etc shows up --- tips for fellow windows users; install arm-gnu-toolchain, libusb, pico-sdk, picotool and you need mingw, dont dorget to set all their paths, follow [this](https://github.com/raspberrypi/picotool/issues/95) for compiling picotool
Author
#!/usr/bin/env python

import struct
from socket import (AF_INET, SO_REUSEADDR, SO_SNDBUF,
                    SOCK_STREAM, SOL_SOCKET, socket)

import click
import serial

COMMAND_NAMES = [
    "reset",
    "tune_freq",
    "sample_rate",
    "manual_gain",
    "gain",
    "ppm_offset",
    "if_gain",
    "test_mode",
    "agc",
    "direct_sampling",
    "offset_tuning",
    "11",
    "12",
    "gain_index",
    "bias_tee",
]


def describe(cmd: int, arg: int):
    try:
        print("->", COMMAND_NAMES[cmd], arg)
    except IndexError:
        print("->", cmd, arg)


#@click.command()
#@click.option("-f", "--frequency", default=88200000, help="Frequency to tune to")
def bridge():

    sock = socket(AF_INET, SOCK_STREAM)
    sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
    sock.setsockopt(SOL_SOCKET, SO_SNDBUF, 1024 * 100)
    

    print("Posing as rtl_tcp at tcp://127.0.0.1:1234")
    
    sock.bind(("localhost", 2245))
    #sock.connect(("", 1234))
    sock.listen(3)
    while True:
    
        peer, addr = sock.accept()
        peer.setblocking(0)
        
        print("Client connected:", addr)

        with serial.Serial("COM12", baudrate=10_000_000, timeout=0.1) as fp:
            print(f"Starting RX @ {88200000}")

            # Remove any leftovers.
            while fp.read(64):
                fp.write(b"\x00")
                fp.flush()

            fp.write(struct.pack(">BL", 1, int(88200000)))
            fp.flush()

            print("Begin")

            try:
                cmd = b""

                while True:
                    try:
                        cmd += peer.recv(1)
                    except BlockingIOError:
                        pass

                    while len(cmd) >= 5:
                        fp.write(cmd[:5])
                        info = struct.unpack(">Bl", cmd[:6])
                        describe(*info)
                        cmd = cmd[5:]

                    data = fp.read(64)
                    if data:
                        peer.send(data)

            except ConnectionError:
                pass

            except KeyboardInterrupt:
                exit()

            finally:
                fp.write(b"\x00")
                fp.flush()
                print("Bye.")
                sock.close()

bridge()

works on windows with sdr++
ip:localhost
port: 2245

```python #!/usr/bin/env python import struct from socket import (AF_INET, SO_REUSEADDR, SO_SNDBUF, SOCK_STREAM, SOL_SOCKET, socket) import click import serial COMMAND_NAMES = [ "reset", "tune_freq", "sample_rate", "manual_gain", "gain", "ppm_offset", "if_gain", "test_mode", "agc", "direct_sampling", "offset_tuning", "11", "12", "gain_index", "bias_tee", ] def describe(cmd: int, arg: int): try: print("->", COMMAND_NAMES[cmd], arg) except IndexError: print("->", cmd, arg) #@click.command() #@click.option("-f", "--frequency", default=88200000, help="Frequency to tune to") def bridge(): sock = socket(AF_INET, SOCK_STREAM) sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) sock.setsockopt(SOL_SOCKET, SO_SNDBUF, 1024 * 100) print("Posing as rtl_tcp at tcp://127.0.0.1:1234") sock.bind(("localhost", 2245)) #sock.connect(("", 1234)) sock.listen(3) while True: peer, addr = sock.accept() peer.setblocking(0) print("Client connected:", addr) with serial.Serial("COM12", baudrate=10_000_000, timeout=0.1) as fp: print(f"Starting RX @ {88200000}") # Remove any leftovers. while fp.read(64): fp.write(b"\x00") fp.flush() fp.write(struct.pack(">BL", 1, int(88200000))) fp.flush() print("Begin") try: cmd = b"" while True: try: cmd += peer.recv(1) except BlockingIOError: pass while len(cmd) >= 5: fp.write(cmd[:5]) info = struct.unpack(">Bl", cmd[:6]) describe(*info) cmd = cmd[5:] data = fp.read(64) if data: peer.send(data) except ConnectionError: pass except KeyboardInterrupt: exit() finally: fp.write(b"\x00") fp.flush() print("Bye.") sock.close() bridge() ``` works on windows with sdr++ ip:localhost port: 2245
Owner

Yeah, sorry. I don't really wish to spend any time on Windows support. Feel free to submit a patch, though.

Yeah, sorry. I don't really wish to spend any time on Windows support. Feel free to submit a patch, though.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: mordae/pico-sdr#2
No description provided.