Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: LeToteTeam/tm_mercury
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.3.0
Choose a base ref
...
head repository: LeToteTeam/tm_mercury
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Oct 3, 2017

  1. Copy the full SHA
    126f17b View commit details

Commits on Oct 23, 2017

  1. Copy the full SHA
    8ad81dd View commit details

Commits on Nov 3, 2017

  1. Configure tag protocol and antennas only when value differs from prio…

    …r read plan (#19)
    
    * Configure the tag protocol only if it differs from last read plan
    
    * Configure the antennas only if it differs from last read plan
    
    * Damn it Jim, I'm a behaviour, not a protocol
    
    * Bump version to 0.4.0.
    electricshaman authored Nov 3, 2017

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6be58f0 View commit details

Commits on Nov 6, 2017

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3124741 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9ffc4d9 View commit details
  3. Start 0.5.0-dev cycle

    Jeff Smith committed Nov 6, 2017
    Copy the full SHA
    519212c View commit details

Commits on Nov 9, 2017

  1. Add antenna diagnostics and selection (#22)

    * Implement antenna detection
    
    * Add get_rx_tx_ports function
    
    * Add get_antenna_return_loss function
    
    * Search on single antenna using current antenna config
    
    * Bump to 0.5.0.
    electricshaman authored Nov 9, 2017

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8bd2be1 View commit details
  2. Start 0.6.0-dev cycle

    Jeff Smith committed Nov 9, 2017
    Copy the full SHA
    20ada02 View commit details
  3. Add CODEOWNERS file

    Jeff Smith committed Nov 9, 2017
    Copy the full SHA
    03fa421 View commit details

Commits on Feb 22, 2018

  1. quiet the logger

    mobileoverlord committed Feb 22, 2018
    Copy the full SHA
    634c4d4 View commit details
  2. v0.5.1

    mobileoverlord committed Feb 22, 2018
    Copy the full SHA
    aed67f9 View commit details

Commits on May 17, 2018

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b7888c9 View commit details

Commits on May 21, 2018

  1. Copy the full SHA
    4f9b00d View commit details
  2. Bump version

    electricshaman committed May 21, 2018
    Copy the full SHA
    a69c4f9 View commit details
  3. Clean up warning

    electricshaman committed May 21, 2018
    Copy the full SHA
    c1caf2b View commit details
  4. Copy the full SHA
    881eb19 View commit details

Commits on Jan 22, 2019

  1. Copy the full SHA
    cdc10fb View commit details
  2. Copy the full SHA
    5415b7b View commit details
  3. Copy the full SHA
    cd3e10b View commit details
  4. Format code

    mobileoverlord committed Jan 22, 2019
    Copy the full SHA
    f9b3703 View commit details
  5. v0.6.0

    mobileoverlord committed Jan 22, 2019
    1
    Copy the full SHA
    cfb07d9 View commit details
4 changes: 4 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
54 changes: 53 additions & 1 deletion .iex.exs
Original file line number Diff line number Diff line change
@@ -2,11 +2,63 @@ IEx.configure(inspect: [limit: :infinity])

alias TM.Mercury.Utils
alias TM.Mercury.Protocol.{Command, Opcode, Parameter, Region}
alias TM.Mercury.{Reader, Reader.Config, ReadPlan, Tag, Tag.Protocol, Transport}
alias TM.Mercury.{Reader, Reader.Config, ReadPlan, SimpleReadPlan, StopTriggerReadPlan, Tag, Tag.Protocol, Transport}

defmodule Helpers do
require Logger

def dump_erl(beam_file_path) do
{:ok , {_, [{:abstract_code, {_, ast}}]}} = :beam_lib.chunks(to_charlist(beam_file_path), [:abstract_code])
IO.puts :erl_prettypr.format(:erl_syntax.form_list(ast))
end

def print_tags_sync({:ok, tags}) do
now = DateTime.utc_now |> to_string
Enum.each(tags, fn t -> IO.puts "#{now} #{format_epc(t)} #{t[:rssi]}" end)
end

def print_tags_sync({:tm_mercury, :tags, tags}) do
print_tags_sync({:ok, tags})
end

def format_epc(tag) do
Utils.format_epc_as_string(tag)
end

def start_async_test(opts) do
Logger.configure(level: :info)

device = Keyword.get(opts, :device, "/dev/ttyACM0")
on_time_ms = Keyword.get(opts, :on_time_ms, 100)
off_time_ms = Keyword.get(opts, :off_time_ms, 400)
power = Keyword.get(opts, :power, 2000)
rate_limit = Keyword.get(opts, :rate_limit, :infinity)
antennas = Keyword.get(opts, :antennas, {1,1})

reader =
case Reader.start_link(device) do
{:ok, pid} -> pid
{:error, {:already_started, pid}} -> pid
end

:ok = Reader.set_read_tx_power(reader, power)

rp = %SimpleReadPlan{antennas: antennas}

{:ok, listener} = Task.start_link(&print_tags_async/0)
Reader.read_async_start(reader, listener, on_time_ms, off_time_ms, rp, rate_limit)
reader
end

def stop_async(pid) do
Reader.read_async_stop(pid)
end

def print_tags_async do
receive do
msg ->
print_tags_sync(msg)
end
print_tags_async()
end
end
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

## v0.6.0

* Enhancements
* Switch `nerves_uart` to `circuits_uart`

## Pre v0.6.0

Changelogs do not exist.
1 change: 0 additions & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
@@ -28,4 +28,3 @@ use Mix.Config
# here (which is why it is important to import them last).
#
# import_config "#{Mix.env}.exs"

2 changes: 1 addition & 1 deletion lib/tm_mercury.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule TM.Mercury do
@spec enumerate() :: map | {:error, term}
defdelegate enumerate(), to: Nerves.UART
defdelegate enumerate(), to: Circuits.UART
end
127 changes: 64 additions & 63 deletions lib/tm_mercury/error.ex
Original file line number Diff line number Diff line change
@@ -1,139 +1,140 @@
defmodule TM.Mercury.Error do
alias TM.Mercury.Message
use TM.Mercury.Utils.Enum, [

use TM.Mercury.Utils.Enum,
# invalid number of arguments
msg_wrong_number_of_data: 0x100,
msg_wrong_number_of_data: 0x100,
# command opcode not recognized.
invalid_opcode: 0x101,
invalid_opcode: 0x101,
# command opcode recognized, but is not supported.
unimplemented_opcode: 0x102,
unimplemented_opcode: 0x102,
# requested power setting is above the allowed maximum.
msg_power_too_high: 0x103,
msg_power_too_high: 0x103,
# requested frequency is outside the allowed range.
msg_invalid_freq_received: 0x104,
msg_invalid_freq_received: 0x104,
# parameter value is outside the allowed range.
msg_invalid_parameter_value: 0x105,
msg_invalid_parameter_value: 0x105,
# requested power setting is below the allowed minimum.
msg_power_too_low: 0x106,
msg_power_too_low: 0x106,
# command not supported.
unimplemented_feature: 0x109,
unimplemented_feature: 0x109,
# requested serial speed is not supported.
invalid_baud_rate: 0x10a,
invalid_baud_rate: 0x10A,
# region is not supported.
invalid_region: 0x10b,
invalid_region: 0x10B,
# license key code in invalid
invalid_license_key: 0x10c,
invalid_license_key: 0x10C,
# firmware is corrupt: checksum doesn't match content.
bl_invalid_image_crc: 0x200,
bl_invalid_image_crc: 0x200,
# serial protocol status code for this exception.
bl_invalid_app_end_addr: 0x201,
bl_invalid_app_end_addr: 0x201,
# internal reader error. contact support.
flash_bad_erase_password: 0x300,
flash_bad_erase_password: 0x300,
# internal reader error. contact support.
flash_bad_write_password: 0x301,
flash_bad_write_password: 0x301,
# internal reader error. contact support.
flash_undefined_sector: 0x302,
flash_undefined_sector: 0x302,
# internal reader error. contact support.
flash_illegal_sector: 0x303,
flash_illegal_sector: 0x303,
# internal reader error. contact support.
flash_write_to_non_erased_area: 0x304,
flash_write_to_non_erased_area: 0x304,
# internal reader error. contact support.
flash_write_to_illegal_sector: 0x305,
flash_write_to_illegal_sector: 0x305,
# internal reader error. contact support.
flash_verify_failed: 0x306,
flash_verify_failed: 0x306,
# reader was asked to find tags, but none were detected.
no_tags_found: 0x400,
no_tags_found: 0x400,
# rfid protocol has not been configured.
no_protocol_defined: 0x401,
no_protocol_defined: 0x401,
# requested rfid protocol is not recognized.
invalid_protocol_specified: 0x402,
invalid_protocol_specified: 0x402,
# for write-then-lock commands, tag was successfully written, but lock failed.
write_passed_lock_failed: 0x403,
write_passed_lock_failed: 0x403,
# tag data was requested, but could not be read.
protocol_no_data_read: 0x404,
protocol_no_data_read: 0x404,
# reader not fully initialized and hasn't yet turned on its radio. have you set region?
afe_not_on: 0x405,
afe_not_on: 0x405,
# write to tag failed.
protocol_write_failed: 0x406,
protocol_write_failed: 0x406,
# command is not supported in the current rfid protocol.
not_implemented_for_this_protocol: 0x407,
not_implemented_for_this_protocol: 0x407,
# data does not conform to protocol standards.
protocol_invalid_write_data: 0x408,
protocol_invalid_write_data: 0x408,
# requested data address is outside the valid range.
protocol_invalid_address: 0x409,
protocol_invalid_address: 0x409,
# unknown error during rfid operation.
general_tag_error: 0x40a,
general_tag_error: 0x40A,
# read tag data was asked for more data than it supports.
data_too_large: 0x40b,
data_too_large: 0x40B,
# incorrect password was provided to kill tag.
protocol_invalid_kill_password: 0x40c,
protocol_invalid_kill_password: 0x40C,
# kill failed for unknown reason.
protocol_kill_failed: 0x40e,
protocol_kill_failed: 0x40E,
# internal reader error. contact support.
protocol_bit_decoding_failed: 0x40f,
protocol_bit_decoding_failed: 0x40F,
# internal reader error. contact support.
protocol_invalid_epc: 0x410,
protocol_invalid_epc: 0x410,
# internal reader error. contact support.
protocol_invalid_num_data: 0x411,
protocol_invalid_num_data: 0x411,
# internal reader error. contact support.
gen2_protocol_other_error: 0x420,
gen2_protocol_other_error: 0x420,
# internal reader error. contact support.
gen2_protocol_memory_overrun_bad_pc: 0x423,
gen2_protocol_memory_overrun_bad_pc: 0x423,
# internal reader error. contact support.
gen2_prococol_memory_locked: 0x424,
gen2_prococol_memory_locked: 0x424,
# authentication failed with specified key.
gen2_protocol_v2_authen_failed: 0x425,
gen2_protocol_v2_authen_failed: 0x425,
# untrace opearation failed.
gen2_protocol_v2_untrace_failed: 0x426,
gen2_protocol_v2_untrace_failed: 0x426,
# internal reader error. contact support.
gen2_protocol_insufficient_power: 0x42b,
gen2_protocol_insufficient_power: 0x42B,
# internal reader error. contact support.
gen2_protocol_non_specific_error: 0x42f,
gen2_protocol_non_specific_error: 0x42F,
# internal reader error. contact support.
gen2_protocol_unknown_error: 0x430,
gen2_protocol_unknown_error: 0x430,
# a command was received to set a frequency outside the specified range.
ahal_invalid_freq: 0x500,
ahal_invalid_freq: 0x500,
# with lbt enabled an attempt was made to set the frequency to an occupied channel.
ahal_channel_occupied: 0x501,
ahal_channel_occupied: 0x501,
# checking antenna status while cw is on is not allowed.
ahal_transmitter_on: 0x502,
ahal_transmitter_on: 0x502,
# antenna not detected during pre-transmit safety test.
antenna_not_connected: 0x503,
antenna_not_connected: 0x503,
# reader temperature outside safe range.
temperature_exceed_limits: 0x504,
temperature_exceed_limits: 0x504,
# excess power detected at transmitter port, usually due to antenna tuning mismatch.
high_return_loss: 0x505,
invalid_antenna_config: 0x507,
high_return_loss: 0x505,
invalid_antenna_config: 0x507,
# asked for more tags than were available in the buffer.
tag_id_buffer_not_enough_tags_available: 0x600,
# too many tags are in buffer. remove some with get tag id buffer or clear tag id buffer.
tag_id_buffer_full: 0x601,
tag_id_buffer_full: 0x601,
# internal error -- reader is trying to insert a duplicate tag record. contact support.
tag_id_buffer_repeated_tag_id: 0x602,
tag_id_buffer_repeated_tag_id: 0x602,
# asked for tags than a single transaction can handle.
tag_id_buffer_num_tag_too_large: 0x603,
tag_id_buffer_num_tag_too_large: 0x603,
# blocked response to get additional data from host.
tag_id_buffer_auth_request: 0x604,
tag_id_buffer_auth_request: 0x604,
# internal reader error. contact support.
system_unknown_error: 0x7f00,
system_unknown_error: 0x7F00,
# internal reader error. contact support.
tm_assert_failed: 0x7f01,
]
tm_assert_failed: 0x7F01

defexception [status: nil, message: ""]
defexception status: nil, message: ""

def exception(%Message{status: status}) do
message =
case Enum.find(list(), fn({_k, v}) -> v == status end) do
case Enum.find(list(), fn {_k, v} -> v == status end) do
{k, _v} -> k
_ -> :unhandled_exception
end

%TM.Mercury.Error{message: to_string(message), status: status}
end

def exception(error) do
status =
case Enum.find(list(), fn({k, _v}) -> k == error end) do
case Enum.find(list(), fn {k, _v} -> k == error end) do
{k, _v} -> k
_ -> :unknown_status_code
end
Loading