packages feed

mercury-api 0.1.0.0 → 0.1.0.1

raw patch · 5 files changed

+70/−24 lines, 5 filesdep ~ansi-terminalPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: ansi-terminal

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,4 +1,9 @@+<!-- -*- text -*- prevent Emacs from formatting ChangeLog incorrectly --> # Revision history for mercury-api++## 0.1.0.1  -- 2017-06-11++* Fixed a crash that could occur when peeking the mask of a TagFilter.  (I was rading the length as a 32-bit number instead of a 16-bit number, which could cause the length to be impossibly long.)  ## 0.1.0.0  -- 2017-06-05 
README.md view
@@ -1,5 +1,5 @@ Latest:-[![Hackage](https://img.shields.io/hackage/v/hs-mercury-api.svg)](https://hackage.haskell.org/package/hs-mercury-api)+[![Hackage](https://img.shields.io/hackage/v/mercury-api.svg)](https://hackage.haskell.org/package/mercury-api) Linux: [![Build Status](https://travis-ci.org/ppelleti/hs-mercury-api.svg?branch=master)](https://travis-ci.org/ppelleti/hs-mercury-api) Windows:@@ -33,17 +33,51 @@ On Mac OS X, be sure to use the serial device that starts with `/dev/cu.`, not the serial device that starts with `/dev/tty.`. +On Windows, you can type `wmic path Win32_SerialPort` to list the+available COM ports.+ Only some parameters and some tagops are currently supported in the Haskell binding.  (There are a lot of them, and I only implemented the ones I needed.)  If you need support for additional parameters or tagops, please file an issue in GitHub and I will add them. +I have tested this package on Linux, Mac OS X, and Windows, using the+SparkFun board.++Here is a minimal example which reads tags at maximum power for 1+second, and then prints the results:++```haskell+{-# LANGUAGE OverloadedStrings #-}++import qualified Data.Text.IO as T+import qualified System.Hardware.MercuryApi as TMR+import qualified System.Hardware.MercuryApi.Params as TMR++main = do+  rdr <- TMR.create "tmr:///dev/ttyUSB0"+  TMR.paramSetTransportTimeout rdr 10000+  TMR.connect rdr+  TMR.paramSetBasics rdr TMR.REGION_NA2 2700 TMR.sparkFunAntennas+  tags <- TMR.read rdr 1000+  putStrLn $ "read " ++ show (length tags) ++ " tags"+  mapM_ T.putStrLn $ concatMap TMR.displayTagReadData tags+  TMR.destroy rdr+```++Additional examples are available in the `examples` directory.+ Additional resources:  * [RFID Basics][8] * [SparkFun Simultaneous RFID Reader hookup guide][3] * [ThingMagic manuals and firmware][4] +Mercury API in other languages:++* C, Java, and C# - officially supported by [Mercury API][5]+* [Python binding][10] by Petr Gotthard+ [1]: https://www.sparkfun.com/products/14066 [2]: http://www.thingmagic.com/images/Downloads/Docs/MercuryAPI_ProgrammerGuide_for_v1.27.3.pdf [3]: https://learn.sparkfun.com/tutorials/simultaneous-rfid-tag-reader-hookup-guide@@ -53,3 +87,4 @@ [7]: http://www.thingmagic.com/index.php/embedded-rfid-readers/thingmagic-nano-module [8]: https://learn.sparkfun.com/tutorials/rfid-basics [9]: https://github.com/ppelleti/hs-mercury-api/blob/master/UPGRADING.md+[10]: https://github.com/gotthardp/python-mercuryapi
mercury-api.cabal view
@@ -10,7 +10,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.1.0.0+version:             0.1.0.1  -- A short (one-line) description of the package. synopsis:            Haskell binding to Mercury API for ThingMagic RFID readers@@ -157,7 +157,7 @@                      , ansi-terminal >= 0.6.2.3 && < 0.7                      , bytestring >= 0.10.4 && < 0.11                      , mercury-api-                     , optparse-applicative >= 0.13 && < 0.14+                     , optparse-applicative >= 0.13 && < 0.15                      , text >= 1.2 && < 1.3   hs-source-dirs:      examples   default-language:    Haskell2010@@ -170,7 +170,7 @@   build-depends:       base >= 4.6 && < 5                      , bytestring >= 0.10.4 && < 0.11                      , mercury-api-                     , optparse-applicative >= 0.13 && < 0.14+                     , optparse-applicative >= 0.13 && < 0.15                      , text >= 1.2 && < 1.3   hs-source-dirs:      examples   default-language:    Haskell2010@@ -184,7 +184,7 @@                      , ansi-terminal >= 0.6.2.3 && < 0.7                      , bytestring >= 0.10.4 && < 0.11                      , mercury-api-                     , optparse-applicative >= 0.13 && < 0.14+                     , optparse-applicative >= 0.13 && < 0.15                      , text >= 1.2 && < 1.3   hs-source-dirs:      examples   default-language:    Haskell2010@@ -198,7 +198,7 @@                      , ansi-terminal >= 0.6.2.3 && < 0.7                      , bytestring >= 0.10.4 && < 0.11                      , mercury-api-                     , optparse-applicative >= 0.13 && < 0.14+                     , optparse-applicative >= 0.13 && < 0.15                      , text >= 1.2 && < 1.3   hs-source-dirs:      examples   default-language:    Haskell2010@@ -211,7 +211,7 @@   build-depends:       base >= 4.6 && < 5                      , bytestring >= 0.10.4 && < 0.11                      , mercury-api-                     , optparse-applicative >= 0.13 && < 0.14+                     , optparse-applicative >= 0.13 && < 0.15                      , text >= 1.2 && < 1.3   hs-source-dirs:      examples   default-language:    Haskell2010@@ -224,7 +224,7 @@   build-depends:       base >= 4.6 && < 5                      , bytestring >= 0.10.4 && < 0.11                      , mercury-api-                     , optparse-applicative >= 0.13 && < 0.14+                     , optparse-applicative >= 0.13 && < 0.15                      , text >= 1.2 && < 1.3   hs-source-dirs:      examples   default-language:    Haskell2010@@ -238,7 +238,7 @@                      , bytestring >= 0.10.4 && < 0.11                      , directory >= 1.2.2 && < 1.4                      , mercury-api-                     , optparse-applicative >= 0.13 && < 0.14+                     , optparse-applicative >= 0.13 && < 0.15                      , text >= 1.2 && < 1.3   hs-source-dirs:      tests   default-language:    Haskell2010
src/System/Hardware/MercuryApi/Records.hsc view
@@ -303,17 +303,17 @@     case ft of       #{const TMR_FILTER_TYPE_TAG_DATA} ->         TagFilterEPC <$> #{peek TagFilterEtc, filter.u.tagData} p-      #{const TMR_FILTER_TYPE_GEN2_SELECT} ->+      #{const TMR_FILTER_TYPE_GEN2_SELECT} -> do+        bitLength <- #{peek TagFilterEtc, filter.u.gen2Select.maskBitLength} p         TagFilterGen2-        <$> (toBool' <$> #{peek TagFilterEtc, filter.u.gen2Select.invert} p)-        <*> #{peek TagFilterEtc, filter.u.gen2Select.bank} p-        <*> #{peek TagFilterEtc, filter.u.gen2Select.bitPointer} p-        <*> #{peek TagFilterEtc, filter.u.gen2Select.maskBitLength} p-        <*> peekMask p+          <$> (toBool' <$> #{peek TagFilterEtc, filter.u.gen2Select.invert} p)+          <*> #{peek TagFilterEtc, filter.u.gen2Select.bank} p+          <*> #{peek TagFilterEtc, filter.u.gen2Select.bitPointer} p+          <*> return bitLength+          <*> peekMask p bitLength -peekMask :: Ptr TagFilter -> IO ByteString-peekMask p = do-  bitLength <- #{peek TagFilterEtc, filter.u.gen2Select.maskBitLength} p :: IO Word32+peekMask :: Ptr TagFilter -> Word16 -> IO ByteString+peekMask p bitLength = do   let len = fromIntegral $ (bitLength + 7) `div` 8   maskPtr <- #{peek TagFilterEtc, filter.u.gen2Select.mask} p   B.packCStringLen (maskPtr, len)
tests/replay.hs view
@@ -32,7 +32,9 @@       IOMode(ReadMode, WriteMode),       withFile,       hPutStrLn,-      hGetLine )+      hGetLine,+      hFlush,+      stderr ) import System.Info ( os )  import qualified System.Hardware.MercuryApi as TMR@@ -53,6 +55,8 @@ suppressUri (Left exc) = Left exc { TMR.meUri = T.empty } suppressUri x = x +putStrLnE = hPutStrLn stderr+ check :: (Read a, Show a, Eq a) => TestState -> IO a -> IO a check ts f = do   eth' <- try f@@ -63,10 +67,11 @@       ln <- hGetLine (tsHandle ts)       let expected = read ln :: (Read a => Either TMR.MercuryException a)       when (expected /= eth) $ do-        putStrLn "expected:"-        putStrLn ln-        putStrLn "but got:"-        print eth+        putStrLnE "expected:"+        putStrLnE ln+        putStrLnE "but got:"+        putStrLnE $ show eth+        hFlush stderr         fail "test failed"   return $ case eth of              Left exc -> throw exc -- only thrown if caller looks at result@@ -74,7 +79,8 @@  runTest :: String -> TestDirection -> String -> TestFunc -> IO () runTest uri dir name func = do-  putStrLn $ "running test: " ++ name+  putStrLnE $ "running test: " ++ name+  hFlush stderr   let fname = "tests/" ++ name       transportFile = fname ++ ".transport"       resultFile = fname ++ ".result"