summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2022-08-23 19:19:52 +0200
committerMartin Burnicki <martin.burnicki@meinberg.de>2022-08-23 19:19:52 +0200
commit60683008a47e57574dbc992735c71e8ba2972ee9 (patch)
tree84d9fe2f9eb2a9a7a46124250cae886ae14556df
parent3befc6ae7e579d75b242811c499bada17f2e9b13 (diff)
downloadmbgtools-lx-60683008a47e57574dbc992735c71e8ba2972ee9.tar.gz
mbgtools-lx-60683008a47e57574dbc992735c71e8ba2972ee9.zip
Check and fix configuration reported by early TCR180USB versions
The RECEIVER_INFO of those versions claims to provide serial ports with configurable string types, though the firmware doesn't support the API. The probe routine of the kernel driver now adjusts the RECEIVER_INFO, if required, to fix this. For this to work, the user-space API call that retrieves the RECEIVER_INFO now returns the potentially modified instance stored in the kernel driver, rather than reading the structure directly from the device.
-rw-r--r--mbglib/common/macioctl.h18
-rw-r--r--mbglib/common/pcpsdev.h28
-rw-r--r--mbglib/common/pcpsdrvr.c53
3 files changed, 82 insertions, 17 deletions
diff --git a/mbglib/common/macioctl.h b/mbglib/common/macioctl.h
index 98f1ad0..93755ab 100644
--- a/mbglib/common/macioctl.h
+++ b/mbglib/common/macioctl.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: macioctl.h 1.55 2022/06/22 10:40:16 martin.burnicki REL_M $
+ * $Id: macioctl.h 1.56 2022/08/23 15:49:13 martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,6 +11,9 @@
*
* -----------------------------------------------------------------------
* $Log: macioctl.h $
+ * Revision 1.56 2022/08/23 15:49:13 martin.burnicki
+ * Don't always read RECEIVER_INFO from device, instead
+ * return the instance stored in the driver.
* Revision 1.55 2022/06/22 10:40:16 martin.burnicki
* Cleaner text of some error messages.
* Revision 1.54 2022/02/10 13:54:46 martin.burnicki
@@ -1200,13 +1203,12 @@ int ioctl_switch( PCPS_DDEV *pddev, unsigned int ioctl_code,
case IOCTL_GET_GPS_RECEIVER_INFO:
- // FIXME TODO Call common function used by probe routine.
- // Always read the receiver info directly from the device. Never
- // just return a previous copy which has been read earlier since
- // something may just have been changed by a configuration API call.
- _io_read_gps_var_chk( pddev, PC_GPS_RECEIVER_INFO,
- receiver_info, pout,
- _pcps_ddev_has_receiver_info( pddev ) );
+ {
+ // Return the structure read by the kernel driver
+ // and possibly adjusted by the probe function.
+ RECEIVER_INFO *p_ri = _ri_addr( pddev );
+ _iob_to_pout_var( *p_ri, pout );
+ }
break;
diff --git a/mbglib/common/pcpsdev.h b/mbglib/common/pcpsdev.h
index b0e90a5..02a3ed0 100644
--- a/mbglib/common/pcpsdev.h
+++ b/mbglib/common/pcpsdev.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdev.h 1.68 2022/04/27 15:07:26 martin.burnicki REL_M $
+ * $Id: pcpsdev.h 1.69 2022/08/23 16:11:57 martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -17,6 +17,9 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdev.h $
+ * Revision 1.69 2022/08/23 16:11:57 martin.burnicki
+ * Support checking of configuration reported by early TCR180USB versions.
+ * Rearranged some feature check macros.
* Revision 1.68 2022/04/27 15:07:26 martin.burnicki
* Changed the definition of MBG_DEV_NAME in a way that it can now
* take up a name based on RECEIVER_INFO::model_name.
@@ -1053,6 +1056,11 @@ enum PCPS_FEATURE_BITS
(_curr_asic_ver), (_req_asic_ver_major), (_req_asic_ver_minor ) ) \
)
+// Even if a device claims to provide a serial port
+// and associated string types, this firmware version
+// is required to fully support the API:
+#define REV_HAS_SER_PORT_CFG_TCR180USB 0x119
+
// Command PC_GPS_TZDL:
#define REV_HAS_TZDL_TCR180USB 0x118 // Also supported by earlier versions, but faulty.
@@ -1257,8 +1265,8 @@ typedef struct
#define _pcps_has_ucap( _d ) _pcps_has_feature( (_d), PCPS_HAS_UCAP )
#define _pcps_has_irig_tx( _d ) _pcps_has_feature( (_d), PCPS_HAS_IRIG_TX )
-// The macro below determines whether a DCF77 receiver
-// supports a higher baud rate than standard
+// The macro below determines whether a simple old device
+// supports a higher baud rate than standard.
#define _pcps_has_serial_hs( _d ) \
( ( _pcps_type_num( _d ) == PCPS_TYPE_TCR511PEX ) || \
( _pcps_type_num( _d ) == PCPS_TYPE_PEX511 ) || \
@@ -1291,9 +1299,6 @@ typedef struct
#define _pcps_has_ref_offs( _d ) \
_pcps_is_irig_rx( _d )
-#define _pcps_ref_offs_out_of_range( _n ) \
- ( ( (_n) > MBG_REF_OFFS_MAX ) || ( (_n) < -MBG_REF_OFFS_MAX ) )
-
#define _pcps_has_opt_flags( _d ) \
_pcps_is_irig_rx( _d )
@@ -1347,9 +1352,20 @@ typedef struct
_pcps_has_ri_feature( (_p_ri), GPS_HAS_XMRS_MULT_INSTC ) )
//### TODO Should also check GPS_MODEL_HAS_XMR_HOLDOVER_INTV, which is a builtin feature flag only.
+#else
+
+/// Check whether a special feature is supported
+#define _pcps_has_feature( _d, _f ) ( ( (_d)->cfg.features & (_f) ) != 0 )
+
+#define _pcps_has_serial( _d ) _pcps_has_feature( (_d), PCPS_HAS_SERIAL )
+
#endif // _USE_DEV_MACROS
+#define _pcps_ref_offs_out_of_range( _n ) \
+ ( ( (_n) > MBG_REF_OFFS_MAX ) || ( (_n) < -MBG_REF_OFFS_MAX ) )
+
+
// There are some versions of IRIG receivers which ignore the TFOM code
// of an incoming IRIG signal even if an IRIG code has been configured which
// supports this. In this case the devices synchronize to the incoming IRIG
diff --git a/mbglib/common/pcpsdrvr.c b/mbglib/common/pcpsdrvr.c
index 583e6e4..d39fa90 100644
--- a/mbglib/common/pcpsdrvr.c
+++ b/mbglib/common/pcpsdrvr.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdrvr.c 1.77 2022/03/30 15:38:40 martin.burnicki REL_M $
+ * $Id: pcpsdrvr.c 1.78 2022/08/23 15:38:16 martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -64,8 +64,10 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdrvr.c $
+ * Revision 1.78 2022/08/23 15:38:16 martin.burnicki
+ * Check and fix configuration reported by early TCR180USB versions.
* Revision 1.77 2022/03/30 15:38:40 martin.burnicki
- * Use new function setup_default_receiver_info() to set up
+ * Use new function setup_default_receiver_info() to set up
* a RECEIVER_INFO structure for devices that don't provide one,
* so also the device name is copied into the model_name field.
* Improved some error logging and conditional compilation.
@@ -4593,7 +4595,7 @@ out:
*/
void check_receiver_info_and_features( PCPS_DDEV *pddev )
{
- const RECEIVER_INFO *p_ri = _ri_addr( pddev );
+ RECEIVER_INFO *p_ri = _ri_addr( pddev );
int rc;
#if REPORT_CFG && !REPORT_CFG_DETAILS
@@ -4631,6 +4633,51 @@ void check_receiver_info_and_features( PCPS_DDEV *pddev )
// Detect the presence of some optional features at runtime.
check_ri_features( pddev );
+
+ // Do some more plausibility checks.
+ switch ( _pcps_ddev_type_num( pddev ) )
+ {
+ case PCPS_TYPE_TCR180USB:
+ {
+ // There are firmware versions out there claiming that
+ // serial ports are supported where in fact they aren't.
+ // Fix the configuration.
+ PCPS_FW_REV_NUM fw_rev_num = _pcps_ddev_fw_rev_num( pddev );
+
+ if ( fw_rev_num < REV_HAS_SER_PORT_CFG_TCR180USB )
+ {
+ if ( p_ri->n_com_ports > 0 )
+ {
+ #if REPORT_CFG || defined( DEBUG )
+ mbg_kdd_msg( MBG_LOG_WARN, "%s: Changing improper COM ports to 0.",
+ _pcps_ddev_type_name( pddev ) );
+ #endif
+ p_ri->n_com_ports = 0;
+ }
+
+ if ( p_ri->n_str_type > 0 )
+ {
+ #if REPORT_CFG || defined( DEBUG )
+ mbg_kdd_msg( MBG_LOG_WARN, "%s: Changing improper string types to 0.",
+ _pcps_ddev_type_name( pddev ) );
+ #endif
+ p_ri->n_str_type = 0;
+ }
+
+ pddev->dev.cfg.features &= ~PCPS_HAS_SERIAL;
+ }
+ break;
+ }
+
+ } // switch
+
+
+ // If the numbers of ports and string types aren't 0 here,
+ // set the appropriate feature bit.
+ if ( ( p_ri->n_com_ports > 0 ) && ( p_ri->n_str_type > 0 ) )
+ pddev->dev.cfg.features |= PCPS_HAS_SERIAL;
+
+
#if REPORT_CFG
_mbg_kdd_msg_3( REPORT_CFG_LOG_LVL, "%s v%03X initial PCPS features: 0x%08lX",
_pcps_ddev_type_name( pddev ), _pcps_ddev_fw_rev_num( pddev ),