Преглед изворни кода

Rename function to bitmap_reverse_bytes_bits() for clarity.

antirez пре 3 година
родитељ
комит
9f9115ed2c
3 измењених фајлова са 4 додато и 4 уклоњено
  1. 1 1
      app.h
  2. 2 2
      protocols/keeloq.c
  3. 1 1
      signal.c

+ 1 - 1
app.h

@@ -256,7 +256,7 @@ bool bitmap_get(uint8_t *b, uint32_t blen, uint32_t bitpos);
 void bitmap_set(uint8_t *b, uint32_t blen, uint32_t bitpos, bool val);
 void bitmap_set(uint8_t *b, uint32_t blen, uint32_t bitpos, bool val);
 void bitmap_copy(uint8_t *d, uint32_t dlen, uint32_t doff, uint8_t *s, uint32_t slen, uint32_t soff, uint32_t count);
 void bitmap_copy(uint8_t *d, uint32_t dlen, uint32_t doff, uint8_t *s, uint32_t slen, uint32_t soff, uint32_t count);
 void bitmap_set_pattern(uint8_t *b, uint32_t blen, uint32_t off, const char *pat);
 void bitmap_set_pattern(uint8_t *b, uint32_t blen, uint32_t off, const char *pat);
-void bitmap_reverse_bytes(uint8_t *p, uint32_t len);
+void bitmap_reverse_bytes_bits(uint8_t *p, uint32_t len);
 bool bitmap_match_bits(uint8_t *b, uint32_t blen, uint32_t bitpos, const char *bits);
 bool bitmap_match_bits(uint8_t *b, uint32_t blen, uint32_t bitpos, const char *bits);
 uint32_t bitmap_seek_bits(uint8_t *b, uint32_t blen, uint32_t startpos, uint32_t maxbits, const char *bits);
 uint32_t bitmap_seek_bits(uint8_t *b, uint32_t blen, uint32_t startpos, uint32_t maxbits, const char *bits);
 uint32_t convert_from_line_code(uint8_t *buf, uint64_t buflen, uint8_t *bits, uint32_t len, uint32_t offset, const char *zero_pattern, const char *one_pattern);
 uint32_t convert_from_line_code(uint8_t *buf, uint64_t buflen, uint8_t *bits, uint32_t len, uint32_t offset, const char *zero_pattern, const char *one_pattern);

+ 2 - 2
protocols/keeloq.c

@@ -58,7 +58,7 @@ static bool decode(uint8_t *bits, uint32_t numbytes, uint32_t numbits, ProtoView
 
 
     info->pulses_count = (off+66*3) - info->start_off;
     info->pulses_count = (off+66*3) - info->start_off;
 
 
-    bitmap_reverse_bytes(raw,sizeof(raw)); /* Keeloq is LSB first. */
+    bitmap_reverse_bytes_bits(raw,sizeof(raw)); /* Keeloq is LSB first. */
 
 
     int buttons = raw[7]>>4;
     int buttons = raw[7]>>4;
     int lowbat = (raw[8]&0x1) == 0; // Actual bit meaning: good battery level
     int lowbat = (raw[8]&0x1) == 0; // Actual bit meaning: good battery level
@@ -104,7 +104,7 @@ static void build_message(RawSamplesBuffer *samples, ProtoViewFieldSet *fieldset
     low_battery = !low_battery; // Bit real meaning is good battery level.
     low_battery = !low_battery; // Bit real meaning is good battery level.
     data[8] |= low_battery;
     data[8] |= low_battery;
     data[8] |= (always_one << 1);
     data[8] |= (always_one << 1);
-    bitmap_reverse_bytes(data,sizeof(data)); /* Keeloq is LSB first. */
+    bitmap_reverse_bytes_bits(data,sizeof(data)); /* Keeloq is LSB first. */
 
 
     for (int j = 0; j < 66; j++) {
     for (int j = 0; j < 66; j++) {
         if (bitmap_get(data,9,j)) {
         if (bitmap_get(data,9,j)) {

+ 1 - 1
signal.c

@@ -343,7 +343,7 @@ void bitmap_copy(uint8_t *d, uint32_t dlen, uint32_t doff,
 /* We decode bits assuming the first bit we receive is the MSB
 /* We decode bits assuming the first bit we receive is the MSB
  * (see bitmap_set/get functions). Certain devices send data
  * (see bitmap_set/get functions). Certain devices send data
  * encoded in the reverse way. */
  * encoded in the reverse way. */
-void bitmap_reverse_bytes(uint8_t *p, uint32_t len) {
+void bitmap_reverse_bytes_bits(uint8_t *p, uint32_t len) {
     for (uint32_t j = 0; j < len; j++) {
     for (uint32_t j = 0; j < len; j++) {
         uint32_t b = p[j];
         uint32_t b = p[j];
         /* Step 1: swap the two nibbles: 12345678 -> 56781234 */
         /* Step 1: swap the two nibbles: 12345678 -> 56781234 */