Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: SerialGPS_TestProgram Nucleo_SerialGPS_to_PC Nucleo_SerialGPS_to_PC SensorInterface ... more
Revision 1:a5b887e09aa4, committed 2010-10-12
- Comitter:
- shintamainjp
- Date:
- Tue Oct 12 22:22:28 2010 +0000
- Parent:
- 0:3d0c5d7e5d0a
- Commit message:
- First version.
Changed in this revision
--- a/SerialBuffered.cpp Mon Sep 20 06:03:38 2010 +0000
+++ b/SerialBuffered.cpp Tue Oct 12 22:22:28 2010 +0000
@@ -1,6 +1,12 @@
#include "mbed.h"
#include "SerialBuffered.h"
+/**
+ * Create a buffered serial class.
+ *
+ * @param tx A pin for transmit.
+ * @param rx A pin for receive.
+ */
SerialBuffered::SerialBuffered(PinName tx, PinName rx) : Serial(tx, rx) {
indexContentStart = 0;
indexContentEnd = 0;
@@ -8,13 +14,29 @@
attach(this, &SerialBuffered::handleInterrupt);
}
+/**
+ * Destroy.
+ */
SerialBuffered::~SerialBuffered() {
}
+/**
+ * Set timeout for getc().
+ *
+ * @param ms milliseconds. (-1:Disable timeout)
+ */
void SerialBuffered::setTimeout(int ms) {
timeout = ms;
}
+/**
+ * Read requested bytes.
+ *
+ * @param bytes A pointer to a buffer.
+ * @param requested Length.
+ *
+ * @return Readed byte length.
+ */
size_t SerialBuffered::readBytes(uint8_t *bytes, size_t requested) {
int i = 0;
while (i < requested) {
@@ -28,6 +50,11 @@
return i;
}
+/**
+ * Get a character.
+ *
+ * @return A character. (-1:timeout)
+ */
int SerialBuffered::getc() {
timer.reset();
timer.start();
@@ -49,6 +76,9 @@
return result;
}
+/**
+ * Returns 1 if there is a character available to read, 0 otherwise.
+ */
int SerialBuffered::readable() {
return indexContentStart != indexContentEnd;
}
--- a/SerialBuffered.h Mon Sep 20 06:03:38 2010 +0000
+++ b/SerialBuffered.h Tue Oct 12 22:22:28 2010 +0000
@@ -13,7 +13,7 @@
* @param rx A pin for receive.
*/
SerialBuffered(PinName tx, PinName rx);
-
+
/**
* Destroy.
*/
@@ -50,7 +50,7 @@
private:
void handleInterrupt();
- static const int BUFFERSIZE = 4096;
+ static const int BUFFERSIZE = 2048;
uint8_t buffer[BUFFERSIZE]; // points at a circular buffer, containing data from m_contentStart, for m_contentSize bytes, wrapping when you get to the end
uint16_t indexContentStart; // index of first bytes of content
uint16_t indexContentEnd; // index of bytes after last byte of content
--- a/SerialGPS.cpp Mon Sep 20 06:03:38 2010 +0000
+++ b/SerialGPS.cpp Tue Oct 12 22:22:28 2010 +0000
@@ -50,7 +50,7 @@
src[cnt++] = c & 0xff;
} while (!done);
} while (cnt <= 1);
-
+
/*
* Return if the callback function does not exists.
*/
--- a/SerialGPS.h Mon Sep 20 06:03:38 2010 +0000
+++ b/SerialGPS.h Tue Oct 12 22:22:28 2010 +0000
@@ -56,7 +56,7 @@
} gps_gga_t;
/**
- * GSAâ€hGNSS DOP and Active Satellites.
+ * GSA hGNSS DOP and Active Satellites.
*
* $GPGSA,A,3,07,02,26,27,09,04,15, , , , , ,1.8,1.0,1.5*33
*/
Grove GPS