diff options
author | Martin Burnicki <martin.burnicki@meinberg.de> | 2022-08-23 19:32:58 +0200 |
---|---|---|
committer | Martin Burnicki <martin.burnicki@meinberg.de> | 2022-08-23 19:32:58 +0200 |
commit | 0b41ca6d8a25c68ffe9f34f4371b1ae9a15a41ae (patch) | |
tree | 76a2b8663839844998c2f04f12b3a80dfcf64c76 | |
parent | 60683008a47e57574dbc992735c71e8ba2972ee9 (diff) | |
download | mbgtools-lx-0b41ca6d8a25c68ffe9f34f4371b1ae9a15a41ae.tar.gz mbgtools-lx-0b41ca6d8a25c68ffe9f34f4371b1ae9a15a41ae.zip |
Use more feature check functions rather than macros in mbgdevio
Also quiet some compiler warnings.
-rw-r--r-- | mbglib/common/mbgdevio.c | 79 | ||||
-rw-r--r-- | mbglib/common/mbgdevio.h | 19 |
2 files changed, 68 insertions, 30 deletions
diff --git a/mbglib/common/mbgdevio.c b/mbglib/common/mbgdevio.c index 44cad56..617cc3b 100644 --- a/mbglib/common/mbgdevio.c +++ b/mbglib/common/mbgdevio.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgdevio.c 1.56 2022/06/23 15:01:51 martin.burnicki REL_M $ + * $Id: mbgdevio.c 1.57 2022/08/23 15:59:09 martin.burnicki REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,10 @@ * * ----------------------------------------------------------------------- * $Log: mbgdevio.c $ + * Revision 1.57 2022/08/23 15:59:09 martin.burnicki + * Use feature check functions instead of macros. + * Updated some doxygen comments. + * Quieted some compiler warnings. * Revision 1.56 2022/06/23 15:01:51 martin.burnicki * Fixed functions mbg_chk_dev_has_xmr, mbg_chk_dev_has_ptp_unicast, * and mbg_chk_dev_has_gpio. @@ -4956,7 +4960,7 @@ _MBG_API_ATTR int _MBG_API mbg_set_time( MBG_DEV_HANDLE dh, const PCPS_STIME *p * when the device was synchronized the last time to its time source, * e.g. the DCF77 signal, the GPS satellites, or similar. * - * The macro ::_pcps_has_sync_time checks whether + * The API call ::mbg_chk_dev_has_sync_time checks whether * this call is supported by a device. * * <b>Note:</b> If that information is not available on the device, @@ -4971,6 +4975,7 @@ _MBG_API_ATTR int _MBG_API mbg_set_time( MBG_DEV_HANDLE dh, const PCPS_STIME *p * * @return ::MBG_SUCCESS on success, else one of the @ref MBG_ERROR_CODES. * + * @see ::mbg_chk_dev_has_sync_time * @see ::mbg_get_time */ _MBG_API_ATTR int _MBG_API mbg_get_sync_time( MBG_DEV_HANDLE dh, PCPS_TIME *p ) @@ -5106,7 +5111,7 @@ _MBG_API_ATTR int _MBG_API mbg_set_event_time( MBG_DEV_HANDLE dh, const PCPS_TIM * API function ::mbg_get_serial_settings should be used instead * which fully supports the capabilities of current devices. * - * The macro ::_pcps_has_serial checks whether + * The API call ::mbg_chk_dev_has_serial checks whether * this call is supported by a device. * * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device. @@ -5135,7 +5140,7 @@ _MBG_API_ATTR int _MBG_API mbg_get_serial( MBG_DEV_HANDLE dh, PCPS_SERIAL *p ) * API function ::mbg_save_serial_settings should be used instead * which fully supports the capabilities of current devices. * - * The macro ::_pcps_has_serial checks whether + * The API call ::mbg_chk_dev_has_serial checks whether * this call is supported by a device. * * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device. @@ -5516,7 +5521,7 @@ _MBG_API_ATTR int _MBG_API mbg_set_irig_rx_settings( MBG_DEV_HANDLE dh, const IR * @brief Read all IRIG input configuration information from a device. * * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device. - * @param[in] pdev Pointer to the ::PCPS_DEV structure of the device. TODO Make this obsolete! + * @param[in] p_obs Obsolete pointer kept for compatibility, should be @a NULL. * @param[in] p_irig_info Pointer to a ::IRIG_SETTINGS structure to be read. * @param[in] p_ref_offs Pointer to a ::MBG_REF_OFFS structure to be read. * @param[in] p_opt_info Pointer to a ::MBG_OPT_SETTINGS structure to be read. @@ -5529,24 +5534,37 @@ _MBG_API_ATTR int _MBG_API mbg_set_irig_rx_settings( MBG_DEV_HANDLE dh, const IR * @see ::mbg_set_opt_settings */ _MBG_API_ATTR int _MBG_API mbg_get_all_irig_rx_info( MBG_DEV_HANDLE dh, - const PCPS_DEV *pdev, + const void *p_obs, IRIG_INFO *p_irig_info, MBG_REF_OFFS *p_ref_offs, MBG_OPT_INFO *p_opt_info ) { - int rc; + int rc = mbg_chk_dev_is_tcr( dh ); - if ( !_pcps_is_irig_rx( pdev ) ) - return MBG_ERR_NOT_SUPP_BY_DEV; + if ( mbg_rc_is_error( rc ) ) + goto out; + + (void) p_obs; // Avoid warning "never used". rc = mbg_get_irig_rx_info( dh, p_irig_info ); - if ( mbg_rc_is_success( rc ) && _pcps_has_ref_offs( pdev ) ) - rc = mbg_get_ref_offs( dh, p_ref_offs ); + if ( mbg_rc_is_success( rc ) ) + { + rc = mbg_chk_dev_has_ref_offs( dh ); - if ( mbg_rc_is_success( rc ) && _pcps_has_opt_flags( pdev ) ) - rc = mbg_get_opt_info( dh, p_opt_info ); + if ( mbg_rc_is_success( rc ) ) + rc = mbg_get_ref_offs( dh, p_ref_offs ); + } + if ( mbg_rc_is_success( rc ) ) + { + rc = mbg_chk_dev_has_opt_flags( dh ); + + if ( mbg_rc_is_success( rc ) ) + rc = mbg_get_opt_info( dh, p_opt_info ); + } + +out: return rc; } // mbg_get_all_irig_rx_info @@ -5563,7 +5581,7 @@ _MBG_API_ATTR int _MBG_API mbg_get_all_irig_rx_info( MBG_DEV_HANDLE dh, * the possible settings supported by the IRIG input. * * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device. - * @param[in] pdev Pointer to the ::PCPS_DEV structure of the device. TODO Make this obsolete! + * @param[in] p_obs Obsolete pointer kept for compatibility, should be @a NULL. * @param[out] p_irig_settings Pointer to a ::IRIG_SETTINGS structure to be written. * @param[out] p_ref_offs Pointer to a ::MBG_REF_OFFS structure to be written. * @param[out] p_opt_settings Pointer to a ::MBG_OPT_SETTINGS structure to be written. @@ -5576,24 +5594,37 @@ _MBG_API_ATTR int _MBG_API mbg_get_all_irig_rx_info( MBG_DEV_HANDLE dh, * @see ::mbg_set_opt_settings */ _MBG_API_ATTR int _MBG_API mbg_save_all_irig_rx_settings( MBG_DEV_HANDLE dh, - const PCPS_DEV *pdev, + const void *p_obs, const IRIG_SETTINGS *p_irig_settings, const MBG_REF_OFFS *p_ref_offs, const MBG_OPT_SETTINGS *p_opt_settings ) { - int rc; + int rc = mbg_chk_dev_has_irig_tx( dh ); - if ( !_pcps_is_irig_rx( pdev ) ) - return MBG_ERR_NOT_SUPP_BY_DEV; + if ( mbg_rc_is_error( rc ) ) + goto out; + + (void) p_obs; // Avoid warning "never used". rc = mbg_set_irig_rx_settings( dh, p_irig_settings ); - if ( mbg_rc_is_success( rc ) && _pcps_has_ref_offs( pdev ) ) - rc = mbg_set_ref_offs( dh, p_ref_offs ); + if ( mbg_rc_is_success( rc ) ) + { + rc = mbg_chk_dev_has_ref_offs( dh ); - if ( mbg_rc_is_success( rc ) && _pcps_has_opt_flags( pdev ) ) - rc = mbg_set_opt_settings( dh, p_opt_settings ); + if ( mbg_rc_is_success( rc ) ) + rc = mbg_set_ref_offs( dh, p_ref_offs ); + } + if ( mbg_rc_is_success( rc ) ) + { + rc = mbg_chk_dev_has_opt_flags( dh ); + + if ( mbg_rc_is_success( rc ) ) + rc = mbg_set_opt_settings( dh, p_opt_settings ); + } + +out: return rc; } // mbg_save_all_irig_rx_settings @@ -6798,6 +6829,8 @@ _MBG_API_ATTR int _MBG_API mbg_setup_receiver_info( MBG_DEV_HANDLE dh, { int rc; + (void) p_obs; // Avoid warning "never used". + // If the device supports the receiver_info structure, // read it from the device, otherwise set up some default // values depending on the device type. @@ -9223,6 +9256,8 @@ _MBG_API_ATTR int _MBG_API mbg_thread_sleep_interruptible( MBG_THREAD_INFO *p_ti { #if defined( MBG_TGT_LINUX ) // TODO Maybe generally for POSIX? + (void) p_ti; // Avoid warning "never used". + if ( usleep( sleep_ms * 1000 ) == 0 ) return MBG_SUCCESS; diff --git a/mbglib/common/mbgdevio.h b/mbglib/common/mbgdevio.h index a4a6515..dc5e472 100644 --- a/mbglib/common/mbgdevio.h +++ b/mbglib/common/mbgdevio.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgdevio.h 1.63 2022/06/02 08:20:23 martin.burnicki REL_M $ + * $Id: mbgdevio.h 1.64 2022/08/23 16:20:24 martin.burnicki REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,8 @@ * * ----------------------------------------------------------------------- * $Log: mbgdevio.h $ + * Revision 1.64 2022/08/23 16:20:24 martin.burnicki + * Updated function prototypes. * Revision 1.63 2022/06/02 08:20:23 martin.burnicki * Updated version code to 3.14. * Revision 1.62 2022/05/31 14:00:10Z martin.burnicki @@ -3206,7 +3208,7 @@ typedef int _MBG_API MBG_CHK_SUPP_FNC( MBG_DEV_HANDLE dh ); * when the device was synchronized the last time to its time source, * e.g. the DCF77 signal, the GPS satellites, or similar. * - * The macro ::_pcps_has_sync_time checks whether + * The API call ::mbg_chk_dev_has_sync_time checks whether * this call is supported by a device. * * <b>Note:</b> If that information is not available on the device, @@ -3221,6 +3223,7 @@ typedef int _MBG_API MBG_CHK_SUPP_FNC( MBG_DEV_HANDLE dh ); * * @return ::MBG_SUCCESS on success, else one of the @ref MBG_ERROR_CODES. * + * @see ::mbg_chk_dev_has_sync_time * @see ::mbg_get_time */ _MBG_API_ATTR int _MBG_API mbg_get_sync_time( MBG_DEV_HANDLE dh, PCPS_TIME *p ) ; @@ -3294,7 +3297,7 @@ typedef int _MBG_API MBG_CHK_SUPP_FNC( MBG_DEV_HANDLE dh ); * API function ::mbg_get_serial_settings should be used instead * which fully supports the capabilities of current devices. * - * The macro ::_pcps_has_serial checks whether + * The API call ::mbg_chk_dev_has_serial checks whether * this call is supported by a device. * * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device. @@ -3313,7 +3316,7 @@ typedef int _MBG_API MBG_CHK_SUPP_FNC( MBG_DEV_HANDLE dh ); * API function ::mbg_save_serial_settings should be used instead * which fully supports the capabilities of current devices. * - * The macro ::_pcps_has_serial checks whether + * The API call ::mbg_chk_dev_has_serial checks whether * this call is supported by a device. * * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device. @@ -3556,7 +3559,7 @@ typedef int _MBG_API MBG_CHK_SUPP_FNC( MBG_DEV_HANDLE dh ); * @brief Read all IRIG input configuration information from a device. * * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device. - * @param[in] pdev Pointer to the ::PCPS_DEV structure of the device. TODO Make this obsolete! + * @param[in] p_obs Obsolete pointer kept for compatibility, should be @a NULL. * @param[in] p_irig_info Pointer to a ::IRIG_SETTINGS structure to be read. * @param[in] p_ref_offs Pointer to a ::MBG_REF_OFFS structure to be read. * @param[in] p_opt_info Pointer to a ::MBG_OPT_SETTINGS structure to be read. @@ -3568,7 +3571,7 @@ typedef int _MBG_API MBG_CHK_SUPP_FNC( MBG_DEV_HANDLE dh ); * @see ::mbg_set_ref_offs * @see ::mbg_set_opt_settings */ - _MBG_API_ATTR int _MBG_API mbg_get_all_irig_rx_info( MBG_DEV_HANDLE dh, const PCPS_DEV *pdev, IRIG_INFO *p_irig_info, MBG_REF_OFFS *p_ref_offs, MBG_OPT_INFO *p_opt_info ) ; + _MBG_API_ATTR int _MBG_API mbg_get_all_irig_rx_info( MBG_DEV_HANDLE dh, const void *p_obs, IRIG_INFO *p_irig_info, MBG_REF_OFFS *p_ref_offs, MBG_OPT_INFO *p_opt_info ) ; /** * @brief Write all IRIG input configuration settings to a device. @@ -3579,7 +3582,7 @@ typedef int _MBG_API MBG_CHK_SUPP_FNC( MBG_DEV_HANDLE dh ); * the possible settings supported by the IRIG input. * * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device. - * @param[in] pdev Pointer to the ::PCPS_DEV structure of the device. TODO Make this obsolete! + * @param[in] p_obs Obsolete pointer kept for compatibility, should be @a NULL. * @param[out] p_irig_settings Pointer to a ::IRIG_SETTINGS structure to be written. * @param[out] p_ref_offs Pointer to a ::MBG_REF_OFFS structure to be written. * @param[out] p_opt_settings Pointer to a ::MBG_OPT_SETTINGS structure to be written. @@ -3591,7 +3594,7 @@ typedef int _MBG_API MBG_CHK_SUPP_FNC( MBG_DEV_HANDLE dh ); * @see ::mbg_set_ref_offs * @see ::mbg_set_opt_settings */ - _MBG_API_ATTR int _MBG_API mbg_save_all_irig_rx_settings( MBG_DEV_HANDLE dh, const PCPS_DEV *pdev, const IRIG_SETTINGS *p_irig_settings, const MBG_REF_OFFS *p_ref_offs, const MBG_OPT_SETTINGS *p_opt_settings ) ; + _MBG_API_ATTR int _MBG_API mbg_save_all_irig_rx_settings( MBG_DEV_HANDLE dh, const void *p_obs, const IRIG_SETTINGS *p_irig_settings, const MBG_REF_OFFS *p_ref_offs, const MBG_OPT_SETTINGS *p_opt_settings ) ; /** * @brief Read the control function bits received from an incoming IRIG signal. |