{"id":21651807,"url":"https://github.com/mignon-p/hs-mercury-api","last_synced_at":"2025-12-11T23:24:01.994Z","repository":{"id":56846831,"uuid":"92863397","full_name":"mignon-p/hs-mercury-api","owner":"mignon-p","description":"Haskell binding to Mercury API for ThingMagic RFID readers","archived":false,"fork":false,"pushed_at":"2021-11-08T22:35:13.000Z","size":719,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-29T15:05:10.325Z","etag":null,"topics":["haskell-bindings","rfid","thingmagic"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mignon-p.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-30T18:24:47.000Z","updated_at":"2021-11-08T22:35:16.000Z","dependencies_parsed_at":"2022-09-09T01:01:53.416Z","dependency_job_id":null,"html_url":"https://github.com/mignon-p/hs-mercury-api","commit_stats":null,"previous_names":["mignon-p/hs-mercury-api","ppelleti/hs-mercury-api"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mignon-p/hs-mercury-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mignon-p%2Fhs-mercury-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mignon-p%2Fhs-mercury-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mignon-p%2Fhs-mercury-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mignon-p%2Fhs-mercury-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mignon-p","download_url":"https://codeload.github.com/mignon-p/hs-mercury-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mignon-p%2Fhs-mercury-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262614456,"owners_count":23337277,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haskell-bindings","rfid","thingmagic"],"created_at":"2024-11-25T07:49:37.189Z","updated_at":"2025-12-11T23:24:01.953Z","avatar_url":"https://github.com/mignon-p.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Latest:\n[![Hackage](https://img.shields.io/hackage/v/mercury-api.svg)](https://hackage.haskell.org/package/mercury-api)\nLinux:\n[![Build Status](https://travis-ci.org/ppelleti/hs-mercury-api.svg?branch=master)](https://travis-ci.org/ppelleti/hs-mercury-api)\nWindows:\n[![Build status](https://ci.appveyor.com/api/projects/status/aywuy9y05ow8wja2/branch/master?svg=true)](https://ci.appveyor.com/project/ppelleti/hs-mercury-api/branch/master)\n\n## Description\n\nThis package is a Haskell binding to the [Mercury API][5] C API for\n[ThingMagic][6] RFID readers.  It is especially geared toward\nthe [SparkFun Simultaneous RFID Reader][1], which uses ThingMagic's\n[M6e Nano][7] module, but it should work with other ThingMagic\nreaders.  (Though currently, only support for serial readers is\ncompiled in.)  Most of the function and type names are the same as\ntheir counterparts in the C API, with the `TMR_` prefix dropped.  For\nmore in-depth, language-independent documentation of Mercury API, see\n[Mercury API Programmers Guide][2].\n\nThis package includes a copy of the Mercury API C library, so no\nexternal libraries are necessary.  Several small bug fixes have been\napplied to the included version of the library.  (I have submitted\nthese patches upstream, but I don't know if or when they will be\nincluded in the official version.)  If you need to upgrade to a newer\nversion of Mercury API than the included one, see [UPGRADING.md][9].\n\nThe Haskell binding doesn't support background reads.  I recommend\nthat you just spawn a new Haskell thread and do foreground reads\ninstead.\n\nCurrently, only support for the serial reader is compiled in, but it\nprobably wouldn't be too hard to enable LLRP support.  (I don't have\nany way to test LLRP, however, as the M6e Nano doesn't support it.)\n\nOn Mac OS X, be sure to use the serial device that starts with\n`/dev/cu.`, not the serial device that starts with `/dev/tty.`.\n\nOn Windows, you can type `wmic path Win32_SerialPort` to list the\navailable COM ports.\n\nOnly some parameters and some tagops are currently supported in the\nHaskell binding.  (There are a lot of them, and I only implemented the\nones I needed.)  If you need support for additional parameters or\ntagops, please file an issue in GitHub and I will add them.\n\nI have tested this package on Linux, Mac OS X, and Windows, using the\nSparkFun board.\n\nHere is a minimal example which reads tags at maximum power for 1\nsecond, and then prints the results:\n\n```haskell\n{-# LANGUAGE OverloadedStrings #-}\n\nimport qualified Data.Text.IO as T\nimport qualified System.Hardware.MercuryApi as TMR\nimport qualified System.Hardware.MercuryApi.Params as TMR\n\nmain = do\n  rdr \u003c- TMR.create \"tmr:///dev/ttyUSB0\"\n  TMR.paramSetTransportTimeout rdr 10000\n  TMR.connect rdr\n  TMR.paramSetBasics rdr TMR.REGION_NA2 2700 TMR.sparkFunAntennas\n  tags \u003c- TMR.read rdr 1000\n  putStrLn $ \"read \" ++ show (length tags) ++ \" tags\"\n  mapM_ T.putStrLn $ concatMap TMR.displayTagReadData tags\n  TMR.destroy rdr\n```\n\nAdditional examples are available in the `examples` directory.\n\n## How to build\n\nThis package is mostly of interest to Haskell programmers, and if\nyou're a Haskell programmer, you already know how to build it with\n`stack` or `cabal`.\n\nHowever, some of the utilities like `tmr-firmware` might be of\ninterest to non-Haskellers, so here is how to build them if you don't\nknow anything about Haskell:\n\n* Install [stack][11].\n\n* Clone this repository.\n\n* Run `stack --install-ghc install` at the top level of the repository.\n\n* Add `~/.local/bin` to your `$PATH`.\n\nNow the following utilities will be available in your `$PATH`:\n\n```\ntmr-firmware - write a new firmware image to reader\n\nUsage: tmr-firmware [-u|--uri URI] [-t|--transport-listener] [FILENAME]\n  If run without firmware file, just print current firmware version. Firmware\n  file can be downloaded from:\n  http://www.thingmagic.com/index.php/download-nano-firmware\n\nAvailable options:\n  -h,--help                Show this help text\n  -u,--uri URI             Reader to connect to (default tmr:///dev/ttyUSB0)\n  -t,--transport-listener  Print bytes sent on serial port\n\n\ntmr-params - print parameters\n\nUsage: tmr-params [-u|--uri URI] [-t|--transport-listener]\n\nAvailable options:\n  -h,--help                Show this help text\n  -u,--uri URI             Reader to connect to (default tmr:///dev/ttyUSB0)\n  -t,--transport-listener  Print bytes sent on serial port\n\n\ntmr-read - read tags\n\nUsage: tmr-read [-u|--uri URI] [-r|--region REGION] [-p|--power CENTI-DBM]\n                [-t|--transport-listener] [-l|--long]\n\nAvailable options:\n  -h,--help                Show this help text\n  -u,--uri URI             Reader to connect to (default tmr:///dev/ttyUSB0)\n  -r,--region REGION       Regulatory region (default na2)\n  -p,--power CENTI-DBM     Power level (0-2700, default 2300)\n  -t,--transport-listener  Print bytes sent on serial port\n  -l,--long                Print lots of information per tag\n\n\ntmr-write - write a string to user data of tag\n\nUsage: tmr-write [-u|--uri URI] [-r|--region REGION] [-p|--power CENTI-DBM]\n                 [-t|--transport-listener] [-R|--rewrite] STRING\n\nAvailable options:\n  -h,--help                Show this help text\n  -u,--uri URI             Reader to connect to (default tmr:///dev/ttyUSB0)\n  -r,--region REGION       Regulatory region (default na2)\n  -p,--power CENTI-DBM     Power level (0-2700, default 2300)\n  -t,--transport-listener  Print bytes sent on serial port\n  -R,--rewrite             Write to a tag even if written before\n```\n\n## Resources\n\nAdditional resources:\n\n* [RFID Basics][8]\n* [SparkFun Simultaneous RFID Reader hookup guide][3]\n* [ThingMagic manuals and firmware][4]\n\nMercury API in other languages:\n\n* C, Java, and C# - officially supported by [Mercury API][5]\n* [Python binding][10] by Petr Gotthard\n\n[1]: https://www.sparkfun.com/products/14066\n[2]: http://www.thingmagic.com/images/Downloads/Docs/MercuryAPI_ProgrammerGuide_for_v1.27.3.pdf\n[3]: https://learn.sparkfun.com/tutorials/simultaneous-rfid-tag-reader-hookup-guide\n[4]: http://www.thingmagic.com/index.php/manuals-firmware\n[5]: http://www.thingmagic.com/index.php/manuals-firmware#Mercury_API\n[6]: http://www.thingmagic.com/\n[7]: http://www.thingmagic.com/index.php/embedded-rfid-readers/thingmagic-nano-module\n[8]: https://learn.sparkfun.com/tutorials/rfid-basics\n[9]: https://github.com/ppelleti/hs-mercury-api/blob/master/UPGRADING.md\n[10]: https://github.com/gotthardp/python-mercuryapi\n[11]: https://docs.haskellstack.org/en/stable/README/#how-to-install\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmignon-p%2Fhs-mercury-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmignon-p%2Fhs-mercury-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmignon-p%2Fhs-mercury-api/lists"}