Skip to content

Commit

Permalink
Syntax fix and some more clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ringvold committed Aug 1, 2019
1 parent 2549b74 commit 68ff775
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ config :logger, backends: [RingLogger]
keys =
[
Path.join([System.user_home!(), ".ssh", "id_rsa.pub"]),
Path.join[(System.user_home!(), ".ssh", "id_rsa_mac.pub"]),
Path.join([System.user_home!(), ".ssh", "id_rsa_bekk.pub"])
]
|> Enum.filter(&File.exists?/1)

Expand Down
9 changes: 3 additions & 6 deletions lib/han_ams/Parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ defmodule HanAms.Parser do
alias HanAms.Lists

def decode(<<rest::binary>>) do

## finn checksum
verifyChecksum(rest)

## fortsett å parse data
# Start parsing of data
parse(rest, %{})
end

Expand Down Expand Up @@ -41,13 +39,13 @@ defmodule HanAms.Parser do
defp parse(
<<0x7E, _::binary-size(16), 0x09, len, datetime::binary-size(len), rest::binary>>,
acc
) do
)
when acc == %{} do
parse(rest, %{meter_time: parse_datetime(len, datetime)})
end

# message type
defp parse(<<0x02, message_type, rest::binary>>, acc) do
''
parse(rest, put_in(acc[:list], message_type_to_list(message_type)))
end

Expand Down Expand Up @@ -213,5 +211,4 @@ defmodule HanAms.Parser do
18 -> %Lists.ThreeFasesMessageType3{}
end
end

end
2 changes: 0 additions & 2 deletions test/han_ams_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ defmodule HanAmsTest do
}
end

# @tag :skip
test "parse threeFasesMessageType2" do
bytes =
<<0x7E, 0xA0, 0x78, 0x01, 0x02, 0x01, 0x10, 0xC4, 0x98, 0xE6, 0xE7, 0x00, 0x0F, 0x40, 0x00,
Expand Down Expand Up @@ -62,7 +61,6 @@ defmodule HanAmsTest do
assert actual == expected
end

@tag :skip
test "parse threeFasesMessageType3" do
bytes =
<<0x7E, 0xA0, 0x9A, 0x01, 0x02, 0x01, 0x10, 0xAA, 0xA5, 0xE6, 0xE7, 0x00, 0x0F, 0x40, 0x00,
Expand Down

0 comments on commit 68ff775

Please sign in to comment.