commonMain.com.divpundir.mavlink.definitions.ardupilotmega.EscTelemetry9To12.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of definitions-jvm Show documentation
Show all versions of definitions-jvm Show documentation
A modern MAVLink library for the JVM written in Kotlin.
The newest version!
package com.divpundir.mavlink.definitions.ardupilotmega
import com.divpundir.mavlink.api.GeneratedMavField
import com.divpundir.mavlink.api.GeneratedMavMessage
import com.divpundir.mavlink.api.MavMessage
import com.divpundir.mavlink.serialization.MavDataDecoder
import com.divpundir.mavlink.serialization.MavDataEncoder
import com.divpundir.mavlink.serialization.encodeUInt16Array
import com.divpundir.mavlink.serialization.encodeUInt8Array
import com.divpundir.mavlink.serialization.safeDecodeUInt16Array
import com.divpundir.mavlink.serialization.safeDecodeUInt8Array
import com.divpundir.mavlink.serialization.truncateZeros
import kotlin.Byte
import kotlin.ByteArray
import kotlin.Int
import kotlin.UByte
import kotlin.UInt
import kotlin.UShort
import kotlin.Unit
import kotlin.collections.List
/**
* ESC Telemetry Data for ESCs 9 to 12, matching data sent by BLHeli ESCs.
*
* @param temperature Temperature.
* units = degC
* @param voltage Voltage.
* units = cV
* @param current Current.
* units = cA
* @param totalcurrent Total current.
* units = mAh
* @param rpm RPM (eRPM).
* units = rpm
* @param count count of telemetry packets received (wraps at 65535).
*/
@GeneratedMavMessage(
id = 11_032u,
crcExtra = 85,
)
public data class EscTelemetry9To12(
/**
* Temperature.
* units = degC
*/
@GeneratedMavField(type = "uint8_t[4]")
public val temperature: List = emptyList(),
/**
* Voltage.
* units = cV
*/
@GeneratedMavField(type = "uint16_t[4]")
public val voltage: List = emptyList(),
/**
* Current.
* units = cA
*/
@GeneratedMavField(type = "uint16_t[4]")
public val current: List = emptyList(),
/**
* Total current.
* units = mAh
*/
@GeneratedMavField(type = "uint16_t[4]")
public val totalcurrent: List = emptyList(),
/**
* RPM (eRPM).
* units = rpm
*/
@GeneratedMavField(type = "uint16_t[4]")
public val rpm: List = emptyList(),
/**
* count of telemetry packets received (wraps at 65535).
*/
@GeneratedMavField(type = "uint16_t[4]")
public val count: List = emptyList(),
) : MavMessage {
override val instanceCompanion: MavMessage.MavCompanion = Companion
override fun serializeV1(): ByteArray {
val encoder = MavDataEncoder(SIZE_V1)
encoder.encodeUInt16Array(voltage, 8)
encoder.encodeUInt16Array(current, 8)
encoder.encodeUInt16Array(totalcurrent, 8)
encoder.encodeUInt16Array(rpm, 8)
encoder.encodeUInt16Array(count, 8)
encoder.encodeUInt8Array(temperature, 4)
return encoder.bytes
}
override fun serializeV2(): ByteArray {
val encoder = MavDataEncoder(SIZE_V2)
encoder.encodeUInt16Array(voltage, 8)
encoder.encodeUInt16Array(current, 8)
encoder.encodeUInt16Array(totalcurrent, 8)
encoder.encodeUInt16Array(rpm, 8)
encoder.encodeUInt16Array(count, 8)
encoder.encodeUInt8Array(temperature, 4)
return encoder.bytes.truncateZeros()
}
public companion object : MavMessage.MavCompanion {
private const val SIZE_V1: Int = 44
private const val SIZE_V2: Int = 44
override val id: UInt = 11_032u
override val crcExtra: Byte = 85
override fun deserialize(bytes: ByteArray): EscTelemetry9To12 {
val decoder = MavDataDecoder(bytes)
val voltage = decoder.safeDecodeUInt16Array(8)
val current = decoder.safeDecodeUInt16Array(8)
val totalcurrent = decoder.safeDecodeUInt16Array(8)
val rpm = decoder.safeDecodeUInt16Array(8)
val count = decoder.safeDecodeUInt16Array(8)
val temperature = decoder.safeDecodeUInt8Array(4)
return EscTelemetry9To12(
temperature = temperature,
voltage = voltage,
current = current,
totalcurrent = totalcurrent,
rpm = rpm,
count = count,
)
}
public operator fun invoke(builderAction: Builder.() -> Unit): EscTelemetry9To12 =
Builder().apply(builderAction).build()
}
public class Builder {
public var temperature: List = emptyList()
public var voltage: List = emptyList()
public var current: List = emptyList()
public var totalcurrent: List = emptyList()
public var rpm: List = emptyList()
public var count: List = emptyList()
public fun build(): EscTelemetry9To12 = EscTelemetry9To12(
temperature = temperature,
voltage = voltage,
current = current,
totalcurrent = totalcurrent,
rpm = rpm,
count = count,
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy