mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Fix stupid packing error on Windows
I guess no one has ever tried to import Uemis dive data under Windows. The glib-2 libraries for Windows (at least the ones that are part of the mingw package, but my guess is this is true for all of them), force the whole program to be compiled with Windows packing rules for structures. That broke the structure we use for decoding Uemis binary data. This commit changes the data structure to no longer use unaligned 16bit values but instead two 8bit values and assemble them in the actual code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									43f122f9ff
								
							
						
					
					
						commit
						cb48db275e
					
				
					 2 changed files with 10 additions and 3 deletions
				
			
		
							
								
								
									
										3
									
								
								uemis.c
									
										
									
									
									
								
							
							
						
						
									
										3
									
								
								uemis.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -229,7 +229,8 @@ void uemis_parse_divelog_binary(char *base64, void *datap) {
 | 
			
		|||
		sample->depth.mm = pressure_to_depth(u_sample->water_pressure);
 | 
			
		||||
		sample->temperature.mkelvin = (u_sample->dive_temperature * 100) + 273150;
 | 
			
		||||
		sample->cylinderindex = u_sample->active_tank;
 | 
			
		||||
		sample->cylinderpressure.mbar= u_sample->tank_pressure * 10;
 | 
			
		||||
		sample->cylinderpressure.mbar =
 | 
			
		||||
			(u_sample->tank_pressure_high * 256 + u_sample->tank_pressure_low) * 10;
 | 
			
		||||
		uemis_event(dive, sample, u_sample);
 | 
			
		||||
		finish_sample(dive);
 | 
			
		||||
		i += 0x25;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										10
									
								
								uemis.h
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								uemis.h
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -24,8 +24,14 @@ typedef struct {
 | 
			
		|||
	uint16_t	hold_depth;
 | 
			
		||||
	uint16_t	hold_time;
 | 
			
		||||
	uint8_t		active_tank;
 | 
			
		||||
	uint16_t	tank_pressure;		// (in cbar)
 | 
			
		||||
	uint16_t	consumption;		// (units unclear)
 | 
			
		||||
	// bloody glib, when compiled for Windows, forces the whole program to use
 | 
			
		||||
	// the Windows packing rules. So to avoid problems on Windows (and since
 | 
			
		||||
	// only tank_pressure is currently used and that exactly once) I give in and
 | 
			
		||||
	// make this silly low byte / high byte 8bit entries
 | 
			
		||||
	uint8_t		tank_pressure_low;	// (in cbar)
 | 
			
		||||
	uint8_t		tank_pressure_high;
 | 
			
		||||
	uint8_t		consumption_low;	// (units unclear)
 | 
			
		||||
	uint8_t		consumption_high;
 | 
			
		||||
	uint8_t		rgt;			// (remaining gas time in minutes)
 | 
			
		||||
	uint8_t		cns;
 | 
			
		||||
	uint8_t		flags[8];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue