From 46c89008fd846d9652744a7043b8670a74ab9d6d Mon Sep 17 00:00:00 2001 From: ytoi <> Date: Tue, 21 Jul 2020 01:00:53 +0900 Subject: [PATCH] =?UTF-8?q?10msec=E3=81=8A=E8=A9=A6=E3=81=97=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/device/peripheral/vdev/vdev_udp.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/device/peripheral/vdev/vdev_udp.c b/src/device/peripheral/vdev/vdev_udp.c index 6072fd9..52ffb66 100644 --- a/src/device/peripheral/vdev/vdev_udp.c +++ b/src/device/peripheral/vdev/vdev_udp.c @@ -156,11 +156,18 @@ static Std_ReturnType vdev_thread_do_proc(MpthrIdType id) uint64 curr_stime; while (1) { - err = udp_comm_read(&vdev_control.comm); - if (err != STD_E_OK) { + struct timeval timeout = { 0, 10*1000}; // 10msec + err = udp_comm_read_with_timeout(&vdev_control.comm,&timeout); + // err = udp_comm_read(&vdev_control.comm); + if (err == STD_E_TIMEOUT ) { + err = udp_comm_remote_write(&vdev_control.comm, vdev_control.remote_ipaddr); + if (err != STD_E_OK) { + printf("WARNING: vdevput_data8: udp send error=%d\n", err); + } continue; - } - if (vdev_udp_packet_check((const char*)&vdev_control.comm.read_data.buffer[0]) != STD_E_OK) { + } else if (err != STD_E_OK) { + continue; + } else if (vdev_udp_packet_check((const char*)&vdev_control.comm.read_data.buffer[0]) != STD_E_OK) { continue; } //gettimeofday(&unity_notify_time, NULL); @@ -208,16 +215,18 @@ static Std_ReturnType vdev_udp_put_data8(MpuAddressRegionType *region, CoreIdTyp *((uint8*)(®ion->data[off])) = data; if (addr == VDEV_TX_FLAG(0)) { + uint32 tx_off = VDEV_TX_DATA_BASE - region->start; Std_ReturnType err; memcpy(&vdev_control.comm.write_data.buffer[VDEV_TX_DATA_BODY_OFF], ®ion->data[tx_off + VDEV_TX_DATA_BODY_OFF], VDEV_TX_DATA_BODY_SIZE); memcpy(&vdev_control.comm.write_data.buffer[VDEV_TX_SIM_TIME(VDEV_SIM_INX_ME)], (void*)&vdev_control.vdev_sim_time[VDEV_SIM_INX_ME], 8U); memcpy(&vdev_control.comm.write_data.buffer[VDEV_TX_SIM_TIME(VDEV_SIM_INX_YOU)], (void*)&vdev_control.vdev_sim_time[VDEV_SIM_INX_YOU], 8U); //printf("sim_time=%llu\n", vdev_udp_control.vdev_sim_time[VDEV_SIM_INX_ME]); - err = udp_comm_remote_write(&vdev_control.comm, vdev_control.remote_ipaddr); +// err = udp_comm_remote_write(&vdev_control.comm, vdev_control.remote_ipaddr); if (err != STD_E_OK) { printf("WARNING: vdevput_data8: udp send error=%d\n", err); } + } else { }