Testdata.swift 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // Testdata.swift
  3. // MAVLink
  4. //
  5. // Created by Max Odnovolyk on 10/31/16.
  6. // Copyright © 2016 Build Apps. All rights reserved.
  7. //
  8. import Foundation
  9. import XCTest
  10. @testable import MAVLink
  11. extension XCTestCase {
  12. /// Loads data from test tlog file
  13. var testTlogData: Data {
  14. func bundledPath() -> URL? {
  15. let bundle = Bundle(for: MAVLinkTests.self)
  16. return bundle.url(forResource: "flight", withExtension: "tlog")
  17. }
  18. func relativePath() -> URL {
  19. let packagePath = URL(fileURLWithPath: FileManager.default.currentDirectoryPath, isDirectory: true).deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
  20. return packagePath.appendingPathComponent("Tests/MAVLinkTests/Testdata/flight.tlog")
  21. }
  22. let logPath: URL!
  23. #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
  24. if let path = bundledPath() {
  25. logPath = path
  26. } else {
  27. logPath = relativePath()
  28. }
  29. #elseif os(Linux)
  30. logPath = relativePath()
  31. #else
  32. XCTFail("Unsupported target OS")
  33. #endif
  34. return try! Data(contentsOf: logPath)
  35. }
  36. /**
  37. ATTITUDE: The attitude in the aeronautical frame (right-handed, Z-down, X-front, Y-right).
  38. Fields:
  39. timeBootMs = 72062 : Timestamp (milliseconds since system boot)
  40. roll = -0.0695389 : Roll angle (rad, -pi..+pi)
  41. pitch = 0.0272282 : Pitch angle (rad, -pi..+pi)
  42. yaw = 1.11595 : Yaw angle (rad, -pi..+pi)
  43. rollspeed = -0.0208449 : Roll angular speed (rad/s)
  44. pitchspeed = 0.00913008 : Pitch angular speed (rad/s)
  45. yawspeed = 0.00166465 : Yaw angular speed (rad/s)
  46. */
  47. var testAttitudeData: Data {
  48. return Data(bytes: [0xFE, 0x1C, 0x00, 0x01, 0x01, 0x1E, 0x7E, 0x19, 0x01, 0x00, 0x64, 0x6A, 0x8E, 0xBD, 0xB2, 0x0D, 0xDF, 0x3C, 0x5B, 0xD7, 0x8E, 0x3F, 0xEA, 0xC2, 0xAA, 0xBC, 0x56, 0x96, 0x15, 0x3C, 0x51, 0x30, 0xDA, 0x3A, 0x12, 0xAB])
  49. }
  50. var testHeartbeatMessage: Heartbeat {
  51. return Heartbeat(type: 6, autopilot: 8, baseMode: 0, customMode: 0, systemStatus: 0, mavlinkVersion: 3)
  52. }
  53. var testHeartbeatData: Data {
  54. return Data(bytes: [0xFE,0x09,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x08,0x00,0x00,0x03,0xA1,0xDF])
  55. }
  56. var testStatustextData: Data {
  57. return Data(bytes: [0xFE,0x33,0x00,0x01,0x01,0xFD,0x01,0x41,0x50,0x4D,0x3A,0x43,0x6F,0x70,0x74,0x65,0x72,0x20,0x56,0x33,0x2E,0x34,0x2D,0x64,0x65,0x76,0x20,0x28,0x62,0x64,0x64,0x64,0x66,0x61,0x65,0x35,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x07])
  58. }
  59. }