Skip to content

Instantly share code, notes, and snippets.

View wheberth's full-sized avatar

Wheberth Dias wheberth

View GitHub Profile
#!/usr/bin/env python3
# Provides "fast" waveform and spectrum visualization for SDR signals using pyqtgraph.
# The idea is that you change the get_samples() function for whatever you need to
# obtain you own data for analisys.
# Hopefully this can be useful, of at least, fun for someone else ;)
# TODO:
# * Command line args / UI Selection for Plot parameters
# * Grid and legend on the "Digital fosphor display"
#!/usr/bin/env python
import iio
import struct
import numpy as np
import matplotlib.pyplot as plt
#initalize the iio device and read samples from the channel voltage0
ctx = iio.Context("ip:192.168.2.1")
dev = ctx.find_device('cf-ad9361-lpc')
ch0 = dev.find_channel('voltage0', False)
@wheberth
wheberth / add_to_bashrc
Last active July 9, 2020 03:15
Show git branch in Ubuntu (18.04) bash prompt
# All credits to https://coderwall.com/p/fasnya/add-git-branch-name-to-bash-prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\\[\033[33m\]\$(parse_git_branch)\[\033[00m\]\$ " #ubuntu way
force_color_prompt=yes
@wheberth
wheberth / iperf3.service
Created January 15, 2020 14:13
systemd service to automattically starts iperf3 on boot
[Unit]
Description=iperf3 server
After=syslog.target network.target auditd.service
[Service]
ExecStart=/usr/bin/iperf3 -s
[Install]
WantedBy=multi-user.target
@wheberth
wheberth / niusrprio.service
Created January 15, 2020 14:12
Service to automatically start niusrprio_pcie at boot time (X310)
[Unit]
Description=Start NI USRP RIO
[Service]
User=root
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/niusrprio_pcie start
ExecStop=/usr/local/bin/niusrprio_pcie stop
@wheberth
wheberth / create_tun.sh
Last active June 17, 2020 15:12
Adds persistent tun interface in network manager (nmcli)
#!/bin/bash
# Adds a tun interface for a point to point link in nmcli and sets the MTU to 9000 bytes
# the created inteface belongs to the group 27 (sudo in Ubuntu 18.04)
# You need to run only once, as the interface is permanent
nmcli connection add type tun mode tun group 27 ifname radiotun0 con-name radiotun0 eth.mtu 9000 ip4 10.0.0.3/29
@wheberth
wheberth / agc.py
Created November 29, 2019 01:13
USRP (x310) AGC Code for a GnuRadio Embedded Python Block
"""
USRP AGC Control
This block is a PI controller to the gain of the USRP based on the
received signal. This particular implementation uses the peak of
the signal, but other metrics, such as variance, os standard deviation
can be employed. The gain is controled in 0.5 steps and an hysteresis
can be set.
The main goal of such block is to avoid saturation at the ADC or
analog frontent.