mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Import: Update libdivecomputer to the Latest Version.
Update `libdivecomputer` to the latest upstream version. Signed-off-by: Michael Keller <mikeller@042.ch>
This commit is contained in:
		
							parent
							
								
									4642f12e29
								
							
						
					
					
						commit
						f495c4f002
					
				
					 1 changed files with 51 additions and 58 deletions
				
			
		|  | @ -95,11 +95,6 @@ const char *errmsg (dc_status_t rc) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static dc_status_t create_parser(device_data_t *devdata, dc_parser_t **parser) |  | ||||||
| { |  | ||||||
| 	return dc_parser_new(parser, devdata->device); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /**
 | /**
 | ||||||
|  * @brief get_deeper_gasmix Returns the gas mix with the deeper MOD. |  * @brief get_deeper_gasmix Returns the gas mix with the deeper MOD. | ||||||
|  * NOTE: Parameters are passed by value in order to use them as local working |  * NOTE: Parameters are passed by value in order to use them as local working | ||||||
|  | @ -170,14 +165,14 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t | ||||||
| 	clear_cylinder_table(&dive->cylinders); | 	clear_cylinder_table(&dive->cylinders); | ||||||
| 	for (i = 0; i < MAX(ngases, ntanks); i++) { | 	for (i = 0; i < MAX(ngases, ntanks); i++) { | ||||||
| 		cylinder_t cyl = empty_cylinder; | 		cylinder_t cyl = empty_cylinder; | ||||||
|  | 		cyl.cylinder_use = NOT_USED; | ||||||
|  | 
 | ||||||
| 		if (i < ngases) { | 		if (i < ngases) { | ||||||
| 			dc_gasmix_t gasmix = { 0 }; | 			dc_gasmix_t gasmix = { 0 }; | ||||||
| 			int o2, he; | 			int o2, he; | ||||||
| 
 | 
 | ||||||
| 			rc = dc_parser_get_field(parser, DC_FIELD_GASMIX, i, &gasmix); | 			rc = dc_parser_get_field(parser, DC_FIELD_GASMIX, i, &gasmix); | ||||||
| 			if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) | 			if (rc == DC_STATUS_SUCCESS) { | ||||||
| 				return rc; |  | ||||||
| 
 |  | ||||||
| 				o2 = lrint(gasmix.oxygen * 1000); | 				o2 = lrint(gasmix.oxygen * 1000); | ||||||
| 				he = lrint(gasmix.helium * 1000); | 				he = lrint(gasmix.helium * 1000); | ||||||
| 
 | 
 | ||||||
|  | @ -199,16 +194,31 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t | ||||||
| 				cyl.gasmix.o2.permille = o2; | 				cyl.gasmix.o2.permille = o2; | ||||||
| 				cyl.gasmix.he.permille = he; | 				cyl.gasmix.he.permille = he; | ||||||
| 				bottom_gas = get_deeper_gasmix(bottom_gas, cyl.gasmix); | 				bottom_gas = get_deeper_gasmix(bottom_gas, cyl.gasmix); | ||||||
| 		} |  | ||||||
| 
 | 
 | ||||||
| 		if (rc == DC_STATUS_UNSUPPORTED) | 				switch (gasmix.usage) { | ||||||
| 			// Gasmix is inactive
 | 				case DC_USAGE_DILUENT: | ||||||
| 			cyl.cylinder_use = NOT_USED; | 					cyl.cylinder_use = DILUENT; | ||||||
| 		else if (dive->dc.divemode == CCR) | 
 | ||||||
|  | 					break; | ||||||
|  | 				case DC_USAGE_OXYGEN: | ||||||
|  | 					cyl.cylinder_use = OXYGEN; | ||||||
|  | 
 | ||||||
|  | 					break; | ||||||
|  | 				case DC_USAGE_OPEN_CIRCUIT: | ||||||
|  | 					cyl.cylinder_use = OC_GAS; | ||||||
|  | 
 | ||||||
|  | 					break; | ||||||
|  | 				default: | ||||||
|  | 					if (dive->dc.divemode == CCR) | ||||||
| 						cyl.cylinder_use = DILUENT; | 						cyl.cylinder_use = DILUENT; | ||||||
| 					else | 					else | ||||||
| 						cyl.cylinder_use = OC_GAS; | 						cyl.cylinder_use = OC_GAS; | ||||||
| 
 | 
 | ||||||
|  | 					break; | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 		if (i < ntanks) { | 		if (i < ntanks) { | ||||||
| 			// If we've run out of gas mixes, assign this cylinder to bottom
 | 			// If we've run out of gas mixes, assign this cylinder to bottom
 | ||||||
| 			// gas. Note that this can be overridden below if the dive computer
 | 			// gas. Note that this can be overridden below if the dive computer
 | ||||||
|  | @ -222,14 +232,7 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t | ||||||
| 				cyl.type.size.mliter = lrint(tank.volume * 1000); | 				cyl.type.size.mliter = lrint(tank.volume * 1000); | ||||||
| 				cyl.type.workingpressure.mbar = lrint(tank.workpressure * 1000); | 				cyl.type.workingpressure.mbar = lrint(tank.workpressure * 1000); | ||||||
| 
 | 
 | ||||||
| 				cyl.cylinder_use = OC_GAS; | 				if (tank.type & DC_TANKVOLUME_IMPERIAL) { | ||||||
| 				// libdivecomputer treats these as independent, but a tank cannot be used for diluent and O2 at the same time
 |  | ||||||
| 				if (tank.type & DC_TANKINFO_CC_DILUENT) |  | ||||||
| 					cyl.cylinder_use = DILUENT; |  | ||||||
| 				else if (tank.type & DC_TANKINFO_CC_O2) |  | ||||||
| 					cyl.cylinder_use = OXYGEN; |  | ||||||
| 
 |  | ||||||
| 				if (tank.type & DC_TANKINFO_IMPERIAL) { |  | ||||||
| 					if (same_string(devdata->model, "Suunto EON Steel")) { | 					if (same_string(devdata->model, "Suunto EON Steel")) { | ||||||
| 						/* Suunto EON Steele gets this wrong. Badly.
 | 						/* Suunto EON Steele gets this wrong. Badly.
 | ||||||
| 						 * but on the plus side it only supports a few imperial sizes, | 						 * but on the plus side it only supports a few imperial sizes, | ||||||
|  | @ -372,9 +375,10 @@ static void handle_gasmix(struct divecomputer *dc, struct sample *sample, int id | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void | void | ||||||
| sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata) | sample_cb(dc_sample_type_t type, const dc_sample_value_t *pvalue, void *userdata) | ||||||
| { | { | ||||||
| 	static unsigned int nsensor = 0; | 	static unsigned int nsensor = 0; | ||||||
|  | 	dc_sample_value_t value = *pvalue; | ||||||
| 	struct divecomputer *dc = userdata; | 	struct divecomputer *dc = userdata; | ||||||
| 	struct sample *sample; | 	struct sample *sample; | ||||||
| 
 | 
 | ||||||
|  | @ -398,7 +402,7 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata) | ||||||
| 		// Create a new sample.
 | 		// Create a new sample.
 | ||||||
| 		// Mark depth as negative
 | 		// Mark depth as negative
 | ||||||
| 		sample = prepare_sample(dc); | 		sample = prepare_sample(dc); | ||||||
| 		sample->time.seconds = value.time; | 		sample->time.seconds = value.time / 1000; | ||||||
| 		sample->depth.mm = -1; | 		sample->depth.mm = -1; | ||||||
| 		// The current sample gets some sticky values
 | 		// The current sample gets some sticky values
 | ||||||
| 		// that may have been around from before, these
 | 		// that may have been around from before, these
 | ||||||
|  | @ -457,7 +461,7 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata) | ||||||
| 		break; | 		break; | ||||||
| 	case DC_SAMPLE_PPO2: | 	case DC_SAMPLE_PPO2: | ||||||
| 		if (nsensor < MAX_O2_SENSORS) | 		if (nsensor < MAX_O2_SENSORS) | ||||||
| 			sample->o2sensor[nsensor].mbar = lrint(value.ppo2 * 1000); | 			sample->o2sensor[nsensor].mbar = lrint(value.ppo2.value * 1000); | ||||||
| 		else | 		else | ||||||
| 			report_error("%d is more o2 sensors than we can handle", nsensor); | 			report_error("%d is more o2 sensors than we can handle", nsensor); | ||||||
| 		nsensor++; | 		nsensor++; | ||||||
|  | @ -484,6 +488,7 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata) | ||||||
| 			sample->stopdepth.mm = stopdepth = lrint(value.deco.depth * 1000.0); | 			sample->stopdepth.mm = stopdepth = lrint(value.deco.depth * 1000.0); | ||||||
| 			sample->stoptime.seconds = stoptime = value.deco.time; | 			sample->stoptime.seconds = stoptime = value.deco.time; | ||||||
| 		} | 		} | ||||||
|  | 		sample->tts.seconds = value.deco.tts; | ||||||
| 	default: | 	default: | ||||||
| 		break; | 		break; | ||||||
| 	} | 	} | ||||||
|  | @ -833,18 +838,12 @@ static int dive_cb(const unsigned char *data, unsigned int size, | ||||||
| 
 | 
 | ||||||
| 	import_dive_number++; | 	import_dive_number++; | ||||||
| 
 | 
 | ||||||
| 	rc = create_parser(devdata, &parser); | 	rc = dc_parser_new(&parser, devdata->device, data, size); | ||||||
| 	if (rc != DC_STATUS_SUCCESS) { | 	if (rc != DC_STATUS_SUCCESS) { | ||||||
| 		download_error(translate("gettextFromC", "Unable to create parser for %s %s"), devdata->vendor, devdata->product); | 		download_error(translate("gettextFromC", "Unable to create parser for %s %s"), devdata->vendor, devdata->product); | ||||||
| 		return true; | 		return true; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	rc = dc_parser_set_data(parser, data, size); |  | ||||||
| 	if (rc != DC_STATUS_SUCCESS) { |  | ||||||
| 		download_error(translate("gettextFromC", "Error registering the data")); |  | ||||||
| 		goto error_exit; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	dive = alloc_dive(); | 	dive = alloc_dive(); | ||||||
| 
 | 
 | ||||||
| 	// Fill in basic fields
 | 	// Fill in basic fields
 | ||||||
|  | @ -1621,7 +1620,7 @@ dc_status_t libdc_buffer_parser(struct dive *dive, device_data_t *data, unsigned | ||||||
| 	case DC_FAMILY_HW_OSTC: | 	case DC_FAMILY_HW_OSTC: | ||||||
| 	case DC_FAMILY_HW_FROG: | 	case DC_FAMILY_HW_FROG: | ||||||
| 	case DC_FAMILY_HW_OSTC3: | 	case DC_FAMILY_HW_OSTC3: | ||||||
| 		rc = dc_parser_new2(&parser, data->context, data->descriptor, 0, 0); | 		rc = dc_parser_new2(&parser, data->context, data->descriptor, buffer, size); | ||||||
| 		break; | 		break; | ||||||
| 	default: | 	default: | ||||||
| 		report_error("Device type not handled!"); | 		report_error("Device type not handled!"); | ||||||
|  | @ -1632,12 +1631,6 @@ dc_status_t libdc_buffer_parser(struct dive *dive, device_data_t *data, unsigned | ||||||
| 		dc_parser_destroy (parser); | 		dc_parser_destroy (parser); | ||||||
| 		return rc; | 		return rc; | ||||||
| 	} | 	} | ||||||
| 	rc = dc_parser_set_data(parser, buffer, size); |  | ||||||
| 	if (rc != DC_STATUS_SUCCESS) { |  | ||||||
| 		report_error("Error registering the data."); |  | ||||||
| 		dc_parser_destroy (parser); |  | ||||||
| 		return rc; |  | ||||||
| 	} |  | ||||||
| 	// Do not parse Aladin/Memomouse headers as they are fakes
 | 	// Do not parse Aladin/Memomouse headers as they are fakes
 | ||||||
| 	// Do not return on error, we can still parse the samples
 | 	// Do not return on error, we can still parse the samples
 | ||||||
| 	if (dc_descriptor_get_type(data->descriptor) != DC_FAMILY_UWATEC_ALADIN && dc_descriptor_get_type(data->descriptor) != DC_FAMILY_UWATEC_MEMOMOUSE) { | 	if (dc_descriptor_get_type(data->descriptor) != DC_FAMILY_UWATEC_ALADIN && dc_descriptor_get_type(data->descriptor) != DC_FAMILY_UWATEC_MEMOMOUSE) { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue