OP25/trunk-recorder on windows? Why not

Status
Not open for further replies.

kcams

Member
Joined
Aug 3, 2021
Messages
16
Want to try Linux software, but just got Windows? Perhaps run boatbod/op25 and osomocom on the same box? Maybe just try some Linux stuff if you were running Unitrunker or something else with just Windows?

You setup a dual boot machine. You could go the virtualbox/vmware route but it's kind of a resource pig. Hyper-V is dying or dead now. A raspberry pi B+ doesn't really have the horse power for trunk recording a large system. How about WSL (Windows Subsystem for Linux)? I had some time, so I made some install notes for getting Linux running on Windows, mostly because I wanted to see what the resource draw looked like.

It's kind of rough, and I don't have startup scripts for it and a couple of issues, both with windows services and WSL2 startup, but I'm attaching my Install Notes. More of a log than a tutorial, but you may find it useful.

Turns out, WSL2 works decently enough. I'm running 12 digital recorders with three SDR's and only hogging 700M of virtual memory and the CPU load is around 50% on an old i3 Intel laptop. Enough head room to do other stuff on it when the trunk-recorder is running. Does it with Win 10 Home edition too.

Some reference material and credit where credit is due, perhaps expand the user base a little bit -- here's what I used, perhaps it will help someone:

About WSL: Windows Subsystem for Linux Documentation
USB with WSL: WSL support · dorssel/usbipd-win Wiki
A cool slick player for your recorded files: GitHub - chuot/rdio-scanner: Rdio Scanner is an open source software that ingest and distribute audio files generated by various software-defined radio recorders. Its interface tries to reproduce the user experience of a real police scanner, while adding its own touch.
Trunk-Recorder: GitHub - robotastic/trunk-recorder: Records calls from a Trunked Radio System (P25 & SmartNet)
OP25 of course: GitHub - boatbod/op25: Fork of osmocom OP25 by boatbod
Shout out to the Ubuntu forums: Ubuntu Forums
 

Attachments

  • WSL-scanner.txt
    16.3 KB · Views: 36

kcams

Member
Joined
Aug 3, 2021
Messages
16
Fixing the startup, just type "wls -d Ubuntu-20.04" in the windows search in the taskbar to launch the scanner
or just type wsl if you set your WSL machine to default, or just have one instance of WSL:

I'm assuming this WSL machine is just used for this purpose with a single user:

USBIPD Device Host Properties (Local Computer) -- was not starting all the time
From services.msc, I set the startup type to Automatic(delayed start)
Also in the Recovery tab, set the 1st failure to "Restart the Service", nothing for the other failures.
Might take a minute or two on a fresh boot to start. You can watch for it in taskmgr.

While you are in services.msc, nuke "Windows Telemetry". That's just a resource pig and Microsoft
Does Not really need to know the status of running programs.

Edit /home/wslUser/.bash_aliases to add shutdown/reboot commands from Linux:
alias shutdown='wsl.exe --terminate $WSL_DISTRO_NAME'
alias reboot='cd /mnt/c/ && cmd.exe /c start "rebooting WSL" cmd /c "timeout 5 && wsl -d $WSL_DISTRO_NAME" && wsl.exe --terminate $WSL_DISTRO_NAME'

On Windows 10 /home/wslUsername/.bash_profile can start services. /etc/wsl.conf will not on Windows 10.
You could get clever and use awk/sed to make it find your USB devices, but for clarity, here is mine:

wsl.exe -u root service udev status || wsl.exe -u root service udev start
usbipd.exe wsl attach -d $WSL_DISTRO_NAME --busid 4-1
usbipd.exe wsl attach -d $WSL_DISTRO_NAME --busid 4-2
usbipd.exe wsl attach -d $WSL_DISTRO_NAME --busid 4-4
sleep 4
/usr/bin/lsusb
/mnt/c/Users/wslUser/repos/rdio-scanner/rdio-scanner &
sleep 4
echo " "
cd /mnt/c/Users/wslUser/repos/trunk-build
./trunk-recorder
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi

On startup, when udev loads there is a really annoying 60 second delay. That's not how you're supposed to start udev on
regular linux, but here it's just 'the way'. Find sleep 60 in /etc/init.d/udev and change that. Maybe sleep 3 just to make it
less annoying.

You probably also ought to clean up after yourself with /home/wslUser/.bash_logout and release the USB devices:

# ~/.bash_logout: executed by bash(1) when login shell exits.
# when leaving the console clear the screen to increase privacy
usbipd.exe wsl detach -d $WSL_DISTRO_NAME --busid 4-1
usbipd.exe wsl detach -d $WSL_DISTRO_NAME --busid 4-2
usbipd.exe wsl detach -d $WSL_DISTRO_NAME --busid 4-4
if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi

CTRL-C stops the scanner. Type shutdown to exit the WSL machine. Vmmem will release eventually.
They say there's an 8 second rule before you try to spawn your machine again to avoid problems, but
it's probably better to look at taskmgr and make sure Vmmem is released by the OS before trying
to spawn your machine again.

Happy Scanning!
 
Last edited:

kcams

Member
Joined
Aug 3, 2021
Messages
16
One thing about windows. It works once or twice, then it does not.

Gah!

Remove these from .bash_profile, that's not 'the way'.

/mnt/c/Users/wslUser/repos/rdio-scanner/rdio-scanner &
sleep 4
echo " "
cd /mnt/c/Users/wslUser/repos/trunk-build
./trunk-recorder

Just start rdio-scanner and then start trunk-recorder from the WSL. Isn't a one command, but it works.
 

kcams

Member
Joined
Aug 3, 2021
Messages
16
Last update. Sorry for the spam. Work in progress with bug fixes that might save you time.

Works great now. Just the 'wsl' command to start the default machine. Two Windows firewall issues you may or may not see. One was a conflict on port 3000 (default rdio), run it on port 3030 or another one. That's unique to this box. The other was usbipd. Not sure what happened there, but I had to add a firewall rule to allow port 3240. Error message in your WSL will be:

usbipd: warning: A third-party firewall may be blocking the connection; ensure TCP port 3240 is allowed.

Add another package:
# sudo apt-get install ubuntu-wsl

.bash_profile now:
wsl.exe -u root service udev status || wsl.exe -u root service udev start
usbipd.exe wsl attach -d $WSL_DISTRO_NAME --busid 4-1
usbipd.exe wsl attach -d $WSL_DISTRO_NAME --busid 4-2
usbipd.exe wsl attach -d $WSL_DISTRO_NAME --busid 4-4
sleep 4
/usr/bin/lsusb

/home/trunk/repo/rdio-scanner -listen :3030 &
cd /home/trunk/repo/trunk-build
./trunk-recorder
cd /home/trunk
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi

You might have to attach your usb devices in the WSL with an administrator prompt in windows the first time. Then after that it's fine.

rdio-scanner has a 'Downstream' capability, so if you install it on another box, you can make your WSL upload to it. Just add the URL and API of your remote box in the rdio downstream admin tab and broadcast anywhere you want.

Clone it with import/export and you can have as many machines as you want:
C:\Users\cams>wsl -l -v
NAME STATE VERSION
* Ubuntu-trunk Stopped 2
Ubuntu-op25-osmo Stopped 2
Ubuntu-20.04 Stopped 2
Ubuntu-op25 Stopped 2
Debian Stopped 2
Ubuntu Stopped 2
 

nick0909

Antenna flicker
Feed Provider
Joined
Jan 4, 2003
Messages
144
Wow thanks for all the info, I may have to try this out. I had one computer just for trunk-recorder and recently switched it over to my Windows server running SDR Trunk and it just doesn't sound as good. I don't really want to run a second machine just for trunk-recorder, but if I could get it running in WSL that may just do the trick. I tried with a VM but the USB passthrough caused all sorts of decode errors.
 

nick0909

Antenna flicker
Feed Provider
Joined
Jan 4, 2003
Messages
144
I was having trouble mounting the SDR via USB in WSL, so I went another route that might be easier. I let Windows handle the RTL dongle and use rtl_tcp (download from here: Index of /binaries/windows/rtl-sdr/) on Windows to attach to the device, then in WSL I run trunk-recorder with rtl_tcp as the source connecting back to its own IP. Now WSL runs trunk-recorder beautifully and Windows just has to handle the USB device. It can all start with a startup bat file in the Windows shell:startup folder.

Windows startup .bat, change the IP and paths to what you need:
Code:
cd \
cd SDR\rtl-sdr
start rtl_tcp -a 172.168.1.100
ping localhost
wsl -d Ubuntu /etc/startup.sh

Then in WSL /etc/startup.sh, change the home folder path to wherever you have trunk-recorder:
Code:
cd /home/scanner/trunk-build
trunk-recorder --config /home/scanner/trunk-build/config.json

In my trunk-recorder config device section:
Code:
        "driver": "osmosdr",
        "device": "rtl_tcp=172.168.1.100:1234"
 
Status
Not open for further replies.
Top