Nistune USB communication

Discuss possible software enhancements/changes here.

Moderator: Matt

Post Reply
DRG
 

Posts: 7
Joined: Fri May 02, 2014 9:19 am
Location: Finland

Nistune USB communication

Post by DRG »

I'm currently running S13 CA18det with Nistune Type 1 board and I would be interested in developing an Android app for viewing live data from Nistune (sensor data, gauges etc). As I do not have Consult port on my vehicle I would need to somehow communicate with Nistune board via USB. What kind of protocol does the Nistune use for communication? My Android tablet can act as USB host with help of USB OTG cable thus enabling the communication if I'm correct?

Could I use for example this app for testing the communication between Nistune and tablet:
https://play.google.com/store/apps/deta ... 03terminal
http://www.prolific.com.tw/US/ShowProdu ... 30&pcid=41
or does the Nistune use some other kind of way to communicate with USB host? The Android app for showing the data I'll try to
implement on my own.

Please comment if this is a feasible idea at all. Any other comments are welcome as well.

The other idea that I have is to use my Arduino board to communicate with Nistune and gather data, and then send this to tablet/smartphone via bluetooth. This way I could easily add for example boost/oil pressure sensor signal input to Arduino board and sent that information to tablet as well.
Matt
Site Admin
 

Posts: 8961
Joined: Sun Jan 29, 2006 1:45 am
Location: Adelaide, Australia
Contact:

Re: Nistune USB communication

Post by Matt »

Type 1 boards use a custom protocol using an FTDI FT245RL DLL so it would be available for windows only

If you figured out how to communicate with the FTDI245 over the USB as a host controller then I can provide you the protocol. For example sending bytes CA 06 00 00 00 will return the ECU version ID

More info is covered at the end of the diagnostics document for Type 1 using the DLP Design test application on these commands (under Type 1 hardware installation)
DRG
 

Posts: 7
Joined: Fri May 02, 2014 9:19 am
Location: Finland

Re: Nistune USB communication

Post by DRG »

There is a FTDI D2XX Java driver for Android available: http://www.ftdichip.com/Drivers/D2XX.htm which are described in this technical note: http://www.ftdichip.com/Support/Documen ... ndroid.pdf
There's also some examples and demo app for these drivers available: http://www.ftdichip.com/Support/Softwar ... ojects.htm

Do you think these drivers would be suitable for communicating with the FTDI245? I've just looked into these but can't tell if they could be used or not.

I'm mostly worried that I'll ruin my Nistune board when testing out the connection. Is there really a such concern or can I just try to read the ECU version ID with the bytes you told?
Matt
Site Admin
 

Posts: 8961
Joined: Sun Jan 29, 2006 1:45 am
Location: Adelaide, Australia
Contact:

Re: Nistune USB communication

Post by Matt »

Hey this is looking pretty good... we would have to use the option 2 (non-root) as most users dont root their phones

What you need to call:
getDeviceInfoListDetail() and isFtDevice()

Look for device in BufPtr[] which has "Nistune" and then open that device with OpenByIndex/OpenByDescription()

Set up your ID buffer CA,06,00,00,00
write(buffer,5)

Read back the buffer
read(readbuffer,5) which has the response

Connecting the Type 1 to the phone, would need to google that. I assume you can get a micro USB connector to hub and then connect the Type 1 board to the hub if the phone is running as host
DRG
 

Posts: 7
Joined: Fri May 02, 2014 9:19 am
Location: Finland

Re: Nistune USB communication

Post by DRG »

I would assume you could just use normal USB OTG cable (http://en.wikipedia.org/wiki/USB_On-The-Go) to connect the Type 1 directly to phone/tablet.
http://christophercolston.files.wordpre ... sb_otg.jpg

I'll try to implement some kind of demo app using the function calls you instructed and see if I can read the ECU version ID from the board.
Matt
Site Admin
 

Posts: 8961
Joined: Sun Jan 29, 2006 1:45 am
Location: Adelaide, Australia
Contact:

Re: Nistune USB communication

Post by Matt »

Looks possible. Limited phones however:
Some high end Android phones produced by Samsung[8] & Sony under Xperia series[9] also have it. Android version 3.1 or newer support USB On-The-Go, but not all devices
skylinegtrhr
 

Posts: 301
Joined: Sat Jun 21, 2008 1:50 am
Location: Croatia
Contact:

Re: Nistune USB communication

Post by skylinegtrhr »

Matt wrote:Looks possible. Limited phones however:
Some high end Android phones produced by Samsung[8] & Sony under Xperia series[9] also have it. Android version 3.1 or newer support USB On-The-Go, but not all devices
Today even China made RK chipset phones have OTG, I have it on almost 4 years old Motorola tablet :) and rooting is pretty much standard procedure for advanced users
DRG
 

Posts: 7
Joined: Fri May 02, 2014 9:19 am
Location: Finland

Re: Nistune USB communication

Post by DRG »

Yes, that is true. I would myself go with the Android 4.0+ device. I think these would most likely support OTG. There's also an app for checking the USB OTG capabilities on Google Play: https://play.google.com/store/apps/deta ... otgchecker

I have cheap chinese made Ainol Fire 7" tablet which also has OTG so I wouldn't be too worried about the compatibility.
DRG
 

Posts: 7
Joined: Fri May 02, 2014 9:19 am
Location: Finland

Re: Nistune USB communication

Post by DRG »

It seems I have trouble discovering the Nistune board with my application. For some reason the Nistune does not get recognized as a FTDI device or something. After Android notices (successfully) that USB device is attached I try to establish connection:

Code: Select all

devCount = ftD2xx.createDeviceInfoList(getApplicationContext());

if (devCount > 0) {
	D2xxManager.FtDeviceInfoListNode[] deviceList = new D2xxManager.FtDeviceInfoListNode[devCount];
	ftD2xx.getDeviceInfoList(devCount, deviceList);
        //Write device information to screen
        ...
        //Open device etc...
}
I get devCount = 0 with nistune attached. I also tested this with another FTDI chip based device (Arduino Nano) and it gets recognized and prints device info to screen.

Any help what could cause this behavior with Nistune?
Matt
Site Admin
 

Posts: 8961
Joined: Sun Jan 29, 2006 1:45 am
Location: Adelaide, Australia
Contact:

Re: Nistune USB communication

Post by Matt »

Have you tried the DLPTest application with the Nistune Type 1 board on a windows PC to check that works okay?

Link is here:
http://www.dlpdesign.com/usb/usb245.shtml

We also change the Product ID from the default FTDI PID to a Nistune PID and modify the FTDI driver INF files to match:

USB\VID_0403&PID_C7D8.DeviceDesc="Nistune Type 1 board"
(originally)
USB\VID_0403&PID_6001.DeviceDesc="USB Serial Converter"

What you might need to do is reprogram the EEPROM on the Type 1 board back to FTDI default for now so the Android drivers recognise it as a normal FTDI (rather than Nistune specific) Product ID (PID)

Found something:
http://www.ftdichip.com/Support/Documen ... Driver.pdf
4 Limitations and Restrictions
4.1 Non-Default VID and PID Combinations
At the time of writing, the Android D2XX driver will support all default FTDI VID and PID combinations and can also support a single custom VID and PID combination via the setVIDPID Java method (FT_SetVIDPID function).

However, it is currently not possible to match several non-default VID and PID combinations simultaneously. This is due to the Android OS hanging on a call to dlopen which precludes the use of an external libtable library at this time.
You can change to use the Nistune Type 1 PID C7D8 or you can reset your board for now to FTDI defaults using MProg/FTProg
http://www.ftdichip.com/Support/Utilities.htm

If you need to put MProg settings back to Type 1 email me and I can send you the EEPROM program file for the FTDI chip
DRG
 

Posts: 7
Joined: Fri May 02, 2014 9:19 am
Location: Finland

Re: Nistune USB communication

Post by DRG »

Matt wrote: We also change the Product ID from the default FTDI PID to a Nistune PID and modify the FTDI driver INF files to match:

USB\VID_0403&PID_C7D8.DeviceDesc="Nistune Type 1 board"
(originally)
USB\VID_0403&PID_6001.DeviceDesc="USB Serial Converter"
Thanks Matt!

That changed PID was exactly the problem. I got the device open by setting first the VID & PID with setVIDPID function. So thankfully no need to reprogram the EEPROM at this point.

I also haven't tested the DLPTest application as I have the Nistune software set up on my development laptop...I've used it to test if the board still works :)

Next I need to implement a way to send and receive data to/from board. Might also need to implement some kind of UI for that.
DRG
 

Posts: 7
Joined: Fri May 02, 2014 9:19 am
Location: Finland

Re: Nistune USB communication

Post by DRG »

Finally got something out of my Nistune board but I'm not quite sure how to interpret the data. My app now opens the device, sets send buffer CA,06,00,00,00, writes buffer and then reads what ever comes back from the device and prints the data in hex values and also in UTF-8 string format.
20140514_230715-1_.jpg
(26.44 KiB) Downloaded 5713 times
Any help on how to proceed from here on would be appreciated.
Matt
Site Admin
 

Posts: 8961
Joined: Sun Jan 29, 2006 1:45 am
Location: Adelaide, Australia
Contact:

Re: Nistune USB communication

Post by Matt »

Shoot me an email and I'll send you the rest of the protocol information
Post Reply