diff --git a/ROMFS/px4fmu_common/init.d-posix/rcS b/ROMFS/px4fmu_common/init.d-posix/rcS index 8ce56eb640..c12d54850a 100644 --- a/ROMFS/px4fmu_common/init.d-posix/rcS +++ b/ROMFS/px4fmu_common/init.d-posix/rcS @@ -187,15 +187,15 @@ param set-default UXRCE_DDS_AG_IP 2130706433 # 127.0.0.1 # Adapt timeout parameters if simulation runs faster or slower than realtime. if [ -n "$PX4_SIM_SPEED_FACTOR" ]; then - COM_DL_LOSS_T_LONGER=$(echo "$PX4_SIM_SPEED_FACTOR * 10" | bc) + COM_DL_LOSS_T_LONGER=$(awk -v s="$PX4_SIM_SPEED_FACTOR" 'BEGIN{print s*10}') echo "COM_DL_LOSS_T set to $COM_DL_LOSS_T_LONGER" param set COM_DL_LOSS_T $COM_DL_LOSS_T_LONGER - COM_RC_LOSS_T_LONGER=$(echo "$PX4_SIM_SPEED_FACTOR * 1.0" | bc) + COM_RC_LOSS_T_LONGER=$(awk -v s="$PX4_SIM_SPEED_FACTOR" 'BEGIN{print s*1.0}') echo "COM_RC_LOSS_T set to $COM_RC_LOSS_T_LONGER" param set COM_RC_LOSS_T $COM_RC_LOSS_T_LONGER - COM_OF_LOSS_T_LONGER=$(echo "$PX4_SIM_SPEED_FACTOR * 1.0" | bc) + COM_OF_LOSS_T_LONGER=$(awk -v s="$PX4_SIM_SPEED_FACTOR" 'BEGIN{print s*1.0}') echo "COM_OF_LOSS_T set to $COM_OF_LOSS_T_LONGER" param set COM_OF_LOSS_T $COM_OF_LOSS_T_LONGER fi diff --git a/platforms/posix/src/px4/common/px4_daemon/client.cpp b/platforms/posix/src/px4/common/px4_daemon/client.cpp index 8fca536096..7664b98629 100644 --- a/platforms/posix/src/px4/common/px4_daemon/client.cpp +++ b/platforms/posix/src/px4/common/px4_daemon/client.cpp @@ -318,7 +318,21 @@ Client::_listen() PX4_ERR("unable to read from socket: WSA error = %d", wsa_err); #else - PX4_ERR("unable to read from socket"); + + // ECONNRESET / EPIPE can fire on AF_UNIX too if the daemon + // closes the socket between sending the {0, retval} sentinel + // and our recv() picking up the EOF. The bytes have already + // been delivered into our kernel buffer, so honour the + // sentinel rather than reporting a spurious socket error. + if (errno == ECONNRESET || errno == EPIPE) { + if (n_buffer_used == 2) { + return buffer[1]; + } + + return -1; + } + + PX4_ERR("unable to read from socket: %s", strerror(errno)); #endif return -1;