Crate nri[stability] [-] [+] [src]

This crate contains all the software used to run the sensing rig. It's designed to run on the Intel NUC in the rig operator's backpack. There are driver wrappers for each sensor, a supervisor that runs each of those in its own thread, plus CLI and web interfaces to control everything.

How to...

... generate this documentation

nri$ cargo doc
nri$ touch src/main.rs
nri$ cargo doc -v | grep rustdoc | awk "-FRunning " '{print substr($NF, 2, length($NF)-2)}' > cargo-doc-command
nri$ source cargo-doc-command
nri$ pushd ../haptics-nri.github.io
haptics-nri.github.io$ git pull
haptics-nri.github.io$ popd
nri$ rsync -a target/doc ../haptics-nri.github.io
nri$ pushd ../haptics-nri.github.io
haptics-nri.github.io$ git add doc
haptics-nri.github.io$ git commit -m "cargo doc"
haptics-nri.github.io$ git push
haptics-nri.github.io$ popd

... lint this code

... set up the wi-fi hotspot

I followed the instructions here to create a Wi-Fi hotspot to which Android devices can connect. Unity's built in network manager can almost, but not quite, do it. You need to create the network in the manager and then go edit the file to change it from Infrastructure Mode to AP Mode (which is not an option in the GUI -- you can select Ad-hoc Mode, but Android won't connect to that).

Shortened instructions:

  1. Click on the network icon in the system tray. Select "Edit connections...".
  2. Click "Add".
  3. Choose "Wi-Fi" for the type and click Create.
  4. Make up an SSID. Leave the type as "Infrastructure" (it doesn't matter, since we'll change it manually). Select the wireless card in the "Device MAC address" dropdown.
  5. Go to the "Wi-Fi Security" tab and choose sane options.
  6. Go to the "IPv4 Settings" tab and set the Method to "Shared to other computers".
  7. Click Save.
  8. Edit the file /etc/NetworkManager/system-connections/$SSID and change mode=infrastructure to mode=ap.
  9. Deactivate and reactivate Wi-Fi. Then you should be able to select the new SSID to "connect" (meaning broadcast). And then you should be able to connect from other devices!

Note that (obviously) when the NUC is running as a hotspot, it has no internet connection. I tried to get DNS running, but I failed, so for now you have to use an IP address to access the NUC. You can see what it chose by running hostname -I -- it seems to like 10.42.0.1.

Reexports

extern crate "std" as std;
extern crate log;
extern crate env_logger;
use std::prelude::v1::*;
use std::io;
use std::io::{Write, BufRead};
use std::ascii::AsciiExt;
use std::ptr;
use std::thread;
use std::sync::mpsc::{channel, Sender, Receiver, TryRecvError};
use std::process::Command;
use mpmc::MultiSender;
use comms::{CmdTo, CmdFrom};
use cli::CLI;
use web::Web;
use structure::Structure;
use bluefox::Bluefox;
use optoforce::Optoforce;

Modules

bluefox

Service to capture frames from the mvBlueFOX3 camera

cli

CLI interface to view and control running services

comms

Utilities for communication between the supervisor thread and services

mpmc

Multi-producer/multi-consumer channels

optoforce

Service to read data from the OptoForce sensor

structure

Service to capture frames from the Structure Sensor

web

Web interface to view and control running services

Macros

rpc!

Convenience macro for making an "RPC" call from a service up to the main thread. This is done by generating a nonce channel, stuffing the sending end into a message that gets sent to the main thread, and then waiting for the main thread to send back a reply.

Structs

Service

Service descriptor

Functions

main

Main function that does everything

send_to
start
stop
stop_all