You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to send Data from my iOS application to a companion computer on a Matrice 300 RTK. For this I’m using the DJI mobile SDK (4.16) and the DJI onboard SDK (4.1.0).
Receiving Data from the companion computer does not cause any problems. But if I try to send data, the application crashes after sending. This means, that the data are received on the companion computer, but afterward the iOS application throws a “bad access exception”. It seems that this erros occurs in the DJI mobile SDK so I’m not able to get useful information to solve the problem.
private var voxelRepository: VoxelRepository?
func connectToOnboardSDK(){
self.voxelRepository = VoxelRepository() { (data) in
print(data)
}
}
func startConnection(){
var startVoxelTransmissionSettings = Voxel_LidarSettings()
let serializedSettings = VoxelSerializer.serializeSettings(lidarSettings: startVoxelTransmissionSettings)
self.voxelRepository?.sendData(data: serializedSettings ?? Data())
}
import Foundation
import DJISDK
class VoxelRepository: NSObject {
private let EOM = "^"
private var onboardSDKDevice: DJIOnboardSDKDevice?
private var responseData = Data()
private var completion: (Voxel_LidarData)->Void
init(completion: @escaping (Voxel_LidarData)->Void){
self.completion = completion
super.init()
initOnboardSDK()
}
private func initOnboardSDK(){
let product = DJISDKManager.product()
let aircraft = product as? DJIAircraft
let flightController = aircraft!.flightController
let onboardSDKDevice = flightController!.onboardSDKDevice
guard flightController!.isOnboardSDKAvailable() == true else {
return
}
onboardSDKDevice!.delegate = self
self.onboardSDKDevice = onboardSDKDevice
}
func sendData(data: Data) {
let size = data.count
var bytesSent = 0
let packageSize = 100
while bytesSent < size {
let bytesToSend = min(packageSize, size-bytesSent)
let dataPart = data.subdata(in: bytesSent..<bytesSent+bytesToSend)
print("sending data with length \(bytesToSend)")
onboardSDKDevice!.sendDataFromMobile(toOnboard: dataPart) { error in
print("completion with \(error.debugDescription)")
}
bytesSent += bytesToSend
}
print("done sending bytes")
sendEOM()
}
private func sendEOM() {
let eomMessage = EOM.data(using: .utf8) ?? Data()
onboardSDKDevice!.sendDataFromMobile(toOnboard: eomMessage, withCompletion: nil)
print("eom sent")
}
}
extension VoxelRepository: DJIOnboardSDKDeviceDelegate {
func onboardSDKDeviceDidDeactivate(_ osdkDevice: DJIOnboardSDKDevice) {
}
func onboardSDKDevice(_ osdkDevice: DJIOnboardSDKDevice, didActivateWithOnboardSDKVersion osdkVersion: String) {
}
func onboardSDKDevice(_ osdkDevice: DJIOnboardSDKDevice, didSendDataToMobile data: Data) {
print("did receive data")
if let stringRep = String(data: data, encoding: .utf8), stringRep == EOM {
// Response Data contains whole message, parse and reset for next message
let lidarData = VoxelSerializer.deserializeLidarHit(data: responseData)
// signal to somewhere that lidar data has been received
print("received lidar data with nr of hits: \(lidarData?.hits.count)")
responseData = Data()
self.completion(lidarData ?? Voxel_LidarData())
return
}
print("appending data")
responseData.append(data)
}
}
Am I missing something, or could there be a problem with the DJI mobile SDK?
Dear DJI Team,
I try to send Data from my iOS application to a companion computer on a Matrice 300 RTK. For this I’m using the DJI mobile SDK (4.16) and the DJI onboard SDK (4.1.0).
Receiving Data from the companion computer does not cause any problems. But if I try to send data, the application crashes after sending. This means, that the data are received on the companion computer, but afterward the iOS application throws a “bad access exception”. It seems that this erros occurs in the DJI mobile SDK so I’m not able to get useful information to solve the problem.
Am I missing something, or could there be a problem with the DJI mobile SDK?
Best Regards
Versions / Products
DJI mobile SDK 4.16
DJI onboard SDK 4.1.0
Matrice 300 RTK
iPad Air 4
iOS 15.4.1
Xcode 13.3.1
The text was updated successfully, but these errors were encountered: