Saturday, 31 January 2015

USB OTG host mode API issues with some Android devices

It has been reported recently that some devices doesn't support USB API correctly, despite having Android version > 3.1 (the first release with USB OTG host mode API available to application layer).

Basically, the non-functioning devices can be divided into two groups:

a) Hardware USB host mode not implemented.

A good example is LG Swift G (or related) mobile handheld, a rumour says that +5V DC supply voltage is not available, a result of hardware cost-cutting. Obviously there's nothing that could be done to enable USB host mode on those devices

b) Hardware USB compatible with host mode, Android version >=3.1, pendrive or mouse works fine, yet no USB devices are visible form the application layer.

This mostly is true when it comes to no-name devices (tablets), it looks as if manufacturers were in a big rush to release a product and forgot to properly configure Android OS.

Some devices can be fixed, a solution is to modify/copy a file in the /system/etc/permissions.

One must have root access to able to remount and modify those files.

See the thread:

http://stackoverflow.com/questions/11183792/android-usb-host-and-hidden-devices

Quotation from the above link:

"To enable USB host API support you should add a file named
android.hardware.usb.host.xml
and containing the following lines:

<permissions> <feature name="android.hardware.usb.host"/> </permissions>

into folder

/system/etc/permissions

in that folder find file named

handheld_core_hardware.xml or tablet_core_hardware.xml

and add

<feature name="android.hardware.usb.host" />

into <permissions> section.

Reboot your device. Usb host api should work."


Some tablets have root by default, it's only necessary to switch into superuser, this can be done with Total Commander

http://www.androidpolice.com/2011/07/25/tip-how-to-enable-writing-to-read-only-partitions-remount-rw-in-total-commander-for-android/

Or by using "adb" command-line utility:

http://forum.xda-developers.com/showthread.php?p=48915118#post48915118


adb shell 
 su
 mount -o rw,remount -t ext4 /system



Be careful with system files/directories it's very easy to brick your device. First make sure you are able to restore the original OS rom image (in case of...) before trying the above hack.





Saturday, 3 January 2015

Rover MEMS 1.6 1.9 ECU Diagnostics tool

 

What is MEMS_Diag

MEMS_Diag is an android application designed to communicate with pre-OBD Rover engine management systems (ECU). Modular Engine Management System (MEMS 1.6 / 1.9) was used on many cars in the 1990s built by the Rover group (models equipped with different variants of K16 petrol engine)


Which MEMS versions are supported 

Currently only MEMS 1.6 and 1.9 are supported, later versions are OBD2 compliant so they're not in the scope of this project


Implemented features

- MEMS 1.6/1.9
- RealTime engine parameters (rpm, map, ignition advance, coolant temp, inlet temp, oxygen sensor, fuel trim/correction and more...)
- Retrieve and erase error codes
- Scrollable view (numerical/table display)
- Graph view (selectable parameters, multiple series)
- Data logging, csv format (full version only)

What is required

In order to use this application, the following componets are required:

- Android-enabled device (smartphone), minimum version 3.1+ (USB host access)
- USB port
- the so-called "USB OTG" cable

in addition to the above, depending on the MEMS version, you also need:

for MEMS 1.9:




- FTDI-based (FT232) 12V K-Line cable, commonly known as VAG-cable/VAG-KKL. These cables are widely available on ebay etc. Make sure it's build using the FTDI USB chip, perhaps PL2303 should also work but I haven't been able to test it. Avoid products based on CH340 chipset (reason being, there's one missing but crucial function not yet implemented in the driver)

For MEMS 1.6:





- Any USB-to-TTL converter, again, the most popular are FTDI and PL2303. Remember that MEMS 1.6 uses 5V logic (depending on the quality of the converter circuit a 3.3 V may also work)


ECU data link socket(s)



MEMS 1.9 uses a standard OBD2 16-pin connection (despite having nothing in common with OBD2 communication protocol). Usually it's located somewhere in the passenger compartment.



IMPORTANT UPDATE - Missing J1962 pin "5" (MEMS 1.9):

If the tool is unable to establish connection the the ECU, or it works intermittently, the connection is dropped as soon as the engine is started...then most likely explanation is the (in)famous missing pin issue.
 
Apparently, with some rover vehicles (400 1.6Si for example) there is a pin missing from the OBD SAE J1962 socket. The missing pin is No. 5 - "signal ground" and the only available "ground" signal is pin 4, see the picture below:



  (counting from right to left, 5th pin is missing)

Now, it depends on your FTDI USB cable, some of them have both pins 4&5 internally connected anyway - these are fine (usually the newer ones), while other designs require ground signal to be present on pin 5 - in this case it might be necessary to modify the cable connector by soldering both 4&5 pins together.





MEMS 1.6 on the other hand, uses a custom 3-pin connector located in the engine bay, just next to the ECU.

Pins/Signals (as seen at the MEMS side):

Pink/Black - GND (connect to USB/TTL GND)
White/Yellow - TXD (connect to USB/TTL RXD)
Black/Green - RXD (connect to USB/TTL TXD)

The diagnostic socket attached to your car ecu (engine bay) looks like the one below (male terminals):

If you don't want to connect pins directly (tricky but possible) a corresponding diagnostic plug is needed (female terminals). They are still sometimes available on ebay:
(ebay link)



(PL2303 USB/TTL + 3 pin socket TE Connectivity / AMP 172201-1)

 

 

ECU models/part numbers


So far the following ECU/Cars have been verified to work correctly:

MKC 103610 (MEMS 1.6)
MKC 101610 (MEMS 1.6)
MKC 104393 (MEMS 1.9, LandRover Freelander 1.8 Petrol 99')
MKC 104031 (MEMS 1.9, Rover 400 1.6Si - "missing pin 5")
MKC 101600 (MEMS 1.6, Rover 620Ti)
MKC 104072 (MEMS 1.9, Rover 620Ti - facelift)

Rover 800 coupe 2.0 turbo, MEMS 1.6
Lotus Elise '98, MEMS 1.9


"Lite" or Paid version ?

 

A lot of time has been invested to analyse and implement MEMS communication protocol, so it would be nice of you if you decide to download the paid version.

However, due to the fact there are many components (Android, USB, cabling etc) that could create some issues, preventing the application from working correctly, a free "lite" version is also available. Before going for the paid version please try the "MEMSDiag_lite" and see if it works for you.

Free/Trial version:
 https://play.google.com/store/apps/details?id=com.rovermemslite&hl=en 

Full version:
 https://play.google.com/store/apps/details?id=com.rovermemsfull&hl=en 

(last edited: 2015-02-11, memsdiag (at) gmail.com)