packages feed

sbp2udp (empty) → 0.0.1

raw patch · 4 files changed

+99/−0 lines, 4 filesdep +basedep +basic-preludedep +binarysetup-changed

Dependencies added: base, basic-prelude, binary, binary-conduit, bytestring, conduit, conduit-extra, network, optparse-generic, protolude, resourcet, sbp, streaming-commons

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Mark Fine (c) 2016++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Mark Fine nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ sbp2udp.cabal view
@@ -0,0 +1,28 @@+name:                  sbp2udp+version:               0.0.1+license:               BSD3+license-file:        LICENSE+synopsis:              SBP to UDP+description:           SBP to UDP+category:              Network+maintainer:            mark@swift-nav.com+build-type:            Simple+cabal-version:         >=1.10++executable sbp2udp+  main-is:             sbp2udp.hs+  default-language:    Haskell2010+  ghc-options:         -Wall+  build-depends:       base >= 4.7 && < 5+                     , basic-prelude+                     , binary+                     , binary-conduit+                     , bytestring+                     , conduit+                     , conduit-extra+                     , network+                     , optparse-generic+                     , protolude+                     , resourcet+                     , sbp+                     , streaming-commons
+ sbp2udp.hs view
@@ -0,0 +1,39 @@+{-# LANGUAGE DeriveGeneric     #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-}++import           BasicPrelude+import           Control.Monad.Trans.Resource+import           Data.Binary+import           Data.ByteString.Lazy+import           Data.Conduit+import           Data.Conduit.Binary+import qualified Data.Conduit.List                 as CL+import           Data.Conduit.Network.UDP+import           Data.Conduit.Serialization.Binary+import           Data.Streaming.Network+import           Network.Socket+import           Options.Generic+import           SwiftNav.SBP+import           System.IO++data Args = Args+  { host :: String+  , port :: Int+  } deriving (Generic)++instance ParseRecord Args++convert :: AddrInfo -> SBPMsg -> Message+convert addr sm =+  Message (toStrict $ encode sm) (addrAddress addr)++main :: IO ()+main = do+  args         <- getRecord "sbp2udp"+  (sock, addr) <- getSocketUDP (host args) (port args)+  runResourceT $+    sourceHandle stdin      =$=+      conduitDecode         =$=+      CL.map (convert addr) $$+      sinkToSocket sock