Hi there, Unfortunately I could not reproduce the problem because I don't have a Petrel device but using the call stack from Rick Walsh I figure out why he receives a SEGV. Apparently the return check of *dc_serial_native_open* method from *shearwater_common_open* was not correct (my mistake :-) ). The first patch attached should fix the issue. It should be applied on Subsurface-branch from libdivecomputer branch.
Also I created two patches which should improve the Subsurface UX. The scope is to save the user's choice about Bluetooth download mode option from the last dive computer download session. In this way, the user doesn't need to open the Bth selection dialog to choose a dive computer device if it is the same as the one from his last session. Claudiu
From 5f8ff48325b598ec0fea1cf341611ea2072398c3 Mon Sep 17 00:00:00 2001 From: Claudiu Olteanu <[email protected]> Date: Mon, 7 Sep 2015 00:54:31 +0300 Subject: [PATCH] Fix dc_serial_native_open return check for Shearwater family The dc_serial_native_open method doesn't return -1 on failures. The failure errors can be DC_STATUS_INVALIDARGS, DC_STATUS_NOMEMORY, DC_STATUS_IO. Therefore we should check if the returned value is equal to DC_STATUS_SUCCESS and pass it further. Signed-off-by: Claudiu Olteanu <[email protected]> --- src/shearwater_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shearwater_common.c b/src/shearwater_common.c index 0b05e53..801fce6 100644 --- a/src/shearwater_common.c +++ b/src/shearwater_common.c @@ -43,9 +43,9 @@ shearwater_common_open (shearwater_common_device_t *device, dc_context_t *contex { // Open the device. int rc = dc_serial_native_open (&device->serial, context, name); - if (rc == -1) { + if (rc != DC_STATUS_SUCCESS) { ERROR (context, "Failed to open the serial port."); - return DC_STATUS_IO; + return rc; } // Set the serial communication protocol (115200 8N1). -- 2.1.4
From 68cfaebdd6d1f78a28642c2b0722ca81e71b6de1 Mon Sep 17 00:00:00 2001 From: Claudiu Olteanu <[email protected]> Date: Sun, 6 Sep 2015 23:59:28 +0300 Subject: [PATCH 1/2] Save Bluetooth download mode settings Save the dive computer download mode flag. In this way, if the user used Bluetooth mode to download its dives on his last session he doesn't need to open the Bth selection dialog if he wants to use the same device. Signed-off-by: Claudiu Olteanu <[email protected]> --- display.h | 2 +- divecomputer.cpp | 11 +++++++++++ helpers.h | 1 + qt-ui/downloadfromdivecomputer.cpp | 5 +++-- qt-ui/mainwindow.cpp | 1 + 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/display.h b/display.h index 3ce0d4f..59dd97e 100644 --- a/display.h +++ b/display.h @@ -53,7 +53,7 @@ int enumerate_devices(device_callback_t callback, void *userdata, int dc_type); extern const char *default_dive_computer_vendor; extern const char *default_dive_computer_product; extern const char *default_dive_computer_device; - +extern int default_dive_computer_download_mode; #define AMB_PERCENTAGE 50.0 #ifdef __cplusplus diff --git a/divecomputer.cpp b/divecomputer.cpp index ac43bd0..b45b74a 100644 --- a/divecomputer.cpp +++ b/divecomputer.cpp @@ -6,6 +6,7 @@ const char *default_dive_computer_vendor; const char *default_dive_computer_product; const char *default_dive_computer_device; +int default_dive_computer_download_mode; DiveComputerList dcList; DiveComputerList::DiveComputerList() @@ -172,6 +173,16 @@ void set_default_dive_computer_device(const char *name) s.endGroup(); } +void set_default_dive_computer_download_mode(int download_mode) +{ + QSettings s; + + default_dive_computer_download_mode = download_mode; + s.beginGroup("DiveComputer"); + s.setValue("dive_computer_download_mode", download_mode); + s.endGroup(); +} + extern "C" void set_dc_nickname(struct dive *dive) { if (!dive) diff --git a/helpers.h b/helpers.h index 47dccb9..6c5c31c 100644 --- a/helpers.h +++ b/helpers.h @@ -25,6 +25,7 @@ QString get_pressure_string(pressure_t pressure, bool showunit = false); QString get_pressure_unit(); void set_default_dive_computer(const char *vendor, const char *product); void set_default_dive_computer_device(const char *name); +void set_default_dive_computer_download_mode(int downloadMode); QString getSubsurfaceDataPath(QString folderToFind); extern const QString get_dc_nickname(const char *model, uint32_t deviceid); int gettimezoneoffset(timestamp_t when = 0); diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index 92f2455..63866d4 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -102,6 +102,7 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) : #if defined(BT_SUPPORT) ui.bluetoothMode->setText(tr("Choose Bluetooth download mode")); + ui.bluetoothMode->setChecked(default_dive_computer_download_mode == DC_TRANSPORT_BLUETOOTH); btDeviceSelectionDialog = 0; ui.chooseBluetoothDevice->setEnabled(ui.bluetoothMode->isChecked()); connect(ui.bluetoothMode, SIGNAL(stateChanged(int)), this, SLOT(enableBluetoothMode(int))); @@ -321,7 +322,7 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked() data.product = strdup(ui.product->currentText().toUtf8().data()); #if defined(BT_SUPPORT) data.bluetooth_mode = ui.bluetoothMode->isChecked(); - if (data.bluetooth_mode) { + if (data.bluetooth_mode && btDeviceSelectionDialog != NULL) { // Get the selected device address data.devname = strdup(btDeviceSelectionDialog->getSelectedDeviceAddress().toUtf8().data()); } else @@ -346,7 +347,7 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked() data.deviceid = data.diveid = 0; set_default_dive_computer(data.vendor, data.product); set_default_dive_computer_device(data.devname); - + set_default_dive_computer_download_mode(ui.bluetoothMode->isChecked() ? DC_TRANSPORT_BLUETOOTH : DC_TRANSPORT_SERIAL); thread = new DownloadThread(this, &data); connect(thread, SIGNAL(finished()), diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index b19a230..4b186ed 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -1127,6 +1127,7 @@ void MainWindow::readSettings() default_dive_computer_vendor = getSetting(s, "dive_computer_vendor"); default_dive_computer_product = getSetting(s, "dive_computer_product"); default_dive_computer_device = getSetting(s, "dive_computer_device"); + default_dive_computer_download_mode = s.value("dive_computer_download_mode").toInt(); s.endGroup(); QNetworkProxy proxy; proxy.setType(QNetworkProxy::ProxyType(prefs.proxy_type)); -- 2.1.4
From aed863ace8793ed22f7fe1479848671167869a0b Mon Sep 17 00:00:00 2001 From: Claudiu Olteanu <[email protected]> Date: Mon, 7 Sep 2015 00:12:00 +0300 Subject: [PATCH 2/2] Reset the index of the device if the Bth mode is disabled If the Bluetooth download mode was disabled then remove the Bth address from the device or mount point section and reset the index. Signed-off-by: Claudiu Olteanu <[email protected]> --- qt-ui/downloadfromdivecomputer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index 63866d4..f2378d5 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -572,8 +572,11 @@ void DownloadFromDCWidget::bluetoothSelectionDialogIsFinished(int result) void DownloadFromDCWidget::enableBluetoothMode(int state) { ui.chooseBluetoothDevice->setEnabled(state == Qt::Checked); + if (state == Qt::Checked) selectRemoteBluetoothDevice(); + else + ui.device->setCurrentIndex(-1); } #endif -- 2.1.4
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
