Skip to content

pkg/lora-serialization: add support for lora-serialization format#9863

Merged
aabadie merged 1 commit intoRIOT-OS:masterfrom
leandrolanzieri:pr/lora-serialization
Sep 26, 2018
Merged

pkg/lora-serialization: add support for lora-serialization format#9863
aabadie merged 1 commit intoRIOT-OS:masterfrom
leandrolanzieri:pr/lora-serialization

Conversation

@leandrolanzieri
Copy link
Copy Markdown
Contributor

@leandrolanzieri leandrolanzieri commented Aug 30, 2018

Contribution description

This PR adds support for the lora-serialization format, as a package (found here).

An example showing the lora-serialization format integrated to OpenSenseMap can be found here #9862.

This library is based on this one, but has been implemented withou using dynamic allocation.

This work was done in conjunction with @jia200x.

Testing procedure

cd $(RIOTBASE)/tests/pkg_lora-serialization
make all term

Should output:

main(): This is RIOT! (Version: 2018.10-devel-569-gb199-X1-pr/lora-serialization)
Lora Serialization test

Test 1
Temperature and humidity
---------------------------------
- Writing temperature: 80.12
- Writing humidity: 99.99
- Encoded:  1f 4c 0e 27
- Expected: 1f 4c 0e 27
---------------------------------
SUCCESS

Test 2
Coordinates and unix time
---------------------------------
- Writing coordinates: -33.905052, 151.26641
- Writing unix time: 1467632413
- Encoded:  65 a6 fa fd 6a 24 04 09 1d 4b 7a 57
- Expected: 65 a6 fa fd 6a 24 04 09 1d 4b 7a 57
---------------------------------
SUCCESS

@@ -0,0 +1 @@
USEPKG += lora-serialization
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know there are already other pkgs in this test application, but embunit can be used outside of the unittests, so can you maybe move them to a separate application?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it to a separate application.

@aabadie aabadie added Type: new feature The issue requests / The PR implemements a new feature for RIOT Area: pkg Area: External package ports Area: LoRa Area: LoRa radio support labels Sep 4, 2018
@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Sep 4, 2018

@leandrolanzieri, I don't think unit testing the lora-serialization package within RIOT is required. This is because the library is already unit tested upstream (I saw a tests directory there).
So just adding a simple test application would be enough, like for many other packages.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Sep 4, 2018

@leandrolanzieri, I don't think unit testing the lora-serialization package within RIOT is required. This is because the library is already unit tested upstream (I saw a tests directory there).
So just adding a simple test application would be enough, like for many other packages.

I think I tend to agree. There should at least be a test application that includes the pkg and wiggles around some bytes (with cayenne-lpp we encountered some platform-dependent issues e.g. due to the way floats are handled on different platforms).

@leandrolanzieri leandrolanzieri force-pushed the pr/lora-serialization branch 2 times, most recently from fadbb2c to fd81c33 Compare September 5, 2018 10:07
@leandrolanzieri
Copy link
Copy Markdown
Contributor Author

I modified the test application, considering the float test cases. Also, a 'real world' example using TTN and openSenseMap can be found here #9862.

#include "embUnit.h"
#include "lora_serialization.h"

#if defined(BOARD_NATIVE) && !defined(__clang__)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with cayenne-lpp we encountered some platform-dependent issues e.g. due to the way floats are handled on different platforms

@miri64 you mean this? I encountered problems with floats while running the test as well.

@leandrolanzieri
Copy link
Copy Markdown
Contributor Author

@miri64 Is the test application ok now?

@miri64
Copy link
Copy Markdown
Member

miri64 commented Sep 17, 2018

Yes. Let me run it real quick ;-)

@miri64
Copy link
Copy Markdown
Member

miri64 commented Sep 17, 2018

I get an error when compiling with TOOLCHAIN=llvm:

make: Entering directory '/home/mlenders/Repositories/RIOT-OS/RIOT/tests/pkg_lora-serialization'
make[1]: Nothing to be done for 'Makefile.include'.
make: Nothing to be done for 'clean'.
Building application "tests_pkg_lora-serialization" for "native" with MCU "native".

make[1]: Nothing to be done for 'prepare'.
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/pkg/lora-serialization
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/tests/pkg_lora-serialization/bin/pkg/native/lora-serialization -f /home/mlenders/Repositories/RIOT-OS/RIOT/pkg/lora-serialization/Makefile.lora-serialization
/home/mlenders/Repositories/RIOT-OS/RIOT/tests/pkg_lora-serialization/tests-lora_serialization.c:128:2: error: no newline at end of file [-Werror,-Wnewline-eof]
}
 ^
1 error generated.
/home/mlenders/Repositories/RIOT-OS/RIOT/Makefile.base:83: recipe for target '/home/mlenders/Repositories/RIOT-OS/RIOT/tests/pkg_lora-serialization/bin/native/application_tests_pkg_lora-serialization/tests-lora_serialization.o' failed
make[1]: *** [/home/mlenders/Repositories/RIOT-OS/RIOT/tests/pkg_lora-serialization/bin/native/application_tests_pkg_lora-serialization/tests-lora_serialization.o] Error 1
/home/mlenders/Repositories/RIOT-OS/RIOT/tests/pkg_lora-serialization/../../Makefile.include:434: recipe for target '/home/mlenders/Repositories/RIOT-OS/RIOT/tests/pkg_lora-serialization/bin/native/application_tests_pkg_lora-serialization.a' failed
make: *** [/home/mlenders/Repositories/RIOT-OS/RIOT/tests/pkg_lora-serialization/bin/native/application_tests_pkg_lora-serialization.a] Error 2
make: Leaving directory '/home/mlenders/Repositories/RIOT-OS/RIOT/tests/pkg_lora-serialization'

I think this should be fixed upstream

@leandrolanzieri
Copy link
Copy Markdown
Contributor Author

Nice one! I was able to reproduce that. I modified the file upstream. It should be working now.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Sep 17, 2018

I guess the last commit has the wrong commit message then ;-)

@miri64
Copy link
Copy Markdown
Member

miri64 commented Sep 17, 2018

Works now. Tests (which is the only thing that matters in this PR) are fine with me. @aabadie any word from your side?

@miri64 miri64 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Sep 17, 2018
Copy link
Copy Markdown
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aabadie any word from your side?

I wanted to ACK, but found one remaining thing. Apart from that it's ok.


#include <string.h>
#include <stdio.h>
#include "embUnit.h"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

embUnit is not used by the test application, so this include can be removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the include.

include ../Makefile.tests_common

USEPKG += lora-serialization
USEMODULE += embunit
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module is not needed by the test application

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the module.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Sep 17, 2018

(please remember to squash before merging ;-))

@miri64 miri64 added CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Sep 17, 2018
@leandrolanzieri
Copy link
Copy Markdown
Contributor Author

(please remember to squash before merging ;-))

@miri64 Do I squash everything to a single commit or keep the one on the tests?

@leandrolanzieri
Copy link
Copy Markdown
Contributor Author

Squashed the commits to a single one.

@danpetry
Copy link
Copy Markdown
Contributor

Hi @miri64 @aabadie I'm using this PR and #9862, which depends on it.
If you're both ok with the contribution, would it be ok to go ahead and ACK?

Copy link
Copy Markdown
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last comment, apart from that I tested it on samr21-xpro and native, so ACK.

@@ -0,0 +1,127 @@
/*
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how nitpicky this is, but usually our c-files containing the main functions are called main.c

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, I would prefer a main.c.

@miri64 miri64 added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable labels Sep 25, 2018
Copy link
Copy Markdown
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found minor remaining things. You can squash and amend directly.

@@ -0,0 +1 @@
USEPKG += lora-serialization
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file seems useless, is it a leftover from the previous unittest ?

@@ -0,0 +1,127 @@
/*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, I would prefer a main.c.

*/

/**
* @ingroup unittests
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use tests

tests/pkg_lora-serialization: Add test application
@leandrolanzieri
Copy link
Copy Markdown
Contributor Author

Applied requested changes and squashed.

Copy link
Copy Markdown
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've run the test application on native and b-l072z-lrwan1 board., using the test target. It works as expected. Code changes are good now.

Thanks @leandrolanzieri !

ACK

@aabadie aabadie merged commit ad7ec70 into RIOT-OS:master Sep 26, 2018
@leandrolanzieri leandrolanzieri deleted the pr/lora-serialization branch September 26, 2018 08:03
@jia200x jia200x added this to the Release 2018.10 milestone Oct 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: LoRa Area: LoRa radio support Area: pkg Area: External package ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants