letoteteam / tm_mercury Goto Github PK
View Code? Open in Web Editor NEWA pure Elixir implementation of the ThingMagic Mercury SDK
License: Other
A pure Elixir implementation of the ThingMagic Mercury SDK
License: Other
iex -S mix
{:ok, pid} = Reader.start_link(device: "/dev/ttyACM0")
Reader.read_async_start(pid, self())
The reader's pseudo async task is unaware of the connection status so it continues trying to send data through the Transport. Since the transport is pre-occupied while waiting to reconnect to the device, the call through Transport.send_data times out. The task is linked to the reader, so the reader crashes too (as it should).
01:03:27.718 [info] Disconnecting from RFID reader at /dev/ttyACM0
01:03:27.718 [error] RFID UART error: :eio
01:03:27.718 [info] Connecting to RFID reader at /dev/ttyACM0
01:03:28.720 [info] Connecting to RFID reader at /dev/ttyACM0
01:03:29.723 [info] Connecting to RFID reader at /dev/ttyACM0
01:03:30.726 [info] Connecting to RFID reader at /dev/ttyACM0
01:03:31.727 [info] Connecting to RFID reader at /dev/ttyACM0
** (EXIT from #PID<0.181.0>) exited in: :gen_server.call(#PID<0.190.0>, {:send, <<34, 0, 0, 19, 1, 244>>})
** (EXIT) time out
01:03:32.159 [error] Task #PID<0.195.0> started from :ttyACM0 terminating
** (stop) exited in: :gen_server.call(#PID<0.190.0>, {:send, <<34, 0, 0, 19, 1, 244>>})
** (EXIT) time out
(stdlib) gen_server.erl:204: :gen_server.call/2
(tm_mercury) lib/tm_mercury/transport.ex:37: TM.Mercury.Transport.send_data/2
(tm_mercury) lib/tm_mercury/reader.ex:554: TM.Mercury.Reader.execute_read_sync/3
(tm_mercury) lib/tm_mercury/reader.ex:510: TM.Mercury.Reader.pseudo_read_async/4
(elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Function: #Function<6.93679168/0 in TM.Mercury.Reader.read_async_start/5>
Args: []
The reader should not crash if disconnected while in read async mode.
Ideally the reader would suspend async reading while it is disconnected and then resume if/when it reconnects.
It crashes the reader process if you try to call it.
We broke it somehow during the recent refactoring/fixes.
iex(29)> Reader.reboot(:ttyACM0)
** (EXIT from #PID<0.181.0>) an exception was raised:
** (FunctionClauseError) no function clause matching in TM.Mercury.Reader.reboot_reader/1
(tm_mercury) lib/tm_mercury/reader.ex:452: TM.Mercury.Reader.reboot_reader(%{async_pid: #PID<0.199.0>, init: %TM.Mercury.Reader{antennas: 1, model: nil, power_mode: :full, region: :na, tag_protocol: :gen2}, read_timeout: 500, reader: %TM.Mercury.Reader{antennas: 1, model: :micro, power_mode: :full, region: :na, tag_protocol: :gen2}, status: :connected, transport: #PID<0.189.0>})
(tm_mercury) lib/tm_mercury/reader.ex:326: TM.Mercury.Reader.handle_call/3
(stdlib) gen_server.erl:615: :gen_server.try_handle_call/4
(stdlib) gen_server.erl:647: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
16:04:09.067 [error] GenServer :ttyACM0 terminating
** (FunctionClauseError) no function clause matching in TM.Mercury.Reader.reboot_reader/1
(tm_mercury) lib/tm_mercury/reader.ex:452: TM.Mercury.Reader.reboot_reader(%{async_pid: #PID<0.199.0>, init: %TM.Mercury.Reader{antennas: 1, model: nil, power_mode: :full, region: :na, tag_protocol: :gen2}, read_timeout: 500, reader: %TM.Mercury.Reader{antennas: 1, model: :micro, power_mode: :full, region: :na, tag_protocol: :gen2}, status: :connected, transport: #PID<0.189.0>})
(tm_mercury) lib/tm_mercury/reader.ex:326: TM.Mercury.Reader.handle_call/3
(stdlib) gen_server.erl:615: :gen_server.try_handle_call/4
(stdlib) gen_server.erl:647: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: :reboot
For the same tag sitting undisturbed on top of the reader for a few minutes, the tag's phase
returned a wide distribution of values.
Value | Count | Frequency % |
---|---|---|
160 | 11 | 9.17 |
5 | 10 | 8.33 |
109 | 9 | 7.5 |
165 | 8 | 6.67 |
70 | 7 | 5.83 |
19 | 5 | 4.17 |
42 | 5 | 4.17 |
47 | 5 | 4.17 |
115 | 5 | 4.17 |
14 | 4 | 3.33 |
25 | 4 | 3.33 |
61 | 4 | 3.33 |
112 | 4 | 3.33 |
22 | 3 | 2.5 |
123 | 3 | 2.5 |
171 | 3 | 2.5 |
28 | 2 | 1.67 |
30 | 2 | 1.67 |
33 | 2 | 1.67 |
53 | 2 | 1.67 |
56 | 2 | 1.67 |
73 | 2 | 1.67 |
75 | 2 | 1.67 |
84 | 2 | 1.67 |
157 | 2 | 1.67 |
163 | 2 | 1.67 |
11 | 1 | 0.83 |
16 | 1 | 0.83 |
64 | 1 | 0.83 |
78 | 1 | 0.83 |
104 | 1 | 0.83 |
106 | 1 | 0.83 |
129 | 1 | 0.83 |
154 | 1 | 0.83 |
174 | 1 | 0.83 |
177 | 1 | 0.83 |
Right now the pseudo async mode calls the public read_sync API on the Reader process, so all of the preparation ops for read_sync are called during each interval of the async loop. e.g. clearing the tag buffer (which async already does itself), and resetting the reader statistics like RF on-time and noise floor.
We should add a new public read_sync_prepared call that the async task can use. It would skip clearing the tag buffer and resetting the statistics, reducing the number of request/response cycles to the reader in the async interval from 5 to 3 when tags are present, and 3 to 1 when none are present.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.