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.
Dependencies: Adafruit-PWM-Servo-Driver MPU6050 RS300 mbed
Diff: SCI.cpp
- Revision:
- 13:711f74b2fa33
- Parent:
- 12:6cd135bf03bd
- Child:
- 14:522bb06f0f0d
--- a/SCI.cpp Sun Feb 03 04:53:44 2013 +0000
+++ b/SCI.cpp Sun Feb 03 21:22:21 2013 +0000
@@ -1,5 +1,6 @@
#include "mbed.h"
#include "SCI.h"
+#include <sstream>
SCI::SCI(PinName tx, PinName rx)
{
@@ -11,14 +12,17 @@
delete serial;
}
-char SCI::getid()
+int SCI::getid()
{
- char comm, id;
+ char comm;
+ int id = 255;
comm = getc_nowait();
if (comm == 'A') {
serial->putc(comm);
- serial->printf("command");
- id = getc_wait();
+ stringstream sstr;
+ sstr << getc_wait();
+ sstr >> id;
+ serial->printf("id = %d \r\n", id);
}
return id;
}
@@ -26,9 +30,10 @@
char SCI::getc_wait()
{
while (!serial->readable()) {
- serial->printf("waiting..");
+ //serial->printf("waiting..");
}
- return serial->getc();
+ char val = serial->getc();
+ return val;
}
char SCI::getc_nowait()
@@ -40,6 +45,11 @@
return buf;
}
+void SCI::printf(char* str)
+{
+ serial->printf(str);
+}
+
/*uint16_t readint(void)
{
uint8_t buff[16];