# Path: pypot/dynamixel/conversion.py
# def dxl_code_all(value, length, nb_elem):
#     if nb_elem > 1:
#         return list(itertools.chain(*(dxl_code(v, length) for v in value)))
#     else:
#         return dxl_code(value, length)
# 
# def dxl_decode_all(data, nb_elem):
#     if nb_elem > 1:
#         data = list(zip(*([iter(data)] * (len(data) // nb_elem))))
#         return tuple(map(dxl_decode, data))
#     else:
#         return dxl_decode(data)
# 
# def decode_error(error_code):
#     bits = numpy.unpackbits(numpy.asarray(error_code, dtype=numpy.uint8))
#     return tuple(numpy.array(dynamixelErrors)[bits == 1])
# 
# def dxl_to_model(value, dummy=None):
#     return dynamixelModels[value]


import serial
import logging
import operator
import itertools
import threading
        import platform
        import pypot.utils.pypot_time as time
from collections import namedtuple, OrderedDict
from contextlib import contextmanager
from ..conversion import (dxl_code_all, dxl_decode_all, decode_error,
                          dxl_to_model)
                if not sp:
                    return ()

                if self._protocol.name == 'v1':
                    values = sp.parameters

                elif self._protocol.name == 'v2':
                    values = list(sp.parameters)
                    for i in range(len(ids) - 1):
                        try:
                            sp = self.__real_read(rp, _force_lock=True)
                        except (DxlTimeoutError, DxlCommunicationError):
                            return ()
                        values.extend(sp.parameters)

                    if len(values) < len(ids):
                        return ()

        else:
            values = []
            for motor_id in ids:
                rp = self._protocol.DxlReadDataPacket(motor_id, control.address, control.length * control.nb_elem)
                sp = self._send_packet(rp, error_handler=error_handler)

                if not sp:
                    return ()

                values.extend(sp.parameters)

        values = list(zip(*([iter(values)] * control.length * control.nb_elem)))

# Path: pypot/dynamixel/conversion.py
# def dxl_code_all(value, length, nb_elem):
#     if nb_elem > 1:
#         return list(itertools.chain(*(dxl_code(v, length) for v in value)))
#     else:
#         return dxl_code(value, length)
# 
# def dxl_decode_all(data, nb_elem):
#     if nb_elem > 1:
#         data = list(zip(*([iter(data)] * (len(data) // nb_elem))))
#         return tuple(map(dxl_decode, data))
#     else:
#         return dxl_decode(data)
# 
# def decode_error(error_code):
#     bits = numpy.unpackbits(numpy.asarray(error_code, dtype=numpy.uint8))
#     return tuple(numpy.array(dynamixelErrors)[bits == 1])
# 
# def dxl_to_model(value, dummy=None):
#     return dynamixelModels[value]


# Path: pypot/dynamixel/io/abstract_io.py
import serial
import logging
import operator
import itertools
import threading
        import platform
        import pypot.utils.pypot_time as time
from collections import namedtuple, OrderedDict
from contextlib import contextmanager
from ..conversion import (dxl_code_all, dxl_decode_all, decode_error,
                          dxl_to_model)

                if not sp:
                    return ()

                if self._protocol.name == 'v1':
                    values = sp.parameters

                elif self._protocol.name == 'v2':
                    values = list(sp.parameters)
                    for i in range(len(ids) - 1):
                        try:
                            sp = self.__real_read(rp, _force_lock=True)
                        except (DxlTimeoutError, DxlCommunicationError):
                            return ()
                        values.extend(sp.parameters)

                    if len(values) < len(ids):
                        return ()

        else:
            values = []
            for motor_id in ids:
                rp = self._protocol.DxlReadDataPacket(motor_id, control.address, control.length * control.nb_elem)
                sp = self._send_packet(rp, error_handler=error_handler)

                if not sp:
                    return ()

                values.extend(sp.parameters)

        values = list(zip(*([iter(values)] * control.length * control.nb_elem)))

        values = [dxl_decode_all(value, control.nb_elem) for value in values]