Merge remote-tracking branch 'refs/remotes/origin/master'
Conflicts: Sources/SwiftRPLidar/SwiftRPLidar.swift
This commit is contained in:
8
Sources/SwiftRPLidar/LidarSerial.swift
Normal file
8
Sources/SwiftRPLidar/LidarSerial.swift
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
protocol LidarSerial {
|
||||||
|
var dtr: Bool {get set};
|
||||||
|
var inWaiting: Int {get};
|
||||||
|
func closePort() -> Void;
|
||||||
|
func openPort() -> Void;
|
||||||
|
readData(ofLength: Int) throws -> Void;
|
||||||
|
writeData(_ data: Data) throws -> Void;
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import SwiftSerial
|
import LidarSerial
|
||||||
|
|
||||||
struct Constants{
|
struct Constants{
|
||||||
static let SYNC: UInt8 = 0xA5
|
static let SYNC: UInt8 = 0xA5
|
||||||
@@ -64,11 +64,11 @@ typealias ScanHandler = (_ scans: [LidarScan]) -> Bool
|
|||||||
|
|
||||||
class RPLidar{
|
class RPLidar{
|
||||||
private var motor: Bool = false
|
private var motor: Bool = false
|
||||||
private var serialPort: SerialPort? = nil
|
private var serialPort: LidarSerial? = nil
|
||||||
private var motorRunning = false
|
private var motorRunning = false
|
||||||
|
|
||||||
|
|
||||||
init(onPort serialPort: SerialPort) throws {
|
init(onPort serialPort: LidarSerial) throws {
|
||||||
self.serialPort = serialPort
|
self.serialPort = serialPort
|
||||||
try connect()
|
try connect()
|
||||||
try startMotor()
|
try startMotor()
|
||||||
|
|||||||
Reference in New Issue
Block a user