Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Somfy RTS #1496

Merged
merged 21 commits into from
Sep 22, 2020
Merged

Add support for Somfy RTS #1496

merged 21 commits into from
Sep 22, 2020

Conversation

matthiasseemoo
Copy link
Contributor

Added decoder for Somfy RTS. Tests are submitted in merbanan/rtl_433_tests#363.

@matthiasseemoo
Copy link
Contributor Author

Can we merge it like this?

@zuckschwerdt
Copy link
Collaborator

There is quite some jitter in the signal, the bit might not be missing but just wrongly detected. I.e. if you drop the OOK on https://triq.org/pdv/ both g015 and g006 look roughly the same.
(rtl_433 -w g015_433.414M_250k.ook g015_433.414M_250k.cu8 rtl_433 -w g006_433.414M_250k.ook g006_433.414M_250k.cu8)

jitter

@zuckschwerdt
Copy link
Collaborator

The code looks great. Let me figure out why that bit is sliced badly, perhaps there is no need for the added logic here then.
Btw. there is no sync for PCM, the comment is useful, but the field likely should not be set in the r_device.

@zuckschwerdt
Copy link
Collaborator

Yeah, including the pulse when slicing the gap for PCM skews the result. https://github.com/merbanan/rtl_433/blob/master/src/pulse_demod.c#L124
I need to consider why this could be useful and likely change it. Then you don't need that hack for the missing bit.

@zuckschwerdt
Copy link
Collaborator

The "missing bit after very long pulse" in PCM has been addressed with 97fdf16. Can you rebase and test?

@zuckschwerdt zuckschwerdt changed the title Add: Support for Somfy RTS decoding Add support for Somfy RTS Sep 17, 2020
@matthiasseemoo
Copy link
Contributor Author

So, finally I rebased by branch and verified that it now also works without the second call to the Manchester decoder. I also fixed the ID's endianess so that the two ID's in the test captures are just off by 1.

You can merge it now.

@zuckschwerdt
Copy link
Collaborator

Thanks for the great work, really looks good now. Look into the preamble note if you have time, but that's not a blocker.

@matthiasseemoo
Copy link
Contributor Author

Btw. I only added my C file into the CMake related files. I saw that there are also VC files for the Windows builds. Should I change them as well or do you do this. I cannot test the VC build on my side, though.

@matthiasseemoo
Copy link
Contributor Author

Besides the capture that I generated with rtl_433 using an rtl-sdr, I also generated a capture of the signal using the universal radio hacker (URH) and a HackRF. There, I set the sample rate to 8 Msps. However, when I try to analyze the file using rtl_433, all pulses are recognized as being too long. Changing the sample rate in the file name does not change the detected pulse lengths so it seems like the sample rate is not taken from the file name? Do I need to configure the sample rate manually in this case?

@zuckschwerdt
Copy link
Collaborator

To fix all build files run ./maintainer_update.py if you like, but I can do that on merge also.

The sample rate is currently not read back from the filename, planned and prepared though. -s8M is needed.

@matthiasseemoo
Copy link
Contributor Author

Running the tool with incorrect sample rate at least lists some pulses:

rtl_433 -R167 -r ../rtl_433_tests/tests/somfy/situo_5_rts_pure_ii/01/g001_433.414M_8000k.cu8 -vvvv
rtl_433 version 20.02-164-ga8aa328 branch master at 202009172208 inputs file rtl_tcp RTL-SDR SoapySDR
Use -h for usage help and see https://triq.org/ for documentation.
Trying conf file at "rtl_433.conf"...
Trying conf file at "/Users/matthias/.config/rtl_433/rtl_433.conf"...
Trying conf file at "/usr/local/etc/rtl_433/rtl_433.conf"...
Trying conf file at "/etc/rtl_433/rtl_433.conf"...
Registered 1 out of 167 device decoding protocols
Test mode active. Reading samples from file: ../rtl_433_tests/tests/somfy/situo_5_rts_pure_ii/01/g001_433.414M_8000k.cu8
Input format: CU8 IQ (2ch uint8)
Pulse data: 1 pulses
[  0] Pulse: 83449, Gap: 25001, Period: 108450
Pulse data: 44 pulses
[  0] Pulse: 19999, Gap: 20250, Period: 40249
[  1] Pulse: 19993, Gap: 20218, Period: 40211
[  2] Pulse: 38645, Gap: 10256, Period: 48901
[  3] Pulse: 10338, Gap: 10282, Period: 20620
[  4] Pulse: 10341, Gap: 5120, Period: 15461
[  5] Pulse: 5195, Gap: 5113, Period: 10308
[  6] Pulse: 5200, Gap: 5127, Period: 10327
[  7] Pulse: 5186, Gap: 5122, Period: 10308
[  8] Pulse: 5194, Gap: 10286, Period: 15480
[  9] Pulse: 5186, Gap: 5130, Period: 10316
[ 10] Pulse: 5185, Gap: 5123, Period: 10308
[ 11] Pulse: 10349, Gap: 10291, Period: 20640
[ 12] Pulse: 5179, Gap: 5124, Period: 10303
[ 13] Pulse: 10346, Gap: 10297, Period: 20643
[ 14] Pulse: 5175, Gap: 5145, Period: 10320
[ 15] Pulse: 5170, Gap: 5131, Period: 10301
[ 16] Pulse: 5184, Gap: 5132, Period: 10316
[ 17] Pulse: 10342, Gap: 10285, Period: 20627
[ 18] Pulse: 5186, Gap: 5128, Period: 10314
[ 19] Pulse: 10344, Gap: 10287, Period: 20631
[ 20] Pulse: 5184, Gap: 5128, Period: 10312
[ 21] Pulse: 10344, Gap: 5111, Period: 15455
[ 22] Pulse: 5202, Gap: 5124, Period: 10326
[ 23] Pulse: 5188, Gap: 5128, Period: 10316
[ 24] Pulse: 5185, Gap: 10283, Period: 15468
[ 25] Pulse: 5187, Gap: 5135, Period: 10322
[ 26] Pulse: 5180, Gap: 5124, Period: 10304
[ 27] Pulse: 10342, Gap: 5110, Period: 15452
[ 28] Pulse: 5201, Gap: 10275, Period: 15476
[ 29] Pulse: 10343, Gap: 10277, Period: 20620
[ 30] Pulse: 5187, Gap: 5129, Period: 10316
[ 31] Pulse: 5182, Gap: 5120, Period: 10302
[ 32] Pulse: 10347, Gap: 10281, Period: 20628
[ 33] Pulse: 5187, Gap: 5126, Period: 10313
[ 34] Pulse: 5185, Gap: 5135, Period: 10320
[ 35] Pulse: 10335, Gap: 10277, Period: 20612
[ 36] Pulse: 10351, Gap: 10281, Period: 20632
[ 37] Pulse: 10341, Gap: 10280, Period: 20621
[ 38] Pulse: 5186, Gap: 5137, Period: 10323
[ 39] Pulse: 10325, Gap: 10291, Period: 20616
[ 40] Pulse: 5171, Gap: 5116, Period: 10287
[ 41] Pulse: 5192, Gap: 5137, Period: 10329
[ 42] Pulse: 10329, Gap: 10287, Period: 20616
[ 43] Pulse: 4994, Gap: 25001, Period: 29995
Test mode file issued 7 packets

However, running it with the correct bandwidth does not list any pulses:

rtl_433 -R167 -r ../rtl_433_tests/tests/somfy/situo_5_rts_pure_ii/01/g001_433.414M_8000k.cu8 -vvvv -s8M
rtl_433 version 20.02-164-ga8aa328 branch master at 202009172208 inputs file rtl_tcp RTL-SDR SoapySDR
Use -h for usage help and see https://triq.org/ for documentation.
Trying conf file at "rtl_433.conf"...
Trying conf file at "/Users/matthias/.config/rtl_433/rtl_433.conf"...
Trying conf file at "/usr/local/etc/rtl_433/rtl_433.conf"...
Trying conf file at "/etc/rtl_433/rtl_433.conf"...
Registered 1 out of 167 device decoding protocols
Test mode active. Reading samples from file: ../rtl_433_tests/tests/somfy/situo_5_rts_pure_ii/01/g001_433.414M_8000k.cu8
Input format: CU8 IQ (2ch uint8)
Test mode file issued 7 packets

I did not commit this test file as it is 1.7 MB.

@matthiasseemoo
Copy link
Contributor Author

matthiasseemoo commented Sep 17, 2020

Running ./maintainer_update.py also adds the pulse_analyer.c file. Are the entries for this file maybe currently missing on the master?

diff --git a/src/Makefile.am b/src/Makefile.am
index e6cb397..ea5b209 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -18,6 +18,7 @@ rtl_433_SOURCES      = abuf.c \
                        optparse.c \
                        output_influx.c \
                        output_mqtt.c \
+                       pulse_analyzer.c \
                        pulse_demod.c \
                        pulse_detect.c \
                        pulse_detect_fsk.c \
diff --git a/vs15/rtl_433.vcxproj b/vs15/rtl_433.vcxproj
index b4d1810..b688946 100644
--- a/vs15/rtl_433.vcxproj
+++ b/vs15/rtl_433.vcxproj
@@ -110,6 +110,7 @@ COPY ..\..\libusb\MS64\dll\libusb*.dll $(TargetDir)</Command>
     <ClInclude Include="..\include\optparse.h" />
     <ClInclude Include="..\include\output_influx.h" />
     <ClInclude Include="..\include\output_mqtt.h" />
+    <ClInclude Include="..\include\pulse_analyzer.h" />
     <ClInclude Include="..\include\pulse_demod.h" />
     <ClInclude Include="..\include\pulse_detect.h" />
     <ClInclude Include="..\include\pulse_detect_fsk.h" />
@@ -142,6 +143,7 @@ COPY ..\..\libusb\MS64\dll\libusb*.dll $(TargetDir)</Command>
     <ClCompile Include="..\src\optparse.c" />
     <ClCompile Include="..\src\output_influx.c" />
     <ClCompile Include="..\src\output_mqtt.c" />
+    <ClCompile Include="..\src\pulse_analyzer.c" />
     <ClCompile Include="..\src\pulse_demod.c" />
     <ClCompile Include="..\src\pulse_detect.c" />
     <ClCompile Include="..\src\pulse_detect_fsk.c" />
@@ -263,6 +265,7 @@ COPY ..\..\libusb\MS64\dll\libusb*.dll $(TargetDir)</Command>
     <ClCompile Include="..\src\devices\simplisafe.c" />
     <ClCompile Include="..\src\devices\smoke_gs558.c" />
     <ClCompile Include="..\src\devices\solight_te44.c" />
+    <ClCompile Include="..\src\devices\somfy.c" />
     <ClCompile Include="..\src\devices\springfield.c" />
     <ClCompile Include="..\src\devices\steelmate.c" />
     <ClCompile Include="..\src\devices\tfa_30_3196.c" />
diff --git a/vs15/rtl_433.vcxproj.filters b/vs15/rtl_433.vcxproj.filters
index 41c5869..dcb792e 100644
--- a/vs15/rtl_433.vcxproj.filters
+++ b/vs15/rtl_433.vcxproj.filters
@@ -160,6 +160,9 @@ <U+FEFF><?xml version="1.0" encoding="utf-8"?>
     <ClCompile Include="..\src\output_mqtt.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\src\pulse_analyzer.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="..\src\pulse_demod.c">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -526,6 +529,9 @@ <U+FEFF><?xml version="1.0" encoding="utf-8"?>
     <ClCompile Include="..\src\devices\solight_te44.c">
       <Filter>Source Files\devices</Filter>
     </ClCompile>
+    <ClCompile Include="..\src\devices\somfy.c">
+      <Filter>Source Files\devices</Filter>
+    </ClCompile>
     <ClCompile Include="..\src\devices\springfield.c">
       <Filter>Source Files\devices</Filter>
     </ClCompile>

It might be best if you would just run the maintainer update while merging this PR.

@zuckschwerdt
Copy link
Collaborator

Oops, yes, I forgot to add that. Just include it, we'll merge this next anyway :)

@matthiasseemoo
Copy link
Contributor Author

done, happy merging :-)

@zuckschwerdt
Copy link
Collaborator

Can you push again so the new style checks can run?
Preferable add a commit which removes checksum and seed from the output as those don't contain any useful data. You can add a if-verbose-fprintf for those if you like.

@matthiasseemoo
Copy link
Contributor Author

It would be nice to get some line numbers for those errors:
Style Check0s
##[error]STDOUT line
Run ./.github/actions/style-check
##[error]NON-ASCII character error
##[error]TRAILING whitespace error
##[error]STDOUT line

@matthiasseemoo
Copy link
Contributor Author

I found it under actions:
Check failure on line 25 in src/devices/somfy.c

@github-actions
github-actions
/ Check code style

src/devices/somfy.c#L25
NON-ASCII character error
Check failure on line 43 in src/devices/somfy.c

@github-actions
github-actions
/ Check code style

src/devices/somfy.c#L43
TRAILING whitespace error

@matthiasseemoo
Copy link
Contributor Author

Done ;-)

@zuckschwerdt
Copy link
Collaborator

Should also be visible with pretty annotations on your commit: https://github.com/merbanan/rtl_433/pull/1496/files/cf953618d61caa6b2ffe7bb549a71f53cc8196fb..b858ea34a4cd55f100d0bae5118ad95b46c4545c
Thanks being the guinea pig here ;)

@zuckschwerdt zuckschwerdt merged commit efc7245 into merbanan:master Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants