diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2dc91ecaacb4d5f736fe2b06bc380e5f88401e7d..1b53248146317f682a18c4cc93f47ebb4963dcf8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,3 +12,9 @@ test: - cargo fmt -- --check - cargo clippy --all-targets --all-features -- -D warnings - cargo test +build: + script: + - cargo deb + artifacts: + paths: + - target/debian/*.deb \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 537dd87a5b557b4ebf96ec2772c7fadac678fb25..da09b26f7d4311ba0d81d18cf0d0abe47f8a4afc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -216,7 +216,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] -name = "cats-sdr-igate" +name = "cats-sdr-igate-decoder" version = "0.1.0" dependencies = [ "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 6eea815f5c85c6158937e230039aae3afe50ece1..2d52f9e3e75c7c8ba26519678114041b359f08f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cats-sdr-igate" +name = "cats-sdr-igate-decoder" version = "0.1.0" edition = "2021" license = "MIT OR LGPL-2.1-only" @@ -8,14 +8,16 @@ description = "An RX-only SDR CATS I-gate" [package.metadata.deb] assets = [ - ["target/release/cats-igate", "usr/bin/", "755"], - ["debian/cats-igate.service", "/lib/systemd/system/cats-igate.service", "644"], - ["config.example.toml", "/etc/cats_igate/config.toml", "644"] + ["target/release/cats-sdr-igate-decoder", "/usr/bin/", "755"], + ["debian/cats-sdr-igate.service", "/lib/systemd/system/cats-sdr-igate.service", "644"], + ["config.example.toml", "/etc/cats-sdr-igate/config.toml", "644"], + ["debian/start.sh", "/usr/bin/cats-sdr-igate", "755"] ] -conf-files = ["/etc/cats_igate/config.toml"] +conf-files = ["/etc/cats-sdr-igate/config.toml"] maintainer-scripts = "debian/maintainer_scripts/" -copyright = "2023, Stephen D <@stephen:crabsin.space>" +copyright = "2024, Stephen D <@stephen:crabsin.space>" maintainer = "Stephen D <@stephen:crabsin.space>" +depends = "$auto, rtl-sdr" [dependencies] anyhow = "1.0.75" diff --git a/README.md b/README.md index a241f73ac05f60b32149c1bd5d11a1105c8e422b..a5d4d739e28f0c72e7b9986e5a925f7eb9b2554e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,58 @@ # cats-sdr-igate -This is a (very) WIP RX-only SDR CATS I-Gate. +This is a CATS RX-only I-Gate which can use a cheap SDR receiver to decode CATS packets. It prints them to the terminal and optionally forwards them to FELINET. Out of the box, it works with the RTL-SDR. + +## Debian & Derivatives (Ubuntu, Raspbian, etc.) + +### Building + +To build the software, you will need to install [Rustup](https://rustup.rs/). You'll also need git. After these are installed, restart your terminal, or open a new one. Then run these commands: + +```bash +sudo apt install rtl-sdr +cargo install cargo-deb + +git clone https://gitlab.scd31.com/cats/sdr-igate +cd sdr-igate +git pull +cargo deb +``` + +The resulting deb package will placed in `target/debian/cats-sdr-igate-decoder_VERSION.deb` + +### Installing + +Once built, the package can be installed with `sudo dpkg -i target/debian/cats-sdr-igate-decoder_VERSION.deb`, replacing `VERSION` with whatever version and architecture was built. + +### Configuring + +The configuration for the I-Gate lives in `/etc/cats-sdr-igate/config.toml`. Make sure to update this before using the utility - most importantly, the callsign must be configured. Optionally, you can remove the entire `[felinet]` section if you don't want to forward packets to the network. + +### Running + +Start the service with `sudo systemctl start cats-sdr-igate`. If you want it to start automatically at boot, you can run `sudo systemclt enable cats-sdr-igate`. + +## Other + +### Building +To build the software, you will need to install [Rustup](https://rustup.rs/). You'll also need git. After these are installed, restart your terminal, or open a new one. Then run these commands: + +```bash +git clone https://gitlab.scd31.com/cats/sdr-igate +cd sdr-igate +git pull +cargo build --release +``` + +### Configuring + +Copy the `config.example.toml` file to `config.toml`. You can either keep it in the current directory or move it to `/etc/cats-sdr-igate/`. Modify this file - be sure to add your callsign, or remove the `[felinet]` section if you don't want to forward packets to the network. + +### Running + +Make sure you have `rtl-sdr` installed. As a sanity check, verify the `rtl_fm` command exists. + +```bash +./start.sh +``` + diff --git a/debian/cats-igate.service b/debian/cats-sdr-igate.service similarity index 58% rename from debian/cats-igate.service rename to debian/cats-sdr-igate.service index 813549a04878e14accebbc8757daf1d756bf528d..85493df79612e582bd589e32988111111ed1e906 100644 --- a/debian/cats-igate.service +++ b/debian/cats-sdr-igate.service @@ -1,14 +1,13 @@ [Unit] -Description=CATS Igate +Description=CATS SDR I-Gate After=syslog.target network-online.target nss-lookup.target [Service] -PIDFile=/run/cats-igate.pid -ExecStart=/usr/bin/cats-igate -ExecReload=/bin/kill -s HUP $MAINPID +PIDFile=/run/cats-sdr-igate.pid +ExecStart=/usr/bin/cats-sdr-igate ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true -User=cats-igate +User=cats-sdr-igate Restart=on-failure [Install] diff --git a/debian/maintainer_scripts/postinst b/debian/maintainer_scripts/postinst index cabb73991db987e97cc2c7053100ba5dcd6fb389..360b42d331790fd454e3c681e471fbeaf1cdc00c 100644 --- a/debian/maintainer_scripts/postinst +++ b/debian/maintainer_scripts/postinst @@ -1,3 +1,2 @@ -adduser --system --system cats-igate -usermod -G spi -a cats-igate -usermod -G gpio -a cats-igate +adduser --system cats-sdr-igate +usermod -G plugdev -a cats-sdr-igate diff --git a/debian/start.sh b/debian/start.sh new file mode 100755 index 0000000000000000000000000000000000000000..3623a67a836844ba26c1026bd264a84668d71f1b --- /dev/null +++ b/debian/start.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +rtl_fm -M raw -F9 -p 0 -d 0 -s 48000 -f 430500000 - | /usr/bin/cats-sdr-igate-decoder diff --git a/src/config.rs b/src/config.rs index 3bceba17d6a93dbe037f5d2655ef855c52dcf2fc..af64d71550f0955cb5688a88c061183f49123721 100644 --- a/src/config.rs +++ b/src/config.rs @@ -52,12 +52,12 @@ impl Config { } fn read_conf_file() -> anyhow::Result<String> { - let filenames = ["config.toml", "/etc/cats_sdr_igate/config.toml"]; + let filenames = ["config.toml", "/etc/cats-sdr-igate/config.toml"]; for filename in filenames.iter() { if let Ok(x) = fs::read_to_string(filename) { return Ok(x); } } - bail!("Could not open config file. Should either be `config.toml` in the current directory, or in /etc/cats_sdr_igate/") + bail!("Could not open config file. Should either be `config.toml` in the current directory, or in /etc/cats-sdr-igate/") } diff --git a/start.sh b/start.sh index 1394e1182b675617ce4ed8f8f825cc140872d67f..66402a5d611af9eb4be15f4934c1e60e32fa81ea 100755 --- a/start.sh +++ b/start.sh @@ -1,9 +1,3 @@ #!/bin/sh -set -euo pipefail - -BINARY="target/release/cats-sdr-igate" - -cargo build --release - -rtl_fm -M raw -F9 -p 0 -d 0 -s 48000 -f 430500000 - 2>/dev/null | $BINARY +rtl_fm -M raw -F9 -p 0 -d 0 -s 48000 -f 430500000 - | target/release/cats-sdr-igate-decoder