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
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
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
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”:
14:57:30.512 [warn] ...
New
The Elixir Typespec docs show the following syntax for keyword lists in typespecs:
# ...
| [key: type] # keyword lis...
New
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
I have a User schema with a :from_id field set to type :string:
defmodule TweetBot.Repo.Migrations.CreateUsers do
use Ecto.Migration
...
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
In AR this is so simple
@articles = current_user.articles
How to do in Ecto?
def index(conn, _params) do
current_user = conn.assig...
New
Other popular topics
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
can someone please explain to me how Enum.reduce works with maps
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!)
This post collects co...
New
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
I have a User schema with a :from_id field set to type :string:
defmodule TweetBot.Repo.Migrations.CreateUsers do
use Ecto.Migration
...
New
Hello, I have map which I want to convert it to string like this:
the map:
%{last_name: "tavakkoli", name: "shahryar"}
the string I ne...
New
Hello everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
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







