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

v1.2.1: Major rewrite and new features (data download) #54

Open
wants to merge 32 commits into
base: master
Choose a base branch
from

Conversation

Fasgort
Copy link

@Fasgort Fasgort commented Apr 11, 2018

I have rewritten most of the code to implement some of the methods that were not implemented, mainly GetImage(), GetRawImage(), GetTemplate() and SetTemplate().

The change list goes like this:

  • Implemented Data_Packet to send over HardwareSerial the data from the new implemented methods.
  • The FPS initialization can now start comms whatever the actual baud rate is (useful if you changed it and didn't restart the FPS). Also can set the initial desired baud rate from the start.
  • Implemented warnings about serial buffer overflow (will happen if you set a too high baud rate).
  • Implemented an experimental patch in GetImage(). Whatever the GT-511C3 documentation says about this is wrong or outdated. You can use the patch by including a true in the method call. By default it will use the documented method.
  • Rewrite of variables (using fixed size ones), and memory optimizations.

Tested all methods with Arduino Uno and GT-511C3 FPS. Any existing code using this library shouldn't have any problem updating to this version, since the method declarations are mostly unmodified.

If this is accepted, any feedback about other FPS devices, implementations with Arduino, bugs, etc., would be very helpful.

Fasgort added 17 commits March 25, 2018 22:47
- Fixed baudrate method. (SEE NEXT).
- Fixed variable type used for parameter (used 2-byte type, it required 4-byte type).
- Some minor memory optimizations done.
…r with the desired baud rate you want to establish communications, as additional parameter. Furthermore, comms won't fail while initializing if the FPS baud rate was established to something else than 9600.
   - Detect serial overflow, stopping data download and clearing the buffer before resuming activity.
   - Disabled most debug messages during data download (It will fail pretty much always).
   - Disabled checksum handling. Arguably useless and slow down the data download, resulting in buffer overflows.

Testing some use cases with data download from the FPS (GT-511C3):
   - 9600 and 19200 baud rates are too slow and will shutdown the FPS.
   - 38400 works pretty fast and stable.
   - 57600 also works, but you can't use debug messages and you MUST allocate all CPU time to the task.
   - 115200 is way too fast and will overflow the buffer immediately.

Short summary, the moment you send the command packet to start downloading, you are in a race against the FPS to receive, process and send the data before your serial buffer overflow. A slower baud rate will allow you to allocate less CPU time to the task, but go too slow and the FPS will shutdown (some kind of timeout?).
…tRawImage().

Other changes:
   - Memory optimizations.
   - Some minor fixes in other methods.
   - Tested with GT-511C3: baud rates 38400 and 57600 work pretty well.
- Data overflow warning will only appear when UseDebugSerial is set.
- Little memory optimizations.
- Renamed a few variables to make the code easier to read.
…wnload enough to be an issue. Fixed some bugs too in the checksum code.

Download methods will send 2 more bytes (byte addition checksum) after the data buffer, so you can check if the data is correct in whatever the destination device is.
…Other changes:

   - Further optimizations.
   - Checksum enabled again after some testing.
   - Added a little "patch" for GetImage().
…l do), I implemented a function that allows you to return the template, instead of just simply sending it over Serial. Have fun.
…over 800 bytes in the SRAM). Instead, they are now saved in flash memory.
…ws you to download and return the template without sending it over serial. Other changes:

   - Further optimizations.
   - Fixed a few errors with the count of packets needed.
   - Debug methods won't use too much memory anymore.
   - A new way to enable or disable debug code.
   - ReturnData() method that works almost exactly as GetData(), but returning the data instead, allowing you for further data processing.
bool retval = rp->ACK;
delete rp;

if (!patched) GetData(52116+6);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these numbers for the size of the image? A constant, or comment here would help a lot.

Copy link
Author

Choose a reason for hiding this comment

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

Line 824 indicates: // Gets an image that is 258x202 (52116 bytes + 2 bytes checksum) and sends it over serial

I'm missing the 4 bytes from the data code, but it's basically 52116 bytes from the image, + 4 bytes of data code and + 2 bytes from the checksum.

Choose a reason for hiding this comment

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

please how do i implement this updated library for my arduino project

…hod (thanks @JoshHawley for finding this one).

(cherry picked from commit aa06925)
@bboyho bboyho mentioned this pull request May 19, 2020
@EmmanuelPeace
Copy link

Please how i implement this updated library in my arduino project

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.

3 participants