MTP

MTP is a Media Transfer Protocol and Picture Transfer Protocol host application for RISC OS. Currently it is work in progress and only beta quality.

Copyright © 2013 Dave Higton

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

You may contact the author:

by e-mail as dave@davehigton.me.uk, or

by snail-mail at 76 Glenfield Crescent, Southampton, Hants, SO18 4RF, United Kingdom.

Purpose

This application is intended to be a host for Media Transfer Protocol and Picture Transfer Protocol devices, usually cameras, mobile phones and media players. It is currently very incomplete.

I intend to extend the application to make it more reliable and to add more facilities. All versions will be freely available.

Features

In its current state, this app allows you to:

• look at the files and directories present on an MTP/PTP device

• look at some of the details of the files

• transfer files one at a time from device to host or from host to device

• examine and set some device properties

• take a single photo, if the device supports it.

Limitations

• It will NOT work with the Simtec stack.

• There remains a great deal of work to be done on Device Properties; see below.

• I repeat, this is beta code. There will no doubt be bugs. You'll have to help me find them. That having been said, there has not yet been a reported case of data loss; not entirely surprising, because MTP and PTP deal with the device at file level, which means that the filing system is on the device, not in my MTP application. Any bugs in the device's filing system are written by the device's manufacturer, not by me!

• Although numeric device properties may appear to be settable and resettable, these actions do nothing at the moment. They're on my to do list, of course.

RISC OS version

There have been substantial improvements in the performance and reliability of RISC OS USB since RISC OS version 5.16 (and further improvements are ongoing). I recommend using RISC OS version 5.20 (though beware of incompatibility of Aemulor on Iyonix if you do). Use at least version 5.18. Versions 5.16 and earlier are known to be problematic.

Installation

This application works on an Iyonix, BeagleBoard xM, BeagleBoard or Raspberry Pi.

Copy the !MTP application into any convenient location.

Running

Plug an MTP or PTP device into the computer. If the !MTP application has been "seen" by the Filer, a window will open; if not, double click the !MTP application. The window will soon be populated with file (and likely directory) icons. Double-clicking a file icon will open a window with more details about the file's contents and an icon that can be dragged to a RISC OS directory in order to save the file to RISC OS. Clicking the "Delete" icon will, via a confirmation dialogue, delete the object from the device.

It is also possible to drag a single item from the viewer to a RISC OS directory. This is quicker than double-clicking and then dragging, but does not allow renaming the file on the way - if you want to rename the file, you will have to do it after it has been transferred.

The "Refresh" menu item has a submenu, with one item for each of the device's storage IDs. It is common for there to be two: one for built-in storage, and one for removable storage. Clicking either will refresh the main window with the contents of the chosen storage. If there are two (or more) submenu items, and you click one that is not currently ticked, the main window will re-open at the root directory of the newly selected storage.

Double-clicking a directory descends into that directory. All directories except the root have a ".." entry; double-clicking it ascends to the level above.

Dragging a file into the directory window writes the file to the currently displayed directory, if the device allows it. Note that quite a few devices do not allow it. I don't really know why; if you are able to write the same type of file to the same directory using another application, I'd like to work with you to try to find out why, and possibly do something about it.

The application does some very simple file name translation when writing a file to a device. It neither adds nor deletes file extensions, but, if you wish the file on the device to have an extension, you must supply one yourself, using the slash character ("/") as the separator. For example, "fred/txt" will end up on the device as "fred.txt".

The "Device properties" menu item leads to a window listing all the properties the device offers. See the "Device properties" section for more information.

Adjust-clicking the icon bar icon opens a small window with one optional action:

• "Capture" makes a camera take a still picture. The directory should be updated with details of the new object. Not even all camera devices support this feature. In general, if the lens remains closed when the camera is connected via USB, it won't work.

Choices

Clicking the "Choices" menu option opens the MTP Choices window, which allows you to control the following choices:

• "Auto start" controls whether the application auto starts whenever an MTP or PTP device is plugged in. By default it does.

• "Auto populate dir" controls whether the directory viewer is populated automatically whenever the application is run. By default, it is.

• "Logging enabled" controls whether a log file is generated. See the "Logging" section. By default, logging is disabled.

• "Log file name" sets the name of the log file. See the "Logging" section. You can type or edit a file name there, or drag a file into the writable icon and edit it.

• "Save choices" saves the choices to a file in a standard writable location in the Choices: area.

Logging

Logging is disabled by default. The "Choices" window allows you to enable logging, and to log to a different location. Logging to a hard disc or flash drive will be very slow. Logging to RamDisc (this is the default location) or Memphis is much the best way to do it, but remember the obvious: if you're going to log to RamDisc, you must have a RamDisc configured! The same applies for Memphis.

If you log to Memphis, you will have to change the "Log file name" to something like:

Mem::Memphis.$.Log

If you report a problem to me, I will almost certainly ask you to send me a log file. To find out how to enable logging, read the "Choices" section. When you've logged a session that demonstrates the problem, quit !MTP, zip up the log file (use SparkFS or similar - the log should compress to a small fraction of its original size), and email me the zipped version.

Non-standard devices

There are some devices around that claim to support a proprietary protocol instead of MTP/PTP, but in fact support MTP. The first two examples known to me are the Google Nexus 7 and the Sony Experia S. I have been able to add support for them because their owners contacted me, explained that they obey MTP or PTP on another platform, and were prepared to do some simple tests for me and send me the results. If you know of another device and are prepared to work with me, I can probably add support for it. Just contact me!

Device properties

Only some data types are currently supported. If the property is read only, the "Set" and "Reset" icons are greyed out; if the property is also settable, they are active. You can alter the "Current" value and click "Set" to change it, or click "Reset" to return it to the manufacturer's default setting.

Device properties make a big subject. There are lots of data types, and three forms (none, range, enumeration). There is a very long list of standard properties, and manufacturers are free to define their own proprietary properties. Some properties, despite using a generic data type, ascribe special values to them (if you're interested, look up Perceived Device Type as an example). You may very well find that your device possesses a Device Property that is not well handled. If you let me know, I can add special handling for properties in the MTP standard, or for vendor specific properties if you or I can find information about them; but you will have to test the resulting code, tell me the results, and send me the logs.

Feedback and bug reporting

I am always glad to hear from anyone who uses an application I've written, whether the news is good or bad. If the news is bad, I like to fix the problem if I can.

This is a public release, so my preferred way to hear from you is in the comp.sys.acorn.apps newsgroup. Otherwise you can email me as dave@davehigton.me.uk.

When you report a bug, please include the make and model of the device you used it with, and you must include a full description of the symptoms. I will probably ask you for a log file. The log file can be very helpful to me, and, fortunately, it doesn't contain any private information, so you don't need to be worried about sending it to me.

Acknowledgements

I am grateful to:

• Colin Granville and Thomas Milius for their help in getting non-blocking, non-padding USB bulk input working;

• Chris Gransden for help in adding support for the Google Nexus 7;

• Chris Dale for help in adding support for the Sony Experia S and unknown filetypes.

I am always grateful for any feedback from anybody.

Download

You can download MTP here.

Revision history

0.06 2012 November 21 Rewritten

0.07 2012 November 29 Added the Delete function

0.08 2012 November 30 Added the Refresh function

0.09 2012 December 29 Some extra options in the !Run file

0.10 2013 May 25 Non-blocking Castle functions; now works with Samsung Galaxy S3 (at least sometimes!)

0.11 2013 June 1 Renamed MTP (previously PTP). Supports hierarchy (crudely). Works with 3 different devices.

0.12 2013 June 6 One of the USB read operations requests a number of bytes rounded up to a multiple of the maxpacket size; this seems to improve reliability.

0.13 2013 June 13 Added recognition for the Nexus 7 (bizarrely, it supports MTP but claims to be a vendor specific protocol).

0.14 2013 June 22 Selects the correct directory item when double-clicking. Some device property handling added.

0.15 2013 June 23 Hourglass added to file write operation. IDs of proprietary device properties corrected. Improved handling of USB IO Error.

0.16 2013 June 24 Logging disabled by default. Better handling of attempting to log to RamDisc when no RamDisc is configured.

0.17 2013 June 26 Source data file closed properly afer writing to device.

0.18 2013 July 27 Auto-starts on plugging device in and auto-quits on unplugging device. Supports Sony Experia S. Abstract Audio Album filetype added. Can now load files of unknown types.

0.19 2013 August 17 Choices moved from the !Run file to a window within the application.

0.20 2013 August 19 "Invalid storage ID" should happen much less often now.

0.21 2013 September 14 Can now drag single items directly from the directory viewer.

Page last updated 2013 September 14