obu数据自测

This commit is contained in:
tongchenfei
2020-09-22 17:46:39 +08:00
parent e4e01c1176
commit d811751442
6 changed files with 44 additions and 9 deletions

View File

@@ -36,9 +36,10 @@ class HualiObu : BaseObu(), IUdpSocketCallback {
}
override fun onMessageReceived(msg: ByteArray) {
// todo 处理数据
// 处理数据
val m = String(msg)
Logger.d(TAG, "onMessageReceived: $m")
printByteArray(msg)
parseObuProtocol(msg)
}
@@ -188,10 +189,10 @@ class HualiObu : BaseObu(), IUdpSocketCallback {
array.forEach {
val res = it.toInt() and 0xff
arrayBuilder.append("0x")
if (res < 10) {
if (res < 16) {
arrayBuilder.append("0")
}
arrayBuilder.append(it.toString(16)).append(", ")
arrayBuilder.append(Integer.toHexString(res)).append(", ")
}
Logger.d(TAG, arrayBuilder.toString())
}

View File

@@ -59,7 +59,7 @@ class UdpSocketManager(private val callback: IUdpSocketCallback? = null) {
socket = DatagramSocket(address.port)
socketMap[address] = socket
}
val buffer = ByteArray(1024)
val buffer = ByteArray(2048)
val packet = DatagramPacket(buffer, buffer.size)
while (isConnected){
if(socket.isClosed){

View File

@@ -28,7 +28,6 @@ import com.zhidao.mogo.module.obu.obu.bean.MogoObuEventInfo;
import com.zhidao.mogo.module.obu.obu.bean.MogoObuLocationInfo;
import com.zhidao.mogo.module.obu.obu.bean.MogoObuTrafficLightInfo;
import org.jetbrains.annotations.NotNull;
import org.json.JSONObject;
import java.util.Map;
@@ -188,8 +187,9 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
return;
}
}
if (SystemClock.elapsedRealtime() - last > DEFAULT_INTERVAL_TIME) {
if (SystemClock.elapsedRealtime() - last > DEFAULT_INTERVAL_TIME||DebugConfig.getObuType() == DebugConfig.OBU_TYPE_HUALI) {
// 距离上次记录超过三十秒,继续相关逻辑,如果不超过三十秒,忽略此次事件
// 华砺智行obu暂时去掉此判断
intervalMap.put(info.getTypeCode(), SystemClock.elapsedRealtime());
V2XMessageEntity<V2XObuEventEntity> messageEntity = new V2XMessageEntity<>();
messageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_OBU_EVENT);