aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--o3000.c28
-rw-r--r--o3000_upgrade.c7
2 files changed, 19 insertions, 16 deletions
diff --git a/o3000.c b/o3000.c
index 37c0ab7..12c5ff1 100644
--- a/o3000.c
+++ b/o3000.c
@@ -869,23 +869,25 @@ int __stdcall o3000_send_xml(int id, const char *msg, int msg_len) {
}
/**
- * Check whether all connections are closed.
+ * Get the number of open sessions.
*
- * @return 0 if all sessions are closed, error code otherwise defined at @ref o3000.h.
+ * @return number of open sessions
*/
-static int check_sessions(void) {
- int i;
+static int get_num_open_sessions(void) {
+ int i, num_sessions = 0;
for(i = 0; i < MAX_NUM_SESSION; i++) {
if(session_table[i] != NULL) {
- break;
+ num_sessions ++;
}
}
- if (i < MAX_NUM_SESSION) {
- printf("%s: Session %d is still open.\n", __func__, i);
- return O3000_ERROR_SESSION_STILL_OPEN;
- }
- return 0;
+ return num_sessions;
+
+// if (i < MAX_NUM_SESSION) {
+// printf("%s: Session %d is still open.\n", __func__, i);
+// return O3000_ERROR_SESSION_STILL_OPEN;
+// }
+// return 0;
}
/**
@@ -897,7 +899,7 @@ static int check_sessions(void) {
*/
int __stdcall o3000_firmware_update(unsigned char *data, int data_len) {
- int ret = 0;
+ int ret = 0, num_sessions;
// paranoia checks
if(data == NULL) {
@@ -912,7 +914,9 @@ int __stdcall o3000_firmware_update(unsigned char *data, int data_len) {
}
// checking whether all connections are closed
- if ((ret = check_sessions())) {
+ num_sessions = get_num_open_sessions();
+ if (num_sessions > 0) {
+ ret = O3000_ERROR_SESSION_STILL_OPEN;
printf("%s: Cannot proceed to firmware update: error code: %d.\n", __func__, ret);
return ret;
}
diff --git a/o3000_upgrade.c b/o3000_upgrade.c
index 264afc1..700a280 100644
--- a/o3000_upgrade.c
+++ b/o3000_upgrade.c
@@ -1,6 +1,8 @@
/**
* @file o3000_upgrade.c
* @brief O-3000 firmware upgrade
+* @author Patrick Roth - roth@stettbacher.ch
+* @author Patrick Brunner - brunner@stettbacher.ch
* @author Sophia Papagiannaki - papagiannaki@stettbacher.ch
* @version 0.1
* @date 2020-05-12
@@ -62,9 +64,6 @@ const char* app_ids[] = {
"Camera O-3120", // global shutter, color version
};
-const uint16_t vid = 0x0483;
-const uint16_t pid = 0xA098;
-
static struct cam_usb_t {
struct libusb_context *ctx; // libusb context
struct libusb_device_handle *dev_handle; // the USB device handle
@@ -225,7 +224,7 @@ static enum cam_mode_t usb_open(void)
// If the camera has just performed a reset, it might not be ready yet.
// We try MAX_RETRIES times, before we give up.
while(retries > 0) {
- if((cam_usb.dev_handle = libusb_open_device_with_vid_pid(cam_usb.ctx, vid, pid)) == NULL) {
+ if((cam_usb.dev_handle = libusb_open_device_with_vid_pid(cam_usb.ctx, O3000_VID, O3000_PID)) == NULL) {
printf("retry: %d\n",retries);
retries--;
sleep(1);