This project has moved and is read-only. For the latest updates, please go here.

Problems with SystemCommand.CopyFileAsync over USB - any Idea?

Dec 17, 2014 at 5:08 PM
Edited Dec 17, 2014 at 5:08 PM
For many days I've been trying to donwload files from a computer to the ev3 brick over an USB-Connection with SystemCommand.CopyFileAsync. In general the USB-connection works fine, I can send commands and read from sensors.

If I try to copy files to the brick there are always a lot of bytes lost - e.g. the file has 7k on the computer and if I copy the file to the brick (to the SD-Card) and check the size it only has about 6k. Not a great problem when I copy sound-files (you hear some noise in the file) but this is a great problem, when I copy executable files and there are bytes missing.

After comparing the original file and the file after it has been copied to the brick with a Hex-Editor, the first bytes ok and the last bytes are ok. So some bytes get lost, when copying the file to the brick.

Any idea?

Thanks for your answers!
Dec 17, 2014 at 5:27 PM
Hello, Which version of the library are you using? Desktop or WinRT?
Dec 17, 2014 at 10:29 PM
Edited Dec 17, 2014 at 10:29 PM
Thanks for yor quick response!

I’m using the desktop library, my intension is to build a windows desktop C# applikation. Actually I’m working on a computer with Windows 8.1.

In addition to my post: when I copy files with Brixcc or the EV3_Ide over USB to the EV3 everything works fine.

Dec 17, 2014 at 10:45 PM
There are issues with the desktop USB implementation that would do exactly what you're describing. There was a fix listed in one of the discussions here which I haven't had time to implement, but the basic idea was to add a .Flush() everywhere a Write occurs in the UsbCommunication object. Give that a try?
Dec 19, 2014 at 11:23 AM
Thank you for this proposal! Now for me it woks!

If anybody need the solution, I've changed the following in the UsbCommunications.cs und rebuild the dll:
public async Task WriteAsync(byte[] data)
            if(_stream != null)
                data.CopyTo(_outputReport, 1);
                await _stream.WriteAsync(_outputReport, 0, _outputReport.Length);

            // invalid stream, bail out, but don't tank who is awaiting us
            //return Task.FromResult(false);