# PCap AHRS Parsing example #

This is a brief example of converting a pcap-file of lcm traffic taken from the wave energy buoy to a csv file. It serves as an example to help create future data conversion tools for radar data correlation. You can collect a pcap file on the main buoy computer (MBC) via the following command:

    tshark -i lo -f 'port 7667' -c 1000 -w lcm_packets.pcap

If the LCM ttl=0, for wireshark to capture LCM packets appropriately, please add a static route forcing LCM traffic onto the loopback of the MBC:

    sudo route add -net 224.0.0.0 netmask 240.0.0.0 dev lo

You can check if this route already exists with the `route` command. 

## Build Instructions ##

This has only been tested on Mac OSX at present. 

### Install Dependencies ###

**LIBPCAP** 

- MacOSX: (via brew) `brew install libpcap`
- Ubuntu/Debian: `sudo apt install libpcap`

**LCM**

You will have to buid LCM from source, follow the instructions via their [github page](http://lcm-proj.github.io). This is a cmake build, and all you really need are the C/C++ libraries.

**WEC LCM TYPES**

The LCM types needed to collect the AHRS data are contained in an MBARI repository. Those have been used to generate the `lcmtypes_wec_ahrs_data_l.c/h` files. If those types become updated, we will have to regenerate them. 

### Building

    make;

### Testing 

Their is a sample pcap file taken May 18th, with about 1,000 samples. You can test via `make test` or

    ./pcaptoahrs lcm_packets.pcap

    