Reply - Raw
Replies:
diff --git a/Cargo.lock b/Cargo.lock
index c65fa81..a2d3c57 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,12 +1,12 @@
 [root]
 name = "ukhasnet-influxdb"
-version = "0.1.0"
+version = "0.2.0"
 dependencies = [
  "hyper 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
  "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
  "toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
- "ukhasnet-parser 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ukhasnet-parser 0.3.0",
 ]

 [[package]]
@@ -126,11 +126,6 @@ dependencies = [
 ]

 [[package]]
-name = "nom"
-version = "1.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
 name = "num_cpus"
 version = "0.2.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -174,6 +169,11 @@ dependencies = [
 ]

 [[package]]
+name = "pest"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
 name = "pkg-config"
 version = "0.3.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -259,10 +259,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"

 [[package]]
 name = "ukhasnet-parser"
-version = "0.2.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
+version = "0.3.0"
 dependencies = [
- "nom 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
 ]

@@ -327,3 +326,44 @@ name = "winapi-build"
 version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"

+[metadata]
+"checksum bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3"
+"checksum cookie 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fa3d3deaa24f00707d1806cd880e851bb1733571599797ba892d39638d504f9"
+"checksum gcc 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)" = "7a1ba971b0d5db5f9bf498266c394014a3ffb890446dc13e644c5ec05485a2a6"
+"checksum gdi32-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "65256ec4dc2592e6f05bfc1ca3b956a4e0698aa90b1dff1f5687d55a5a3fd59a"
+"checksum hpack 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d2da7d3a34cf6406d9d700111b8eafafe9a251de41ae71d8052748259343b58"
+"checksum httparse 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ed8e190c5c20526ecc81c46ad598ea70d73d76ed7f818cbe11d4e9360ab1f29"
+"checksum hyper 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "77c79d64e2ddbe851c8158ba2a69b820e5039fe16c3d91ba90eb19719f31be54"
+"checksum kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b5e7edf375e6d26243bde172f1d5ed1446f4a766fc9b7006e1fd27258243f1"
+"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
+"checksum lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "547fd11b0400fbab39f7a6df53c648cfb01b977233015d9e0784d595a5a6c449"
+"checksum libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "52f45f4d4d75de96cf7f8b0e37b6a8e2f96619749b80bd79aa9f5a3100d63208"
+"checksum libressl-pnacl-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "cbc058951ab6a3ef35ca16462d7642c4867e6403520811f28537a4e2f2db3e71"
+"checksum log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "038b5d13189a14e5b6ac384fdb7c691a45ef0885f6d2dddbf422e6c3506b8234"
+"checksum matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "15305656809ce5a4805b1ff2946892810992197ce1270ff79baded852187942e"
+"checksum mime 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a74cc2587bf97c49f3f5bab62860d6abf3902ca73b66b51d9b049fbdcd727bd2"
+"checksum num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "51fedae97a05f7353612fe017ab705a37e6db8f4d67c5c6fe739a9e70d6eed09"
+"checksum openssl 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c67f1d1d43f7b9ed16c2d783d517a3cd1d65c29c19b2683d123895998d68b531"
+"checksum openssl-sys 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "065e99c2dca7abfe305bd8254d221952b46d47ea9a1c85b6d674c38f083765e6"
+"checksum openssl-sys-extras 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "bb915fe683516da2ba95a10c57f5154712e0fb3ddd92eb8a926fc870443cdca8"
+"checksum pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0a6dda33d67c26f0aac90d324ab2eb7239c819fc7b2552fe9faa4fe88441edc8"
+"checksum pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8cee804ecc7eaf201a4a207241472cc870e825206f6c031e3ee2a72fa425f2fa"
+"checksum pnacl-build-helper 1.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "61c9231d31aea845007443d62fcbb58bb6949ab9c18081ee1e09920e0cf1118b"
+"checksum rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "2791d88c6defac799c3f20d74f094ca33b9332612d9aef9078519c82e4fe04a5"
+"checksum rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "9cf81518cd579f8a9c58c0a71328bdb9be15c754181261da82583092dc8a7ff0"
+"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084"
+"checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac"
+"checksum solicit 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "172382bac9424588d7840732b250faeeef88942e37b6e35317dce98cafdd75b2"
+"checksum tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0b62933a3f96cd559700662c34f8bab881d9e3540289fb4f368419c7f13a5aa9"
+"checksum time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)" = "8c4aeaa1c95974f5763c3a5ac0db95a19793589bcea5d22e161b5587e3aad029"
+"checksum toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "fcd27a04ca509aff336ba5eb2abc58d456f52c4ff64d9724d88acb85ead560b6"
+"checksum traitobject 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "07eaeb7689bb7fca7ce15628319635758eda769fed481ecfe6686ddef2600616"
+"checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887"
+"checksum unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "13a5906ca2b98c799f4b1ab4557b76367ebd6ae5ef14930ec841c74aed5f3764"
+"checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f"
+"checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172"
+"checksum url 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0cfad3f2f6c8bdeca794aba1a40f5b4b38ce4994844f5feb7466a0addbf5a36d"
+"checksum user32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6717129de5ac253f5642fc78a51d0c7de6f9f53d617fc94e9bae7f6e71cf5504"
+"checksum uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "78c590b5bd79ed10aad8fb75f078a59d8db445af6c743e55c4a53227fc01c13f"
+"checksum winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "4dfaaa8fbdaa618fa6914b59b2769d690dd7521920a18d84b42d254678dd5fd4"
+"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
diff --git a/Cargo.toml b/Cargo.toml
index 107fb07..a080770 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,12 +1,12 @@
 [package]
 name = "ukhasnet-influxdb"
-version = "0.1.0"
+version = "0.2.0"
 authors = ["Adam Greig <adam@adamgreig.com>"]
 readme = "README.md"

 [dependencies]
-ukhasnet-parser = "0.2.4"
-rustc-serialize = "0.3"
+ukhasnet-parser = {version="0.3.0", path="/root/ukhasnet/ukhasnet-parser"}
+rustc-serialize = "0.3.18"
 hyper = "0.8.0"
 time = "0.1"
 toml = "0.1"
diff --git a/src/main.rs b/src/main.rs
index 3392bb1..a0a405f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -16,7 +16,7 @@ use std::thread::sleep;
 use rustc_serialize::Decodable;

 use rustc_serialize::json;
-use ukhasnet_parser::{parse, DataField, Packet, Done, Error, Incomplete};
+use ukhasnet_parser::{parse, DataField, Packet, ParserError};
 use hyper::client::Client;
 use hyper::header::{Headers, Authorization, Basic};

@@ -103,7 +103,7 @@ fn packet_to_influx(sm: &SocketMessage, p: &Packet) -> Result<String, String> {
     let mut location_count = 0;
     let mut windspeed_count = 0;
     let mut zombie_count = 0;
-    let mut comment_count = 0;
+//    let mut comment_count = 0;

     fn numeric_field(name: &str, d: &Vec<f32>, c: i32, field: &mut String) {
         let mut cc = 0;
@@ -153,11 +153,18 @@ fn packet_to_influx(sm: &SocketMessage, p: &Packet) -> Result<String, String> {
             },
             &DataField::Location(ref l) => {
                 location_count += 1;
-                line.push_str(&format!(",location_{}_latitude={}",
-                                      location_count, l.latitude));
-                line.push_str(&format!(",location_{}_longitude={}",
-                                      location_count, l.longitude));
-                match l.altitude {
+                match l.latlng {
+                    Some(a) => {
+                        line.push_str(
+                            &format!(",location_{}_latitude={}",
+                                location_count, a.0));
+                        line.push_str(
+                            &format!(",location_{}_longitude={}",
+                                location_count, a.1));
+                    }
+                    None => ()
+                }
+                match l.alt {
                     Some(a) => line.push_str(
                         &format!(",location_{}_altitude={}",
                                 location_count, a)),
@@ -166,8 +173,14 @@ fn packet_to_influx(sm: &SocketMessage, p: &Packet) -> Result<String, String> {
             },
             &DataField::WindSpeed(ref w) => {
                 windspeed_count += 1;
-                line.push_str(&format!(",windspeed_{}_speed={}",
-                                      windspeed_count, w.speed));
+
+                match w.speed {
+                    Some(a) => line.push_str(
+                        &format!(",windspeed_{}_speed={}",
+                                windspeed_count, a)),
+                    None => ()
+                }
+
                 match w.bearing {
                     Some(b) => line.push_str(
                         &format!(",windspeeed_{}_bearing={}",
@@ -179,10 +192,11 @@ fn packet_to_influx(sm: &SocketMessage, p: &Packet) -> Result<String, String> {
                 zombie_count += 1;
                 line.push_str(&format!(",zombie_{}={}i", zombie_count, z));
             },
-            &DataField::Comment(ref c) => {
-                comment_count += 1;
-                line.push_str(&format!(",comment_{}=\"{}\"", comment_count, c));
-            }
+//            &DataField::Comment(ref c) => {
+//                comment_count += 1;
+//                line.push_str(&format!(",comment_{}=\"{}\"", comment_count, c));
+//            }
+
         }
     }

@@ -296,9 +310,12 @@ fn main() {

             // Parse the message into a packet
             let packet = match parse(&message.p) {
-                Done(_, p) => p,
-                Error(e) => {println!("Error parsing packet: {}", e); continue;},
-                Incomplete(_) => {println!("Packet data incomplete"); continue;}
+                Ok(p) => p,
+                Err(e) => {
+                    println!("Error parsing packet: {}", e);
+                    continue
+                },
+                //Incomplete(_) => {println!("Packet data incomplete"); continue;}
             };

             // Upload the packet to InfluxDB