Home FAQs Using MSII B&G Code with Bluetooth
Using MSII B&G Code with Bluetooth PDF Print E-mail
Written by Phil Tobin   
Wednesday, 29 February 2012 15:21
MSII B&G firmware is sensitive to having bytes sent too fast. If you send bytes too fast, the firmware may be executing another task, by the time it finishes that task and checks if a byte has been sent by tuning software, the 1st byte may have already been over written by the next byte and the previous is missed.
 
If this is occurring, you will likely continuously drop connection, reconnect, drop, etc... Or worse, if loading an msq, you could end up with corrupt settings on your controller.
 
To prevent this, there is a configuration setting in the ini file called interWriteDelay.
 
The interWriteDelay throttles the speed that bytes are sent to the controller, it sets the number of milliseconds that TunerStudio will wait between each byte written before writing the next byte. With the MSII B&G Code, this typically needs to be set to 2 to 3 ms to ensure no bytes are missed.
 
The trouble with Bluetooth is that the specification does not allow for such fine grained control of the byte delivery. TunerStudio may send the data with a 3ms wait between each byte, but then it gets queued in a BT buffer down stream and flushed all at once. Thus on the on the firmware side it sees no bytes, then a bunch of bytes too fast for it to read.

So there is a work around... You need to set the interWriteDelay to a very high number, high enough to insure that each byte is flushed before the next is sent. I have found this to be any where from 10-25ms depending on the BT Adapter.

Shadow Logger manages the interWriteDelay on its own, however TunerStudio uses the values in the ini file, so you will need to edit your ini file. The ini file is found at:
[YourTunerStudioProjectFolder]\projectCfg\mainController.ini
 
To edit your ini, search for the line:
 
interWriteDelay =     5
 
In many of the recent MSII firmware ini files there is no interWriteDelay set, therefore it will be using the default value of 3. This works fine for cabled connections, however not always so with bluetooth.
 
Add this line near
pageActivationDelay =  50 ; Milliseconds delay after burn command.
blockReadTimeout    = 200 ; Milliseconds total timeout for reading page.
interWriteDelay =     20
That will set it to 20, and it should be pretty stable. You can play around with it some and see what is the lowest number you can use and stay stable. Making this number high will slow the time to load an msq quite a lot, but making it too low means a byte could get dropped and your settings could get corrupt. So you are best making it higher than it needs to be even if that does slow performance.
Also I should note, if you use MS2 Extra or MS3, this isn't an issue. MS2 Extra firmware doesn't mind when the data is sent at full speed with no wait between.
 
Last Updated on Sunday, 08 July 2012 13:33
 
 

Polls

What would you like to see in TunerStudio 3.0