- You must be logged in to reply to this topic.
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
Tagged: serial.flush() FONA
I understand that Serial.flush() is empty for Adafruit FONA. In Print.h:
virtual void flush() { /* Empty implementation for backward compatibility */ }
I need to make sure that all Serial.print() statements are completed before I enter sleep mode for the FONA, otherwise it will be subsequently woken up in Serial.print code (and crashes) instead of in loop().
Is there any code that can accomplish this?
Are you sure they are empty? flush() could be implemented in Stream class. I could be wrong because I rarely use 32U4.
Try putting some characters into print() and call flush() before sleep. See whether all characters are sent before sleep.
Else it is best to simply put a delay by comparing it to millis(). Just estimate the time by calculating how many bytes you are sending.
LIM PHANG MOH,
Again, thanks for your effort. Yes, I did call flush() before sleep and it crashed. Found this code:
u16 flushOutput()
{
u16 count;
while ((count = FifoByteCount()) != 0);
return count; // Returns 0
}
u16 FifoByteCount()
{
return ((((u16)UEBCHX) << 8) | (UEBCLX));
}
It compiles ok but does not wait untill the output buffer is empty.
Regarding delay() : I cannot estimate the number of characters waiting to be output. They come from various libraries with DEBUG_PRINT and the like.
There must surely be a way to interrogate the output queue in the build-in UART in Atmel 32u4.
This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.
OKWe may request cookies to be set on your device. We use cookies to let us know when you visit our websites, how you interact with us, to enrich your user experience, and to customize your relationship with our website.
Click on the different category headings to find out more. You can also change some of your preferences. Note that blocking some types of cookies may impact your experience on our websites and the services we are able to offer.
These cookies are strictly necessary to provide you with services available through our website and to use some of its features.
Because these cookies are strictly necessary to deliver the website, refusing them will have impact how our site functions. You always can block or delete cookies by changing your browser settings and force blocking all cookies on this website. But this will always prompt you to accept/refuse cookies when revisiting our site.
We fully respect if you want to refuse cookies but to avoid asking you again and again kindly allow us to store a cookie for that. You are free to opt out any time or opt in for other cookies to get a better experience. If you refuse cookies we will remove all set cookies in our domain.
We provide you with a list of stored cookies on your computer in our domain so you can check what we stored. Due to security reasons we are not able to show or modify cookies from other domains. You can check these in your browser security settings.
These cookies collect information that is used either in aggregate form to help us understand how our website is being used or how effective our marketing campaigns are, or to help us customize our website and application for you in order to enhance your experience.
If you do not want that we track your visit to our site you can disable tracking in your browser here:
We also use different external services like Google Webfonts, Google Maps, and external Video providers. Since these providers may collect personal data like your IP address we allow you to block them here. Please be aware that this might heavily reduce the functionality and appearance of our site. Changes will take effect once you reload the page.
Google Webfont Settings:
Google Map Settings:
Google reCaptcha Settings:
Vimeo and Youtube video embeds:
The following cookies are also needed - You can choose if you want to allow them:
You can read about our cookies and privacy settings in detail on our Privacy Policy Page.
Privacy Policy