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: telemetry_car_demo telemetry_demo_FRDM-TFC telemetry_example_01 telemetry_indexed_data_demo ... more
Revision 2:b7a3ac7bcec8, committed 2016-02-11
- Comitter:
- Overdrivr
- Date:
- Thu Feb 11 08:10:08 2016 +0000
- Parent:
- 1:e51abb43c074
- Child:
- 3:37d2d127bc83
- Commit message:
- Replaced MODSERIAL by BufferedSerial for increasing amount of supported devices
Changed in this revision
| driver.cpp | Show annotated file Show diff for this revision Revisions of this file |
| driver.hpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/driver.cpp Thu Jan 28 10:00:45 2016 +0000
+++ b/driver.cpp Thu Feb 11 08:10:08 2016 +0000
@@ -1,7 +1,7 @@
-#include "MODSERIAL.h"
+#include "BufferedSerial.h"
#include "driver.hpp"
-static MODSERIAL pc(USBTX, USBRX);
+static BufferedSerial pc(USBTX, USBRX);
// Physical driver
@@ -11,21 +11,17 @@
return 1;
}
-int32_t readable()
-{
- return pc.rxBufferGetCount();
-}
-
int32_t write(void * buf, uint32_t sizeToWrite)
{
- char * ptr = (char *)buf;
- for(uint32_t i = 0 ; i < sizeToWrite ; i++)
- {
- pc.putc(ptr[i]);
- }
+ pc.write(buf,sizeToWrite);
return 0;
}
+int32_t readable()
+{
+ return pc.readable();
+}
+
int32_t writeable()
{
return pc.writeable();
@@ -33,7 +29,7 @@
// C++ interface
-Telemetry::Telemetry(TM_state* userData)
+Telemetry::Telemetry(TM_state* userData, uint32_t bauds)
{
transport.read = read;
transport.write = write;
@@ -42,7 +38,7 @@
init_telemetry(userData, &transport);
- pc.baud(9600);
+ pc.baud(bauds);
}
uint32_t Telemetry::cast(TM_msg * m, char * buf, size_t bufSize)
--- a/driver.hpp Thu Jan 28 10:00:45 2016 +0000
+++ b/driver.hpp Thu Feb 11 08:10:08 2016 +0000
@@ -6,7 +6,7 @@
class Telemetry
{
public:
- Telemetry(TM_state* userData);
+ Telemetry(TM_state* userData, uint32_t bauds = 9600);
uint32_t cast(TM_msg * m, char * buf, size_t bufSize);
uint32_t cast_u8(TM_msg * m, uint8_t * dst);