Browse Source

修复部分钥匙底座左、右判断

Frankensteinly 1 năm trước cách đây
mục cha
commit
1e371e013e

+ 1 - 0
app/src/main/java/com/grkj/iscs/activity/ModbusActivity.kt

@@ -60,6 +60,7 @@ class ModbusActivity : BaseMvpActivity<IModbusView, ModBusPresenter, ActivityMod
                 LogUtil.i("单slave卡扣状态 : $type - ${res.toHexStrings()}")
                 when (type) {
                     0 -> {
+                        // TODO 待验证
                         val isLeftLock = (res[4].toInt() shr 0) and 0x1 == 1
                         val isRightLock = (res[4].toInt() shr 4) and 0x1 == 1
                         println("钥匙底座卡扣状态 : $isLeftLock - $isRightLock")

+ 4 - 4
app/src/main/java/com/grkj/iscs/modbus/DeviceBean.kt

@@ -26,10 +26,10 @@ class DeviceBean(
             when (it) {
                 0x00.toByte() -> {
                     // TODO 未验证
-                    val leftHasKey = (byteArray[3].toInt() shr 0) and 0x1 == 1
-                    val isLeftCharging = (byteArray[3].toInt() shr 1) and 0x1 == 1
-                    val rightHasKey = (byteArray[4].toInt() shr 0) and 0x1 == 1
-                    val isRightCharging = (byteArray[4].toInt() shr 1) and 0x1 == 1
+                    val leftHasKey = (byteArray[4].toInt() shr 0) and 0x1 == 1
+                    val isLeftCharging = (byteArray[4].toInt() shr 1) and 0x1 == 1
+                    val rightHasKey = (byteArray[3].toInt() shr 0) and 0x1 == 1
+                    val isRightCharging = (byteArray[3].toInt() shr 1) and 0x1 == 1
                     LogUtil.i("钥匙刷新状态 : $leftHasKey - $isLeftCharging - $rightHasKey - $isRightCharging")
                     if (keyList.isEmpty()) {
                         keyList.add(KeyBean(true, leftHasKey, isLeftCharging))

+ 2 - 1
app/src/main/java/com/grkj/iscs/modbus/ModBusManager.kt

@@ -292,7 +292,8 @@ class ModBusManager(
     fun generateKeyLightCmd(leftAction: Int = 0, rightAction: Int = 0): MBFrame {
         return MBFrame(
             FRAME_TYPE_WRITE,
-            byteArrayOf(0x00, 0x15, leftAction.toByte(), rightAction.toByte())
+            // TODO 第三个是高位,第四个是低位
+            byteArrayOf(0x00, 0x15, rightAction.toByte(), leftAction.toByte())
         )
     }