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

Quick and dirty tool to decode GC codes #308

Merged
merged 9 commits into from
Oct 2, 2017
Merged

Quick and dirty tool to decode GC codes #308

merged 9 commits into from
Oct 2, 2017

Conversation

jorgecis
Copy link
Contributor

@jorgecis jorgecis commented Oct 1, 2017

I created a tool to decode a GC code, the code is quick and dirty but I think that can be used as the base to create something better.

Example Power on for Roku

./gc_decode 38000,1,69,342,172,21,21,21,64,21,21,21,64,21,21,21,64,21,64,21,64,21,21,21,64,21,21,21,21,21,21,21,21,21,64,21,64,21,64,21,64,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,64,21,64,21,64,21,64,21,64,21,64,21,1524,342,172,21,21,21,64,21,21,21,64,21,21,21,64,21,64,21,64,21,21,21,64,21,21,21,21,21,21,21,21,21,64,21,64,21,64,21,64,21,21,21,21,21,21,21,21,21,21,21,64,21,21,21,21,21,64,21,64,21,64,21,64,21,64,21,21,21,1524
Code GC length 139
Code type 3
Code bits 32
Code value 5743c03f
Code address c2ea
Code command 3

Copy link
Owner

@crankyoldgit crankyoldgit left a comment

Choose a reason for hiding this comment

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

First of all, wow, thanks for doing this. That's really useful. I apologize in advance for my feedback/comments/suggestions. They are mostly minor nitpicks and style guide things to make things look/read better later on.

One other nitpick/suggestion, could you use a 'tools' directory instead of 'tool' I'm sure we will collect more down the track. Might as well name it correctly this time around. ;-)

Basically, other than the nitpicks, it looks good. We really should only have one copy of IRsend_test.h though. :-/

@@ -0,0 +1,104 @@
// Copyright 2017 David Conran

#ifndef TEST_IRSEND_TEST_H_
Copy link
Owner

Choose a reason for hiding this comment

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

Can you reference the canonical file instead of making essentially a copy of it here? It would be better if you just included the "real" IRsend_test.h file instead of making a copy which we need to keep in sync etc.

tool/Makefile Outdated
COMMON_DEPS = $(USER_DIR)/IRrecv.h $(USER_DIR)/IRsend.h $(USER_DIR)/IRtimer.h \
$(USER_DIR)/IRutils.h $(USER_DIR)/IRremoteESP8266.h
# Common test dependencies
COMMON_TEST_DEPS = $(COMMON_DEPS) IRsend_test.h
Copy link
Owner

Choose a reason for hiding this comment

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

per the other comment, perhaps ../test/IRsend_test.h instead? or what ever makes it use the original file.

@@ -0,0 +1,62 @@
#include "IRsend.h"
#include "IRsend_test.h"
Copy link
Owner

Choose a reason for hiding this comment

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

Per other comments. Lets use the original file.

Also, the ordering of the headers I think needs to be different per styleguide.
https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes



int main (int argc, char * argv[]) {

Copy link
Owner

Choose a reason for hiding this comment

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



if (argc != 2) {
cout << "Use gc_decode [global_code]" << endl;
Copy link
Owner

Choose a reason for hiding this comment

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

Indenting misaligned. pls fix.

char * pch;
pch = strtok (argv[1],",");
while (pch != NULL)
{
Copy link
Owner

Choose a reason for hiding this comment

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

Bracer to the end of the previous line. (style guide thing)


char * pch;
pch = strtok (argv[1],",");
while (pch != NULL)
Copy link
Owner

Choose a reason for hiding this comment

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

You need a bounds check on the size of gc_test so you don't go writing data outside the array.
e.g.
while (pch != NULL && index < 250) {

return 0;
}

uint16_t gc_test[250];
Copy link
Owner

Choose a reason for hiding this comment

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

Nitpick/suggestion: Probably best to put the 250 value into a #define etc, and make it larger. e.g. 512 or something. Some GC codes can be very long.

irrecv.decode(&irsend.capture);

cout << "Code GC length " << index << endl;
cout << "Code type " << irsend.capture.decode_type << endl;
Copy link
Owner

Choose a reason for hiding this comment

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

You should probably also print out the common name for the type. e.g. See the switch statement in the dumpV2 example code.

cout << "Code command " << std::hex << irsend.capture.command << endl;

return 0;
}
Copy link
Owner

Choose a reason for hiding this comment

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

Can you please run the Google cpplint.py over this code? https://github.com/cpplint/cpplint
Also, can you please add it to the travis.yaml file so a) it gets a "does it compile" check, and b) update the cpplint.py call/args in the travis.yaml file to also cover code in this directory, so it gets linted etc. ;-)

@crankyoldgit
Copy link
Owner

Oh, and please feel free to add yourself to the contributers file etc. If you want. ;-)

Added #define to control the max length for the GC code.
Now show the type of code as string
Fix errors found using cpplint
Removed unused headers
@jorgecis
Copy link
Contributor Author

jorgecis commented Oct 1, 2017

Hi David

I think that I did all the changes that you requested, as I said, my code was something that I did very quickly and I know that was very dirty. I did the change to travis.yml too.

If there anything else please let me know. by the way, this library is awesome I used it on my hardware.

@crankyoldgit
Copy link
Owner

crankyoldgit commented Oct 2, 2017

Looks great to me!
Thanks for all the changes. I made a few minor cosmetic tweaks as well.

And a big thanks for adding to the project and doing this. ;-)

@crankyoldgit crankyoldgit merged commit 489df09 into crankyoldgit:master Oct 2, 2017
@crankyoldgit crankyoldgit added the Hacktoberfest Hacktoberfest participation label Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Hacktoberfest Hacktoberfest participation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants