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: Nucleo_NHK_2018_syudo_wheel a_team_R1370 Nucleo_NHK_2018_syudo_wheel 2018NHK_gaku_ver2 ... more
Revision 1:a28d64ee7a79, committed 2018-08-29
- Comitter:
- UCHITAKE
- Date:
- Wed Aug 29 04:39:35 2018 +0000
- Parent:
- 0:a6b2ad4005b0
- Child:
- 2:a14ba6b3f198
- Child:
- 3:dd947d95765a
- Commit message:
- fixed BUG
Changed in this revision
| SerialMultiByte.cpp | Show annotated file Show diff for this revision Revisions of this file |
| SerialMultiByte.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/SerialMultiByte.cpp Wed Aug 29 02:49:51 2018 +0000
+++ b/SerialMultiByte.cpp Wed Aug 29 04:39:35 2018 +0000
@@ -1,7 +1,8 @@
#include "SerialMultiByte.h"
SerialMultiByte::SerialMultiByte(PinName tx, PinName rx) :
- RawSerial(tx, rx)
+ RawSerial(tx, rx),
+ myled(LED1)
{
header[0] = DEFAULT_FIRST_HEADER;
header[1] = DEFAULT_SECOND_HEADER;
@@ -31,7 +32,7 @@
{
while(true) {
if(buffer.size() > bufferSize) {
- if(buffer[0] == header[0] && buffer[1] == header[0]) {
+ if(buffer[0] == header[0] && buffer[1] == header[1]) {
checkData();
buffer.erase(buffer.begin(), buffer.begin() + (bufferSize - 1));
} else {
@@ -48,11 +49,12 @@
void SerialMultiByte::checkData()
{
- uint8_t checksum = 0xff;
+ uint8_t checksum = 0x00;
for(int i = 2; i < bufferSize - 1; i++) {
checksum += buffer[i];
}
if(checksum == buffer[bufferSize - 1]) {
+ myled = !myled;
for(int i = 2; i < bufferSize - 1; i++) {
data[i-2] = buffer[i];
}
@@ -68,7 +70,7 @@
void SerialMultiByte::sendData(uint8_t data_[], uint16_t length)
{
- uint8_t checksum = 0;
+ uint8_t checksum = 0x00;
for(int i = 0; i < length; i++) {
checksum += data_[i];
}
--- a/SerialMultiByte.h Wed Aug 29 02:49:51 2018 +0000
+++ b/SerialMultiByte.h Wed Aug 29 04:39:35 2018 +0000
@@ -20,6 +20,7 @@
void sendData(uint8_t data_[], uint16_t length);
private :
+ DigitalOut myled;
void receiveLoop();
void receiveByte();
void checkData();