jmayrhofer
(Compile error): module Platform.Parsing.Behaviour is not loaded and could not be found
Hi! When I try to compile the following Codefile, the compiler gives me a error message:
** (CompileError) main.exs:2: module Platform.Parsing.Behaviour is not loaded and could not be found
(elixir 1.12.2) expanding macro: Kernel.use/1
main.exs:2: Parser (module)
exit status 1
Do you have an idea to fix that? Thank you in advance :).
defmodule Parser do
use Platform.Parsing.Behaviour
require Logger
# LPP_TEMP (Devicetype 0x0010)
defp parse_payload(
device_type,
0x01,
<<temperature::signed-16>>
)
when device_type in [0x0010] do
%{
temperature: temperature * 10
}
|> Map.merge(parse_temperature(temperature))
end
# LPP_CO2 (Devicetype 0x0012)
defp parse_payload(
device_type,
0x01,
<<co2::signed-16>>
)
when device_type in [0x0012] do
%{
co2: co2 / 1
}
|> Map.merge(parse_co(CO2))
end
# LPP_RHUM (Devicetype 0x0011)
defp parse_payload(
device_type,
0x01,
<<lpp_rhum::signed-8>>
)
when device_type in [0x0011] do
%{
lpp_rhum: lpp_rhum
}
|> Map.merge(parse_rhum(lpp_rhum))
end
# LPP_VOC (Devicetype 0x0013)
defp parse_payload(
device_type,
0x01,
<<lpp_voc::signed-16>>
)
when device_type in [0x0013] do
%{
lpp_voc: lpp_voc
}
|> Map.merge(parse_voc(lpp_voc))
end
# LPP_ATM_P (Devicetype 0x0030)
defp parse_payload(
device_type,
0x01,
<<lpp_atm::signed-16>>
)
when device_type in [0x0030] do
%{
lpp_atm_p: lpp_atm_p
}
|> Map.merge(parse_atmp(lpp_atm_p))
end
# LPP_DP (Devicetype 0x0031)
defp parse_payload(
device_type,
0x01,
<<lpp_dp::signed-16>>
)
when device_type in [0x0031] do
%{
lpp_dp: lpp_dp
}
|> Map.merge(parse_dp(lpp_dp))
end
# lpp_flow (Devicetype 0x0032)
defp parse_payload(
device_type,
0x01,
<<lpp_flow::signed-16>>
)
when device_type in [0x0032] do
%{
lpp_flow: lpp_flow
}
|> Map.merge(parse_flow(lpp_flow))
end
# lpp_visible_light (Devicetype 0x0040)
defp parse_payload(
device_type,
0x01,
<<lpp_visible_light::signed-16>>
)
when device_type in [0x0040] do
%{
lpp_visible_light: lpp_visible_light
}
|> Map.merge(parse_light(lpp_visible_light))
end
# lpp_vbat (Devicetype 0x0054)
defp parse_payload(
device_type,
0x01,
<<lpp_vbat::signed-8>>
)
when device_type in [0x0054] do
%{
lpp_vbat: lpp_vbat
}
|> Map.merge(parse_vbat(lpp_vbat))
end
defp parse_payload(_device_type, _report_type, payload) do
%{
unknown_payload: Base.encode16(payload)
}
end
defp parse_temperature(<<temperature::signed-16>>, field \\ :temperature, factor \\ 0.10) do
%{
field => temperature * factor
}
end
defp parse_co(<<co2::signed-16>>, field \\ :CO2, factor \\ 1.0) do
%{
field => CO2 * factor
}
end
defp parse_rhum(<<lpp_rhum::signed-8>>, field \\ :lpp_rhum, factor \\ 1.0) do
%{
field => lpp_RHUM * factor
}
end
defp parse_voc(<<lpp_voc::signed-16>>, field \\ :lpp_voc, factor \\ 1.0) do
%{
field => lpp_VOC * factor
}
end
defp parse_atmp(<<lpp_atm_p::signed-16>>, field \\ :lpp_atm_p, factor \\ 1.0) do
%{
field => lpp_atm_p * factor
}
end
defp parse_dp(<<lpp_dp::signed-16>>, field \\ :lpp_dp, factor \\ 1.0) do
%{
field => lpp_dp * factor
}
end
defp parse_flow(<<lpp_flow::signed-16>>, field \\ :lpp_flow, factor \\ 1.0) do
%{
field => lpp_flow * factor
}
end
defp parse_light(<<lpp_visible_light::signed-16>>, field \\ :lpp_visible_light, factor \\ 1.0) do
%{
field => lpp_visible_light * factor
}
end
defp parse_vbat(<<lpp_vbat::signed-8>>, field \\ :lpp_vbat, factor \\ 0.05) do
%{
field => lpp_vbat * factor
}
end
def fields() do
[
%{
field: "temperature",
display: "Temperatur",
unit: "°C"
},
%{
field: "CO2",
display: "CO2",
unit: "ppm"
},
%{
field: "lpp_RHUM",
display: "relative Feuchte",
unit: "% rH"
},
%{
field: "lpp_VOC",
display: "VOC",
unit: "%"
},
%{
field: "lpp_ATM_P",
display: "Absoluter Druck",
unit: "mBar/hPa"
},
%{
field: "lpp_DP",
display: "Differenzdruck",
unit: "Pa"
},
%{
field: "lpp_flow",
display: "Volumenstrom",
unit: "m3/h"
},
%{
field: "lpp_visible_light",
display: "Beleuchtungsstärke",
unit: "lux"
},
%{
field: "lpp_vbat",
display: "Energielevel",
unit: "mV"
}
]
end
end
Marked As Solved
BartOtten
It seems you want to implement a behaviour. Use ‘ @behaviour Module.Name’ instead of ‘use Module.Name’
2
Popular in Questions
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it.
I’m very interested in Elixir,...
New
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I'm writing a test for one of t...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set?
Thanks.
New
Student & New to elixir. Nice language.
I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Hi all
I want to have a unix time, from the current time plus 1 hour.
DateTime.now + 1 hour
How to get it in elixir?
Thanks
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
Other popular topics
Phoenix 1.4.0 released
Phoenix 1.4 is out! This release ships with exciting new features, most notably
with HTTP2 support, improved deve...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
Hi,
I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
Hello everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
Hi everyone,
One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
I have a super simple question about elixir - how would I take a file like this
foo bar baz
and output a new file that enumerates th...
New
by Lance Halvorsen
Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
New







