Try
'------------------------------------------------------------------------------------------------------
'UNSAVED WILL GO HERE.
'------------------------------------------------------------------------------------------------------
If Starter.GaugeNb > 0 And blnNewFile = True Then 'SAVE ONLY IF NEW FILE AND GAUGES ON BACKGROUND
'Old Legacy Dashboard
If StateManager.blnNewDashboard = False Then
SaveGaugesLayoutsPreference(File.DirInternal, "Layout.cgl") 'SAVES LAYOUTS (DEFAULT) IN PORTRAIT AND LANDSCAPE
'New Dashboard
Else
SaveGaugesLayoutsPreferenceNew(File.DirInternal, "Layout.cgl") 'SAVES LAYOUTS (DEFAULT) IN PORTRAIT AND LANDSCAPE
End If
blnNewFile = False 'test this
End If
'------------------------------------------------------------------------------------------------------
'SELECT MODULE TYPE
'------------------------------------------------------------------------------------------------------
Dim L2 As List: L2.Initialize
L2.Add("All (OBD II Generic)")
L2.Add("Ford")
L2.Add("GM")
L2.Add("Nissan")
L2.Add("Toyota")
L2.Add("KIA")
' Dim Ret1 As Int
' Ret2 = InputList(L2, "Select Vehicle Make", -1)
Dim sf23 As Object = InputListAsync(L2, "Select Vehicle Make", -1, True)
Wait For (sf23) InputList_Result(Ret2 As Int)
If Ret2 = DialogResponse.CANCEL Then
Return
End If
L2.Clear
Select Case Ret2
'--------------------------------------------------------------------------------------------------
'FORD
'--------------------------------------------------------------------------------------------------
Case 1
L2.Add("Powertrain")
L2.Add("Powertrain 2")
L2.Add("ABS")
L2.Add("Accessory Protocol") 'new
L2.Add("A/C Control")
L2.Add("Airbag")
L2.Add("Air Suspension")
L2.Add("All Terrain") 'New
L2.Add("Anti-Theft Passive")
L2.Add("Anti-Theft Remote")
L2.Add("Audio Control")
L2.Add("Audio Rear")
L2.Add("Aux Fuel Control")
L2.Add("Body Control B") 'new
L2.Add("Central Security")
L2.Add("Cluster")
L2.Add("Column Lock") 'New
L2.Add("Cruise Control") 'New
L2.Add("Digital Audio Process") 'New
L2.Add("Driver Seat")
L2.Add("Driver Door")
L2.Add("Electronics Rear")
L2.Add("Electronic Parking Brake")
L2.Add("Front Control") 'new
L2.Add("Front Control/Display") 'New
L2.Add("Front Display") 'new
L2.Add("Front Lighting Control")
L2.Add("GEM/Front Electronics")
L2.Add("Generic Function") 'New
L2.Add("Global Positioning System") 'new
L2.Add("Headlamp/Right")
L2.Add("Headlamp Left")
L2.Add("Head Up Display") 'New
L2.Add("Hybrid Electronic")
L2.Add("Image Process A") 'new
L2.Add("Liftgate/Trunk")
L2.Add("Over Head Trip 1")
L2.Add("Over Head Trip 2")
L2.Add("Navigation")
L2.Add("Park Aid")
L2.Add("Passenger Seat")
L2.Add("Passenger Door")
L2.Add("Power Steering Assist")
L2.Add("Occupant Classification") 'new
L2.Add("Satellite Audio") 'new
L2.Add("Sliding Door Right")
L2.Add("Sliding Door Left")
L2.Add("Steering Angle Module")
L2.Add("Steering Column") 'new
L2.Add("Tire Monitor")
L2.Add("Trailer Brake")
L2.Add("Transmission")
L2.Add("4x4 Control")
L2.Add("Back")
' Ret1 = InputList(L2, "Select Module" & " (Ford)", -1)
Dim sf24 As Object = InputListAsync(L2, "Select Module" & " (Ford)", -1, True)
Wait For (sf24) InputList_Result(Ret1 As Int)
If Ret1 = DialogResponse.CANCEL Then
Return
End If
'ARRANGE THEM PROPERLY. THEY NEED SORTING AND INDEX IS BASED ON THE ORDER WHICH AFFECTS THE GAUGES FILE TYPE MODULE
Select Case L2.Get(Ret1)
Case "Powertrain": Ret1 = 5 'FORD CAN POWERTRAIN
Case "Powertrain 2": Ret1 = 79 'FORD PWM POWERTRAIN 2
Case "Transmission": Ret1 = 82 'FORD TRANSMISSION
Case "ABS": Ret1 = 7 'FORD ABS 1
Case "A/C Control": Ret1 = 11 'FORD A/C
Case "Airbag": Ret1 = 10 'FORD AIRBAG
Case "Air Suspension": Ret1 = 12 'FORD SUSPENSION
Case "Anti-Theft Passive": Ret1 = 13 'FORD THEFT PASSIVE
Case "Anti-Theft Remote": Ret1 = 14 'FORD THEFT REMOTE
Case "Audio Control": Ret1 = 15 'FORD AUDIO
Case "Audio Rear": Ret1 = 72 'FORD AUDIO REAR
Case "Aux Fuel Control": Ret1 = 16 'FORD AUX FUEL
Case "Central Security": Ret1 = 76 'FORD CENTRAL SECURITY
Case "Cluster": Ret1 = 8 'FORD CLUSTER
Case "Driver Seat": Ret1 = 17 'DRIVER SEAT
Case "Driver Door": Ret1 = 18 'DRIVER DOOR
Case "Electronics Rear": Ret1 = 19 'ELECTRONICS REAR
Case "Electronic Parking Brake": Ret1 = 64 'ELECTRONIC PARKING
Case "Front Lighting Control": Ret1 = 70 'FRONT LIGHTING CONTROL
Case "GEM/Front Electronics": Ret1 = 21 'GEM 1
Case "Headlamp/Right": Ret1 = 71 'HEADLAMP/RIGHT
Case "Headlamp Left": Ret1 = 95 'HEADLAMP LEFT
Case "Hybrid Electronic": Ret1 = 84 'HYBRID ELECTRONIC
Case "Liftgate/Trunk": Ret1 = 95 'LIFTGATE/TRUNK
Case "Over Head Trip 1": Ret1 = 23 'OVER HEAD TRIP 1
Case "Over Head Trip 2": Ret1 = 24 'OVER HEAD TRIP 2
Case "Navigation": Ret1 = 69 'NAVIGATION
Case "Park Aid": Ret1 = 25 'FORD PARK AID
Case "Passenger Seat": Ret1 = 77 'FORD PASSENGER SEAT
Case "Passenger Door": Ret1 = 78 'FORD PASSENGER DOOR
Case "Power Steering Assist": Ret1 = 65 'POWER STEERING ASSIST
Case "Sliding Door Right": Ret1 = 97 'SLIDING DOOR RIGHT
Case "Sliding Door Left": Ret1 = 98 'SLIDING DOOR LEFT
Case "Steering Angle Module": Ret1 = 68 'STEERING ANGLE
Case "Tire Monitor": Ret1 = 9 'FORD TIRE
Case "Trailer Brake": Ret1 = 83 'TRAILER BRAKE
Case "4x4 Control": Ret1 = 26 'FORD 4X4
Case "Accessory Protocol": Ret1 = 99 'FORD ACCESSORY PROTOCOL
Case "Body Control B": Ret1 = 100 'BODY CONTROL MODULE B
Case "Front Control": Ret1 = 101 'FRONT CONTROL
Case "Front Display": Ret1 = 102 'FRONT DISPLAY
Case "Global Positioning System": Ret1 = 103 'GPS
Case "Occupant Classification": Ret1 = 104 'OCCUPANT CLASSIFICATION
Case "Satellite Audio": Ret1 = 105 'SATELLITE AUDIO
Case "All Terrain": Ret1 = 110 'New
Case "Column Lock": Ret1 = 114 'New
Case "Cruise Control": Ret1 = 112 'New
Case "Digital Audio Process": Ret1 = 111 'New
Case "Front Control/Display": Ret1 = 108 'New
Case "Generic Function": Ret1 = 109 'New
Case "Head Up Display": Ret1 = 107 'New
Case "Image Process A": Ret1 = 115 'new
Case "Steering Column": Ret1 = 113 'new
Case "Back": ImportPidsOptions_Click: Return
End Select
'--------------------------------------------------------------------------------------------------
'GM
'--------------------------------------------------------------------------------------------------
Case 2
L2.Add("Powertrain")
L2.Add("ABS")
L2.Add("A/C-Heating")
L2.Add("Amplifier") 'new
L2.Add("Battery")
L2.Add("BCM")
L2.Add("CD Changer")
L2.Add("Chime")
L2.Add("Cluster")
L2.Add("Cluster 2") 'new
L2.Add("Door Driver")
L2.Add("Door Passenger")
L2.Add("End Gate") 'new
L2.Add("ESC")
L2.Add("EVO/Theft Deterrent/Passlock")
L2.Add("Head Display") 'new
L2.Add("Lift Gate") 'new
L2.Add("Onstar")
L2.Add("Onstar VS")
L2.Add("Radio/Navigation")
L2.Add("Radio Receiver")
L2.Add("Rear Climate")
L2.Add("Rear HVAC")
L2.Add("Rear Integration") 'new
L2.Add("Rear Seat Audio")
L2.Add("Rear Seat Entertainment") 'new
L2.Add("Rear Steering")
L2.Add("Remote Actuation") 'new
L2.Add("Seat Driver")
L2.Add("SIR")
L2.Add("Tire Monitor")
L2.Add("Transfer Case")
L2.Add("Transmission")
L2.Add("Traction Control")
L2.Add("VCI")
L2.Add("4WAL/ABS/VSES")
L2.Add("Back")
' Ret1 = InputList(L2, "Select Module" & " (GM)", -1)
Dim sf25 As Object = InputListAsync(L2, "Select Module" & " (GM)", -1, True)
Wait For (sf25) InputList_Result(Ret1 As Int)
If Ret1 = DialogResponse.CANCEL Then
Return
End If
'ARRANGE THEM PROPERLY. THEY NEED SORTING AND INDEX IS BASED ON THE ORDER WHICH AFFECTS THE GAUGES FILE TYPE MODULE
Select Case L2.Get(Ret1)
Case "Powertrain": Ret1 = 27
Case "ABS": Ret1 = 85
Case "A/C-Heating": Ret1 = 29
Case "Battery": Ret1 = 31
Case "BCM": Ret1 = 32
Case "CD Changer": Ret1 = 33
Case "Chime": Ret1 = 34
Case "Cluster": Ret1 = 35
Case "Door Driver": Ret1 = 37
Case "Door Passenger": Ret1 = 38
Case "ESC": Ret1 = 39
Case "EVO/Theft Deterrent/Passlock": Ret1 = 40
Case "Onstar": Ret1 = 42
Case "Onstar VS": Ret1 = 43
Case "Radio/Navigation": Ret1 = 45
Case "Radio Receiver": Ret1 = 36
Case "Rear Climate": Ret1 = 46
Case "Rear HVAC": Ret1 = 47
Case "Rear Seat Audio": Ret1 = 48
Case "Rear Steering": Ret1 = 49
Case "Seat Driver": Ret1 = 50
Case "SIR": Ret1 = 51
Case "Tire Monitor": Ret1 = 53
Case "Transfer Case": Ret1 = 30
Case "Transmission": Ret1 = 54
Case "Traction Control": Ret1 = 55
Case "VCI": Ret1 = 56
Case "4WAL/ABS/VSES": Ret1 = 58
Case "Amplifier": Ret1 = 88
Case "Cluster 2": Ret1 = 91
Case "End Gate": Ret1 = 86
Case "Head Display": Ret1 = 90
Case "Lift Gate": Ret1 = 89
Case "Rear Integration": Ret1 = 92
Case "Rear Seat Entertainment": Ret1 = 87
Case "Remote Actuation": Ret1 = 93
Case "Back": ImportPidsOptions_Click : Return
End Select
'--------------------------------------------------------------------------------------------------
'NISSAN
'--------------------------------------------------------------------------------------------------
Case 3
L2.Add("ECM (Gasoline)")
L2.Add("ECM (Diesel)")
L2.Add("TCM")
L2.Add("ABS")
L2.Add("SRS")
L2.Add("BCM-40")
L2.Add("BCM-42")
L2.Add("4WD")
L2.Add("Back")
' Ret1 = InputList(L2, "Select Module" & " (Nissan)", -1)
Dim sf26 As Object = InputListAsync(L2, "Select Module" & " (Nissan)", -1, True)
Wait For (sf26) InputList_Result(Ret1 As Int)
If Ret1 = DialogResponse.CANCEL Then
Return
End If
'ARRANGE THEM PROPERLY. THEY NEED SORTING AND INDEX IS BASED ON THE ORDER WHICH AFFECTS THE GAUGES FILE TYPE MODULE
Select Case L2.Get(Ret1)
Case "ECM (Gasoline)": Ret1 = 2 'NISSAN ECM 0x10
Case "ECM (Diesel)": Ret1 = 4 'NISSAN ECM 0x12
Case "TCM": Ret1 = 3 'NISSAN TCM
Case "ABS": Ret1 = 63 'NISSAN ABS 0x28
Case "SRS": Ret1 = 81 'NISSAN SRS 0x58
Case "BCM-40": Ret1 = 66 'NISSAN BCM 0x40
Case "BCM-42": Ret1 = 67 'NISSAN BCM 0x42
Case "4WD": Ret1 = 94 'NISSAN 4WD 0x22
Case "Back": ImportPidsOptions_Click: Return
End Select
'--------------------------------------------------------------------------------------------------
'TOYOTA
'--------------------------------------------------------------------------------------------------
Case 4
L2.Add("PowertrainCAN")
L2.Add("Powertrain")
L2.Add("Airbag")
'L2.Add("Airbag")
'L2.Add("Occupant")
L2.Add("Back")
' Ret1 = InputList(L2, "Select Module" & " (Toyota)", -1)
Dim sf27 As Object = InputListAsync(L2, "Select Module" & " (Toyota)", -1, True)
Wait For (sf27) InputList_Result(Ret1 As Int)
If Ret1 = DialogResponse.CANCEL Then
Return
End If
'ARRANGE THEM PROPERLY. THEY NEED SORTING AND INDEX IS BASED ON THE ORDER WHICH AFFECTS THE GAUGES FILE TYPE MODULE
Select Case L2.Get(Ret1)
Case "PowertrainCAN": Ret1 = 62 'TOYOTA POWERTRAIN CAN
Case "Powertrain": Ret1 = 1 'TOYOTA POWERTRAIN
Case "Airbag": Ret1 = 59 'TOYOTA AIRBAG
' Case "Airbag": Ret1 = 61 'TOYOTA OCCUPANT
' Case "Occupant": Ret1 = 60 'TOYOTA AIRBAG OLD
Case "Back": ImportPidsOptions_Click: Return
End Select
'--------------------------------------------------------------------------------------------------
'OTHER
'--------------------------------------------------------------------------------------------------
Case 5
L2.Add("Powertrain")
'L2.Add("KIA Powertrain")
'L2.Add("Vauxhall Powertrain")
L2.Add("Back")
' Ret1 = InputList(L2, "Select Module" & " (KIA)", -1)
'Ret1 = InputList(L2, "Select Module" & " (Other)", -1)
Dim sf27 As Object = InputListAsync(L2, "Select Module" & " (KIA)", -1, True)
Wait For (sf27) InputList_Result(Ret1 As Int)
If Ret1 = DialogResponse.CANCEL Then
Return
End If
'ARRANGE THEM PROPERLY. THEY NEED SORTING AND INDEX IS BASED ON THE ORDER WHICH AFFECTS THE GAUGES FILE TYPE MODULE
Select Case L2.Get(Ret1)
Case "Powertrain": Ret1 = 74 'KIA ISO 9141
'Case "KIA Powertrain": Ret1 = 74 'KIA ISO 9141
'Case "Vauxhall Powertrain": Ret1 = 73 'VAUXHALL
Case "Back": ImportPidsOptions_Click: Return
End Select
End Select
'--------------------------------------------------------------------------------------------------
'END OF MODULE SELECTION
'--------------------------------------------------------------------------------------------------
'SET THE MODULE TYPE
Starter.SELECT_MODULE = Ret1
'SPECIAL PROCEDURES FOR CERTAIN MODULES
Select Case Starter.SELECT_MODULE
'--------------------------------------------------------------------
'FIGURE OUT ADDRESS FOR NISSANS
'--------------------------------------------------------------------
Case Starter.NISSAN_POWERTRAIN_0x10: Starter.NISSAN_ADDR = "10"
Case Starter.NISSAN_POWERTRAIN_0x12: Starter.NISSAN_ADDR = "12"
Case Starter.NISSAN_TCM: Starter.NISSAN_ADDR = "18"
Case Starter.NISSAN_4WD_0x22: Starter.NISSAN_ADDR = "22"
Case Starter.NISSAN_ABS: Starter.NISSAN_ADDR = "28"
Case Starter.NISSAN_BCM_0x40: Starter.NISSAN_ADDR = "40"
Case Starter.NISSAN_BCM_0x42: Starter.NISSAN_ADDR = "42"
Case Starter.NISSAN_AIRBAG_0x58: Starter.NISSAN_ADDR = "58"
Case Starter.NISSAN_POWERTRAIN_0x7E0: Starter.NISSAN_ADDR = "0007E0"
End Select
'Alert User it will disconnect
If Starter.blnConnected = True Then
Dim sf88 As Object = Msgbox2Async("This will disconnect from OBD2", "Offline Only", "OK", "Cancel", "", LoadBitmap(File.DirAssets, "disclaimer.png"), True)
Wait For (sf88) Msgbox_Result(Result As Int)
If Result = DialogResponse.CANCEL Then
Return
End If
End If
'------------------------------------------------------------------------------------------------------
'CALL DISCONNECT
'------------------------------------------------------------------------------------------------------
Starter.blnResetELM = True 'BYPASS THE RESET IT WILL RESET ON NEXT CONNECTION
CallSub(CommunicationRoutine, "mnuDisconnect_Click") 'ASTREAM CLOSED BEFORE STARTING AGAIN. NOT SURE IF I LIKE THIS METHOD.
Starter.blnReconnect = False
Dim d As Thread 'ignore
d.Initialise("") 'delay to avoid busy error.
d.Sleep(200)
'CLEARS THE GAUGES. WRONG FILE TYPE WILL CAUSE PROBLEMS
If Starter.SELECT_MODULE <> Starter.ModuleFileType Then 'SELECT MODULE SELECTION CAN BE CHOSEN BY USER. MODULEFILETYPE IS CHOSEN BY PROFILE WHEN LOADED.
'Legacy Dashboard
If StateManager.blnNewDashboard = False Then
ClearAllGauges(False, True)
'New Dashboard
Else
ClearAllGaugesNew(False, True)
End If
Starter.ModuleFileType = Starter.SELECT_MODULE
End If
'allow user to import from file or all
Dim mL As List: mL.Initialize
mL.Add("Import Predefined Pids"): mL.Add("Import from file")
' Dim Ret4 As Int
' Ret4 = InputList(mL, "Choose Import Types", 0)
Dim sf27 As Object = InputListAsync(mL, "Choose Import Types", 0, True)
Wait For (sf27) InputList_Result(Ret4 As Int)
Select Case Ret4
Case 0: GaugeCenterReadyImport(False)
Case 1: ImportPidList
End Select
Catch
Msgbox2Async("The following Error Message Occured" & Chr(10) & Chr(10) & LastException.Message, "Error ImportPidsOptions", "Ok", "", "", LoadBitmap(File.DirAssets, "disclaimer.png"), True)
End Try