# Path: src/crazyflieROS/cflib/crtp/crtpdriver.py
# class CRTPDriver:
#     """ CTRP Driver main class
# 
#     This class in inherited by all the CRTP link drivers.
#     """
# 
#     def __init__(self):
#         """Driver constructor. Throw an exception if the driver is unable to
#         open the URI
#         """
# 
#     def connect(self, uri, link_quality_callback, link_error_callback):
#         """Connect the driver to a specified URI
# 
#         @param uri Uri of the link to open
#         @param link_quality_callback Callback to report link quality in percent
#         @param link_error_callback Callback to report errors (will result in
#                disconnection)
#         """
# 
#     def send_packet(self, pk):
#         """Send a CRTP packet"""
# 
#     def receive_packet(self, wait=0):
#         """Receive a CRTP packet.
# 
#         @param wait The time to wait for a packet in second. -1 means forever
# 
#         @return One CRTP packet or None if no packet has been received.
#         """
# 
#     def get_status(self):
#         """
#         Return a status string from the interface.
#         """
# 
#     def get_name(self):
#         """
#         Return a human readable name of the interface.
#         """
# 
#     def scan_interface(self):
#         """
#         Scan interface for available Crazyflie quadcopters and return a list
#         witha them.
#         """
# 
#     def enum(self):
#         """Enumerate, and return a list, of the available link URI on this
#         system
#         """
# 
#     def get_help(self):
#         """return the help message on how to form the URI for this driver
#         None means no help
#         """
# 
#     def close(self):
#         """Close the link"""
# 
# Path: src/crazyflieROS/cflib/crtp/exceptions.py
# class WrongUriType (Exception):
#     """ Wrong type of URI for this interface """
#     pass


from .crtpdriver import CRTPDriver
from .exceptions import WrongUriType
import re
#
#  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., 51 Franklin Street, Fifth Floor, Boston,
#  MA  02110-1301, USA.

"""
An early serial link driver. This could still be used (after some fixing) to
run high-speed CRTP with the Crazyflie. The UART can be run at 2Mbit.
"""

__author__ = 'Bitcraze AB'
__all__ = ['SerialDriver']





class SerialDriver (CRTPDriver):
    def __init__(self):
        None

    def connect(self, uri, linkQualityCallback, linkErrorCallback):
        #check if the URI is a serial URI
        if not re.search("^serial://", uri):

# Path: src/crazyflieROS/cflib/crtp/crtpdriver.py
# class CRTPDriver:
#     """ CTRP Driver main class
# 
#     This class in inherited by all the CRTP link drivers.
#     """
# 
#     def __init__(self):
#         """Driver constructor. Throw an exception if the driver is unable to
#         open the URI
#         """
# 
#     def connect(self, uri, link_quality_callback, link_error_callback):
#         """Connect the driver to a specified URI
# 
#         @param uri Uri of the link to open
#         @param link_quality_callback Callback to report link quality in percent
#         @param link_error_callback Callback to report errors (will result in
#                disconnection)
#         """
# 
#     def send_packet(self, pk):
#         """Send a CRTP packet"""
# 
#     def receive_packet(self, wait=0):
#         """Receive a CRTP packet.
# 
#         @param wait The time to wait for a packet in second. -1 means forever
# 
#         @return One CRTP packet or None if no packet has been received.
#         """
# 
#     def get_status(self):
#         """
#         Return a status string from the interface.
#         """
# 
#     def get_name(self):
#         """
#         Return a human readable name of the interface.
#         """
# 
#     def scan_interface(self):
#         """
#         Scan interface for available Crazyflie quadcopters and return a list
#         witha them.
#         """
# 
#     def enum(self):
#         """Enumerate, and return a list, of the available link URI on this
#         system
#         """
# 
#     def get_help(self):
#         """return the help message on how to form the URI for this driver
#         None means no help
#         """
# 
#     def close(self):
#         """Close the link"""
# 
# Path: src/crazyflieROS/cflib/crtp/exceptions.py
# class WrongUriType (Exception):
#     """ Wrong type of URI for this interface """
#     pass


# Path: src/crazyflieROS/cflib/crtp/serialdriver.py
from .crtpdriver import CRTPDriver
from .exceptions import WrongUriType
import re

#
#  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., 51 Franklin Street, Fifth Floor, Boston,
#  MA  02110-1301, USA.

"""
An early serial link driver. This could still be used (after some fixing) to
run high-speed CRTP with the Crazyflie. The UART can be run at 2Mbit.
"""

__author__ = 'Bitcraze AB'
__all__ = ['SerialDriver']





class SerialDriver (CRTPDriver):
    def __init__(self):
        None

    def connect(self, uri, linkQualityCallback, linkErrorCallback):
        #check if the URI is a serial URI
        if not re.search("^serial://", uri):

            raise WrongUriType("Not a serial URI")