[PATCH] Cleanup OSTC debug code

Dirk Hohndel dirk at hohndel.org
Tue Dec 30 06:49:12 PST 2014


On Tue, Dec 30, 2014 at 10:48:42AM +0100, Anton Lundin wrote:
> The old OSTC debug code was a bit ugly. This cleans that up and contains
> all the ugly-ness behind the ifdef.

I'm not sure I understand this patch.

Previously we didn't actually open the device for an OSTC 2N, but only if
DEBUG_OSTC was set. Now we ALWAYS don't open the device for an OSTC 2N,
regardless of the DEBUG_OSTC setting.

If that's the code you wanted, then the commit message doesn't match.

Please clarify

/D


> diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp
> index 2ff3661..26420ac 100644
> --- a/configuredivecomputerthreads.cpp
> +++ b/configuredivecomputerthreads.cpp
> @@ -71,6 +71,16 @@
>  #define hw_ostc_device_clock local_hw_ostc_device_clock
>  #define OSTC_FILE "../OSTC-data-dump.bin"
>  
> +// Fake the open function.
> +static dc_status_t local_dc_device_open(dc_device_t **out, dc_context_t *context, dc_descriptor_t *descriptor, const char *name)
> +{
> +	if (strcmp(dc_descriptor_get_vendor(descriptor), "Heinrichs Weikamp") == 0 &&strcmp(dc_descriptor_get_product(descriptor), "OSTC 2N") == 0)
> +		return DC_STATUS_SUCCESS;
> +	else
> +		return dc_device_open(out, context, descriptor, name);
> +}
> +#define dc_device_open local_dc_device_open
> +
>  static dc_status_t local_hw_ostc_device_eeprom_read(void *ignored, unsigned char bank, unsigned char data[], unsigned int data_size)
>  {
>  	FILE *f;
> @@ -1387,12 +1397,8 @@ void ReadSettingsThread::run()
>  {
>  	bool supported = false;
>  	dc_status_t rc;
> -#ifdef DEBUG_OSTC
> -	if (strcmp(m_data->vendor, "Heinrichs Weikamp") == 0 && strcmp(m_data->product, "OSTC 2N") == 0)
> -		rc = DC_STATUS_SUCCESS;
> -	else
> -#endif
> -		rc = dc_device_open(&m_data->device, m_data->context, m_data->descriptor, m_data->devname);
> +
> +	rc = dc_device_open(&m_data->device, m_data->context, m_data->descriptor, m_data->devname);
>  	if (rc == DC_STATUS_SUCCESS) {
>  		DeviceDetails *m_deviceDetails = new DeviceDetails(0);
>  		switch (dc_device_get_type(m_data->device)) {
> -- 
> 2.1.0
> 
> _______________________________________________
> subsurface mailing list
> subsurface at subsurface-divelog.org
> http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


More information about the subsurface mailing list