Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions Example/OBD2-Swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,19 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0910;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = J7LBYY3B34;
LastSwiftMigration = 0910;
LastSwiftMigration = 1020;
};
};
};
buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "OBD2-Swift" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -292,6 +292,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand All @@ -300,12 +301,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -345,6 +348,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand All @@ -353,12 +357,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -399,8 +405,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -416,8 +421,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0910"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -40,7 +40,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -70,7 +69,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
4 changes: 1 addition & 3 deletions Example/OBD2-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand All @@ -40,7 +40,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

19 changes: 12 additions & 7 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions OBD2-Swift/Classes/Command/CommandMode01.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import Foundation

public extension Command {

public enum Mode01 : CommandType {
enum Mode01 : CommandType {

public typealias Descriptor = Mode01Descriptor

public var hashValue: Int {
switch self {
case .pid(number : let pid):
return Int(mode.rawValue) ^ pid
}
public func hash(into hasher: inout Hasher) {
switch self {
case .pid(number : let pid):
hasher.combine(Int(mode.rawValue) ^ pid)
}
}

public static func ==(lhs: Mode01, rhs: Mode01) -> Bool {
Expand All @@ -37,7 +37,5 @@ public extension Command {
return DataRequest(mode: mode, pid: UInt8(pid))
}
}

}

}
12 changes: 6 additions & 6 deletions OBD2-Swift/Classes/Command/CommandMode02.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import Foundation

public extension Command {

public enum Mode02 : CommandType {
enum Mode02 : CommandType {

public typealias Descriptor = Mode01Descriptor

public var hashValue: Int {
switch self {
case .pid(number : let pid):
return Int(mode.rawValue) ^ pid
}
public func hash(into hasher: inout Hasher) {
switch self {
case .pid(number : let pid):
hasher.combine(Int(mode.rawValue) ^ pid)
}
}

public static func ==(lhs: Mode02, rhs: Mode02) -> Bool {
Expand Down
6 changes: 3 additions & 3 deletions OBD2-Swift/Classes/Command/CommandMode03.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import Foundation

public extension Command {

public enum Mode03 : CommandType {
enum Mode03 : CommandType {

public typealias Descriptor = Mode03Descriptor

public var hashValue: Int {
return Int(mode.rawValue) ^ 0
public func hash(into hasher: inout Hasher) {
hasher.combine(Int(mode.rawValue) ^ 0)
}

public static func == (lhs: Mode03, rhs: Mode03) -> Bool {
Expand Down
6 changes: 3 additions & 3 deletions OBD2-Swift/Classes/Command/CommandMode09.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation


public extension Command {
public enum Mode09 : CommandType {
enum Mode09 : CommandType {

public typealias Descriptor = Mode09Descriptor

Expand All @@ -24,8 +24,8 @@ public extension Command {
return lhs.hashValue == rhs.hashValue
}

public var hashValue: Int {
return Int(mode.rawValue ^ pid)
public func hash(into hasher: inout Hasher) {
hasher.combine(Int(mode.rawValue ^ pid))
}

public var mode : Mode {
Expand Down
5 changes: 2 additions & 3 deletions OBD2-Swift/Classes/Command/DataRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ extension DataRequest: Equatable {
}

extension DataRequest: Hashable {

public var hashValue: Int {
return description.hash
public func hash(into hasher: inout Hasher) {
hasher.combine(description.hash)
}
}
8 changes: 4 additions & 4 deletions OBD2-Swift/Classes/Model/Command.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public struct Command {
case readDeviceIdentifier
case setDeviceIdentifier(String)

public var hashValue: Int {
return Int(mode.rawValue ^ mode.rawValue)
public func hash(into hasher: inout Hasher) {
hasher.combine(Int(mode.rawValue ^ mode.rawValue))
}

public static func == (lhs: AT, rhs: AT) -> Bool {
Expand Down Expand Up @@ -86,8 +86,8 @@ public struct Command {
case string(String)
case digit(mode : Int, pid : Int)

public var hashValue: Int {
return Int(mode.rawValue ^ pid)
public func hash(into hasher: inout Hasher) {
hasher.combine(Int(mode.rawValue ^ pid))
}

public static func == (lhs: Custom, rhs: Custom) -> Bool {
Expand Down
4 changes: 2 additions & 2 deletions OBD2-Swift/Classes/Model/Response.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public struct Response : Hashable, Equatable {
self.timestamp = Date()
}

public var hashValue: Int {
return Int(mode.rawValue ^ pid)
public func hash(into hasher: inout Hasher) {
hasher.combine(Int(mode.rawValue ^ pid))
}

public static func ==(lhs: Response, rhs: Response) -> Bool {
Expand Down
2 changes: 1 addition & 1 deletion OBD2-Swift/Classes/Observer/SensorObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Observer<T : CommandType> : ObserverType {
public func observe(command : T, block : @escaping (_ descriptor : T.Descriptor?)->()){
let key = command.hashValue
let array = observers[key] ?? []
let flatAray = array.flatMap({$0})
let flatAray = array.compactMap({$0})
observers[key] = flatAray
observers[key]?.append(block)
}
Expand Down
4 changes: 2 additions & 2 deletions OBD2-Swift/Classes/Operations/CommandOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class CommandOperation: StreamHandleOperation {
private(set) var reader: StreamReader
private var readCompleted = false {
didSet {
self.input.remove(from: .current, forMode: .defaultRunLoopMode)
self.output.remove(from: .current, forMode: .defaultRunLoopMode)
self.input.remove(from: .current, forMode: RunLoop.Mode.default)
self.output.remove(from: .current, forMode: RunLoop.Mode.default)
}
}

Expand Down
4 changes: 2 additions & 2 deletions OBD2-Swift/Classes/Operations/InitScanerOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class InitScanerOperation: StreamHandleOperation {
private var state: Scanner.State = .unknown {
didSet{
if state == .complete {
input.remove(from: .current, forMode: .defaultRunLoopMode)
output.remove(from: .current, forMode: .defaultRunLoopMode)
input.remove(from: .current, forMode: RunLoop.Mode.default)
output.remove(from: .current, forMode: RunLoop.Mode.default)
}
}
}
Expand Down
Loading