+--- Sends a USBpacket to the device
+-- @param command - the usb packet to send
+-- @param ignoreresponse - if set to true, we don't read the device answer packet
+-- which is usually recipe for fail. If not sent, the host will wait 2s for a
+-- response of type CMD_ACK
+-- @return packet,nil if successfull
+-- nil, errormessage if unsuccessfull
+
+local function sendToDevice(command, ignoreresponse)
+ core.clearCommandBuffer()
+ local err = core.SendCommand(command:getBytes())
+ if err then
+ print(err)
+ return nil, err
+ end
+ if ignoreresponse then return nil,nil end
+
+ local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
+ return response,nil
+end
+
+