-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 General Motors TPMS #3191
Add General Motors TPMS #3191
Conversation
src/devices/tpms_gm.c
Outdated
@@ -0,0 +1,161 @@ | |||
/** @file | |||
General Motors Aftermarket TPMS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
End the first line with a dot.
src/devices/tpms_gm.c
Outdated
*/ | ||
|
||
#include "decoder.h" | ||
#include "r_util.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include only decoder.h if possible.
src/devices/tpms_gm.c
Outdated
#include <stdio.h> | ||
#include <inttypes.h> // Needed for PRIX64 | ||
|
||
static uint8_t const preamble_pattern[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this into the decoder function.
src/devices/tpms_gm.c
Outdated
static uint8_t const preamble_pattern[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | ||
|
||
/** | ||
Data was detected an initially captured using: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first line should be the same as line 2
src/devices/tpms_gm.c
Outdated
/** | ||
Data was detected an initially captured using: | ||
|
||
rtl_433 -X 'n=name,m=OOK_MC_ZEROBIT,s=120,l=0,r=15600' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
four spaces indent for code lines
src/devices/tpms_gm.c
Outdated
|
||
|
||
|
||
130 bits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
src/devices/tpms_gm.c
Outdated
130 bits | ||
AAAAAAAAAAAASSSSDDDDIIIIIIPPTTCCX | ||
0000000000004c90007849176600536d0 | ||
Data layout: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no indent for header lines
src/devices/tpms_gm.c
Outdated
Bit 5 of status indicates low battery when set to 1 | ||
Bits 0,1,8 are set to 0 to indicate learn mode and 1 for operational mode. | ||
The sensors drop to learn mode when detecting a large pressure drop | ||
or when activated with the learning tool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
end sentences with a dot
src/devices/tpms_gm.c
Outdated
// But I think it might be best to allow the user to | ||
// to add their own offset when consuming the data | ||
float pressure_kpa = (pressure_raw * 2.75); | ||
float pressure_psi = kpa2psi(pressure_kpa); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
output native units, don't convert in decoders
src/devices/tpms_gm.c
Outdated
int bit0 = (status >> 0) & 1; | ||
|
||
// Status bits | ||
int learn_mode = ((bit8 == 0) && (bit1 == 0) && (bit0 == 0)) ? 1 : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't ? 1 : 0
on a bool
Thanks! Some code style comments :) |
@zuckschwerdt The docs suggest id should be integer but I noticed that all of the TPMS decoders output a hex string for id, should I change my code to be consistent with other TPMS? |
A plain int for "id" is preferred. You can use something like |
I believe all of your suggestions have been addressed. |
Thanks!
should be
flags, pressure_raw, temperature_raw should just be The model must follow https://triq.org/rtl_433/DATA_FORMAT.html, likely Run |
@zuckschwerdt Hopefully I have not overlooked anything this time. |
This adds a decoder for one of the protocols discussed in #3123