-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the optional System Fusion Parrot.
- Loading branch information
Showing
11 changed files
with
206 additions
and
5 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ ColorCode=1 | |
|
||
[System Fusion] | ||
Enable=1 | ||
Parrot=1 | ||
|
||
[D-Star Network] | ||
Enable=1 | ||
|
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
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
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
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,92 @@ | ||
/* | ||
* Copyright (C) 2016 by Jonathan Naylor G4KLX | ||
* | ||
* 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 2 of the License, 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; if not, write to the Free Software | ||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
*/ | ||
|
||
#include "YSFParrot.h" | ||
#include "YSFDefines.h" | ||
#include "Defines.h" | ||
|
||
#include <cstdio> | ||
#include <cassert> | ||
#include <cstring> | ||
|
||
CYSFParrot::CYSFParrot(unsigned int timeout) : | ||
m_data(NULL), | ||
m_length(timeout * 1220U + 1000U), | ||
m_used(0U), | ||
m_ptr(0U), | ||
m_timer(1000U, 2U) | ||
{ | ||
assert(timeout > 0U); | ||
|
||
m_data = new unsigned char[m_length]; | ||
} | ||
|
||
CYSFParrot::~CYSFParrot() | ||
{ | ||
delete[] m_data; | ||
} | ||
|
||
bool CYSFParrot::write(const unsigned char* data) | ||
{ | ||
assert(data != NULL); | ||
|
||
if ((m_length - m_used) < 1000U) | ||
return false; | ||
|
||
::memcpy(m_data + m_used, data, YSF_FRAME_LENGTH_BYTES + 2U); | ||
m_used += YSF_FRAME_LENGTH_BYTES + 2U; | ||
|
||
if (data[0U] == TAG_EOT) { | ||
m_timer.start(); | ||
m_ptr = 0U; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
void CYSFParrot::read(unsigned char* data) | ||
{ | ||
assert(data != NULL); | ||
|
||
if (m_used == 0U) | ||
return; | ||
|
||
::memcpy(data, m_data + m_ptr, YSF_FRAME_LENGTH_BYTES + 2U); | ||
m_ptr += YSF_FRAME_LENGTH_BYTES + 2U; | ||
|
||
if (m_ptr >= m_used) { | ||
m_timer.stop(); | ||
m_used = 0U; | ||
} | ||
} | ||
|
||
bool CYSFParrot::hasData() | ||
{ | ||
if (m_timer.isRunning() && m_timer.hasExpired()) | ||
return true; | ||
|
||
if (m_used == 0U) | ||
return false; | ||
|
||
return false; | ||
} | ||
|
||
void CYSFParrot::clock(unsigned int ms) | ||
{ | ||
m_timer.clock(ms); | ||
} |
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,46 @@ | ||
/* | ||
* Copyright (C) 2016 by Jonathan Naylor G4KLX | ||
* | ||
* 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 2 of the License, 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; if not, write to the Free Software | ||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
*/ | ||
|
||
#if !defined(YAFParrot_H) | ||
#define YSFParrot_H | ||
|
||
#include "Timer.h" | ||
|
||
class CYSFParrot | ||
{ | ||
public: | ||
CYSFParrot(unsigned int timeout); | ||
~CYSFParrot(); | ||
|
||
bool write(const unsigned char* data); | ||
|
||
void read(unsigned char* data); | ||
|
||
bool hasData(); | ||
|
||
void clock(unsigned int ms); | ||
|
||
private: | ||
unsigned char* m_data; | ||
unsigned int m_length; | ||
unsigned int m_used; | ||
unsigned int m_ptr; | ||
CTimer m_timer; | ||
}; | ||
|
||
#endif |