#NEWLINE# def send( self , raw_data = None ) : #NEWLINE# #INDENT# 'Prepare HID raw report (unless raw_data is provided) and send\n        it to HID device\n        ' #NEWLINE# if ( ( self . __report_kind != HidP_Output ) and ( self . __report_kind != HidP_Feature ) ) : #NEWLINE# #INDENT# raise HIDError ( 'Only for output or feature reports' ) #NEWLINE# #UNINDENT# if ( raw_data and ( len ( raw_data ) != self . __raw_report_size ) ) : #NEWLINE# #INDENT# raise HIDError ( ( 'Report size has to be %d elements (bytes)' % self . __raw_report_size ) ) #NEWLINE# #UNINDENT# if ( raw_data and ( raw_data [ 0 ] != self . __report_id . value ) ) : #NEWLINE# #INDENT# raise HIDError ( 'Not matching report id' ) #NEWLINE# #UNINDENT# if ( ( self . __report_kind != HidP_Output ) and ( self . __report_kind != HidP_Feature ) ) : #NEWLINE# #INDENT# raise HIDError ( 'Can only send output or feature reports' ) #NEWLINE# #UNINDENT# if ( not raw_data ) : #NEWLINE# #INDENT# self . __prepare_raw_data ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not ( isinstance ( raw_data , ctypes . Array ) and issubclass ( raw_data . _type_ , c_ubyte ) ) ) : #NEWLINE# #INDENT# self . __alloc_raw_data ( raw_data ) #NEWLINE# #UNINDENT# #UNINDENT# raw_data = self . __raw_data #NEWLINE# if ( self . __report_kind == HidP_Output ) : #NEWLINE# #INDENT# return self . __hid_object . send_output_report ( raw_data ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . __report_kind == HidP_Feature ) : #NEWLINE# #INDENT# return self . __hid_object . send_feature_report ( raw_data ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# pass