Personal tools
User menu

Difference between revisions of "Porsche 928 LH Replacement Prototype"

From Francois Louw

Jump to: navigation, search
(New USB (LibUSB-win32) 22 April 2013)
Line 363: Line 363:
 
==New USB (LibUSB-win32) 22 April 2013==
 
==New USB (LibUSB-win32) 22 April 2013==
  
Ok, so far I have used serial emulation to communicate between the PC and the ECU. Not a very elegant solution, but its quick and easy to implement. Downsides was that the user needed to select the correct serial port before being able to connect. After connecting initially there was no problem and the user could forget about reconnecting. Well now there is the proper solution. The device now uses the LibUSB generic USB interface.
+
Ok, so far I have used serial emulation to communicate between the PC and the ECU. Not a very elegant solution, but its quick and easy to implement. Downsides were that the user needed to select the correct serial port before being able to connect. After connecting initially there was no problem and the user could forget about reconnecting. Well now I implemented a proper solution. The device now uses the LibUSB generic USB interface.
  
I had to rewrite the code on the ECU to use the new Microchip USB stack and I used the libUSB-win32 port. Most of the time the port is implemented using static libraries, and compiled into the Windows Interface software but I prefer to use dynamic linking. By using dynamic linking I don't have to worry about any problems integrating it into Qt.
+
I had to rewrite the code on the ECU to use the new Microchip USB stack and I used the libUSB-win32 port. Most of the time the USB port communication in Windows is implemented using static libraries, and compiled into the Interface Software but I prefer to use dynamic linking. By using dynamic linking I don't have to worry about any problems integrating it into Qt.
  
 
New USB drivers are required when the new firmware is executed, as Windows detects a new device. After the new drivers are installed your Device Manager should have an entry like this:
 
New USB drivers are required when the new firmware is executed, as Windows detects a new device. After the new drivers are installed your Device Manager should have an entry like this:
Line 371: Line 371:
 
[[File:ECUNewDeviceManager.jpg]]
 
[[File:ECUNewDeviceManager.jpg]]
  
With the new USB interface I don't have to rely on the slightly unstable Qt serial library. The coding required a complete rewrite of the Qt Interface software because the LibUSB implementation that I use is synchronous communication, requiring the Interface software to send a "Request for Data" instruction before reading the data. The Firmware required little change, seeing that on both instances I just empty the buffers that I use. On the firmware side I have 2KB buffer for receiving and another 2KB buffer for sending. That should be more than enough for any delays in data that can occur on the USB line. The windows interface uses 4KB buffers because the way that Qt works there is more delays in the Interface software than in the Firmware.
+
With the new USB interface I don't have to rely on the slightly unstable Qt serial library. The coding required a complete rewrite of the Qt Interface communication protocol because the LibUSB implementation that I use is synchronous communication (vs. asynchronous with the serial emulation), requiring the Interface software to send a "Request for Data" instruction before reading the data. The Firmware required little change, seeing that on both instances I just empty the buffers that I use. On the firmware side I have 2KB buffer for receiving and another 2KB buffer for sending. That should be more than enough for any delays in data that can occur on the USB line. The windows interface uses 4KB send 4KB receive buffers because the way that Qt works there is more delays in the Interface software than in the Firmware.
  
Difference in operation now is that in the Interface software you don't need to select "Connect" anymore, and all detecting and communication happens automatically. when you switch on the ignition then the Interface software will detect and connect to the ECU.  
+
Difference in operation to the user now is that in the Interface Software you don't need to select "Connect" anymore, and all detecting and communication happens automatically. when you switch on the ignition then the Interface software will detect and connect to the ECU. The Interface Software also gracefully detects disconnects and reconnects.
  
The USB code in the Interface software is also threaded to allow for smooth communication.
+
The USB code in the Interface Software is also threaded to allow for smooth communication.
  
 
Another change that was made was the status message box. I changed it to fix an annoying memory leak (shame on me for it being there in the first place).
 
Another change that was made was the status message box. I changed it to fix an annoying memory leak (shame on me for it being there in the first place).
  
 
On to more testing!
 
On to more testing!

Revision as of 20:29, 22 April 2013