This repository has been archived by the owner on Sep 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa26754
commit e7df218
Showing
7 changed files
with
121 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) 2011 Aliaksei Stratsilatau <[email protected]> | ||
* | ||
* This file is part of the UAV Open System Project | ||
* http://www.uavos.com/ | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation; either version 3, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; see the file COPYING. If not, write to | ||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth | ||
* Floor, Boston, MA 02110-1301, USA. | ||
* | ||
*/ | ||
#include "EscReader.h" | ||
//============================================================================= | ||
EscReader::EscReader(QObject *parent) | ||
: QObject(parent), _escaped() | ||
{} | ||
void EscReader::push(const QByteArray ba) | ||
{ | ||
data.append(ba); | ||
while(!data.isEmpty()){ | ||
uint cnt=readEscaped(); | ||
if(!cnt)continue; | ||
emit packet_read(QByteArray((const char*)esc_rx,cnt)); | ||
//qDebug("pkt"); | ||
} | ||
} | ||
//_escaped override | ||
uint EscReader::read(uint8_t *buf,uint sz) | ||
{ | ||
if(data.isEmpty())return 0; | ||
if((int)sz>data.size())sz=data.size(); | ||
memcpy(buf,data.data(),sz); | ||
data=data.mid(sz); | ||
return sz; | ||
} | ||
bool EscReader::write_byte(const uint8_t v) | ||
{ | ||
Q_UNUSED(v); | ||
return true; | ||
} | ||
void EscReader::escError(void) | ||
{ | ||
//qWarning("ESC reader error"); | ||
} | ||
//============================================================================= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (C) 2011 Aliaksei Stratsilatau <[email protected]> | ||
* | ||
* This file is part of the UAV Open System Project | ||
* http://www.uavos.com/ | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation; either version 3, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; see the file COPYING. If not, write to | ||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth | ||
* Floor, Boston, MA 02110-1301, USA. | ||
* | ||
*/ | ||
#ifndef EscReader_H | ||
#define EscReader_H | ||
#include <QtCore> | ||
#include "escaped.h" | ||
//============================================================================= | ||
class EscReader: public QObject, public _escaped | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit EscReader(QObject *parent=0); | ||
void push(const QByteArray ba); | ||
//_escaped override | ||
uint read(uint8_t *buf,uint sz); | ||
bool write_byte(const uint8_t v); | ||
void escError(void); | ||
private: | ||
QByteArray data; | ||
signals: | ||
void packet_read(const QByteArray &ba); | ||
}; | ||
//============================================================================= | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters