# hidraw.h
class _hidraw_report_descriptor(ctypes.Structure):
    _fields_ = [
        ('size', ctypes.c_uint),
        ('value', ctypes.c_ubyte * _HID_MAX_DESCRIPTOR_SIZE),
    ]

class _hidraw_devinfo(ctypes.Structure):
    _fields_ = [
        ('bustype', ctypes.c_uint),
        ('vendor', ctypes.c_short),
        ('product', ctypes.c_short),
    ]

_HIDIOCGRDESCSIZE = ioctl_opt.IOR(ord('H'), 0x01, ctypes.c_int)
_HIDIOCGRDESC = ioctl_opt.IOR(ord('H'), 0x02, _hidraw_report_descriptor)
_HIDIOCGRAWINFO = ioctl_opt.IOR(ord('H'), 0x03, _hidraw_devinfo)
_HIDIOCGRAWNAME = lambda len: ioctl_opt.IOC(ioctl_opt.IOC_READ, ord('H'),
    0x04, len)
_HIDIOCGRAWPHYS = lambda len: ioctl_opt.IOC(ioctl_opt.IOC_READ, ord('H'),
    0x05, len)
_HIDIOCSFEATURE = lambda len: ioctl_opt.IOC(
    ioctl_opt.IOC_WRITE|ioctl_opt.IOC_READ, ord('H'), 0x06, len)
_HIDIOCGFEATURE = lambda len: ioctl_opt.IOC(
    ioctl_opt.IOC_WRITE|ioctl_opt.IOC_READ, ord('H'), 0x07, len)

HIDRAW_FIRST_MINOR = 0
HIDRAW_MAX_DEVICES = 64
HIDRAW_BUFFER_SIZE = 64
Beispiel #2
0
# The same as in gadgetfs

# IN transfers may be reported to the gadget driver as complete
#    when the fifo is loaded, before the host reads the data;
# OUT transfers may be reported to the host's "client" driver as
#    complete when they're sitting in the FIFO unread.
# THIS returns how many bytes are "unclaimed" in the endpoint fifo
# (needed for precise fault handling, when the hardware allows it)
FIFO_STATUS = ioctl_opt.IO(ord('g'), 1)

# discards any unclaimed data in the fifo.
FIFO_FLUSH = ioctl_opt.IO(ord('g'), 2)

# resets endpoint halt+toggle; used to implement set_interface.
# some hardware (like pxa2xx) can't support this.
CLEAR_HALT = ioctl_opt.IO(ord('g'), 3)

# Specific for functionfs

# Returns reverse mapping of an interface.  Called on EP0.  If there
# is no such interface returns -EDOM.  If function is not active
# returns -ENODEV.
INTERFACE_REVMAP = ioctl_opt.IO(ord('g'), 128)

# Returns real bEndpointAddress of an endpoint.  If function is not
# active returns -ENODEV.
ENDPOINT_REVMAP = ioctl_opt.IO(ord('g'), 129)

# Returns endpoint descriptor. If function is not active returns -ENODEV.
ENDPOINT_DESC = ioctl_opt.IOR(ord('g'), 130, USBEndpointDescriptor)
Beispiel #3
0
 def get_ioctl_request(cls):
     return ioctl_opt.IOR(
         RFM12B_SPI_MAJOR, 0, ctypes.POINTER(cls))
Beispiel #4
0
BUS_BLUETOOTH = 0x05
BUS_VIRTUAL = 0x06

class _hidraw_report_descriptor(ctypes.Structure):
    _fields_ = [
        ('size', ctypes.c_uint),
        ('value', ctypes.c_ubyte * 4096),
    ]

class _hidraw_devinfo(ctypes.Structure):
    _fields_ = [
        ('bustype', ctypes.c_uint),
        ('vendor', ctypes.c_short),
        ('product', ctypes.c_short),
    ]
HIDIOCGRAWINFO = ioctl_opt.IOR(ord('H'), 0x03, _hidraw_devinfo)
HIDIOCSFEATURE = lambda len: ioctl_opt.IOC(ioctl_opt.IOC_WRITE|ioctl_opt.IOC_READ, ord('H'), 0x06, len)
DevInfo = collections.namedtuple('DevInfo', ['bustype', 'vendor', 'product'])


def getInfo(device):
    devinfo = _hidraw_devinfo()
    result = fcntl.ioctl(device, HIDIOCGRAWINFO, devinfo, True)
    """ioctl(_HIDIOCGRAWINFO, devinfo, True)"""
    return DevInfo(devinfo.bustype, devinfo.vendor, devinfo.product)

def sendFeatureReport(device, report, report_num=0):
    """
    Send a feature report.
    """
    length = len(report) + 1
Beispiel #5
0
#    __be16		sb_logsectsize;	/* sector size for the log, bytes */
#    __be32		sb_logsunit;	/* stripe unit size for the log */
#    __be32		sb_features2;	/* additional feature bits */
#    /*
#     * bad features2 field as a result of failing to pad the sb
#     * structure to 64 bits. Some machines will be using this field
#     * for features2 bits. Easiest just to mark it bad and not use
#     * it for anything else.
#     */
#    __be32	sb_bad_features2;
#
#    /* must be padded to 64 bit alignment */
#} xfs_dsb_t;
#

BLKGETSIZE64 = ioctl_opt.IOR(0x12, 114, ctypes.c_size_t)
BLKSSZGET = ioctl_opt.IO(0x12, 104)
XFS_SDB_T_STRUCT = struct.Struct(
    ">4sIQQQ16sQQQQIIIIIHHHH12sBBBBBBBBQQQQQQHBBIIIBBHIII"
)  # Always big-endian per above struct
XFSSdbT = namedtuple("XFSSdbT", [
    "sb_magicnum", "sb_blocksize", "sb_dblocks", "sb_rblocks", "sb_rextents",
    "sb_uuid", "sb_logstart", "sb_rootino", "sb_rbmino", "sb_rsumino",
    "sb_rextsize", "sb_agblocks", "sb_agcount", "sb_rbmblocks", "sb_logblocks",
    "sb_versionnum", "sb_sectsize", "sb_inodesize", "sb_inopblock", "sb_fname",
    "sb_blocklog", "sb_sectlog", "sb_inodelog", "sb_inopblog", "sb_agblklog",
    "sb_rextslog", "sb_inprogress", "sb_imax_pct", "sb_icount", "sb_ifree",
    "sb_fdblocks", "sb_frextents", "sb_uquotino", "sb_gquotino", "sb_qflags",
    "sb_flags", "sb_shared_vn", "sb_inoalignmt", "sb_unit", "sb_width",
    "sb_dirblklog", "sb_logsectlog", "sb_logsectsize", "sb_logsunit",
    "sb_features2", "sb_bad_features2"