@@ -64,6 +64,7 @@ function parseOIF411(xdata, pressure){
6464 // Not an OIF411 (shouldn't get here)
6565 return { } ;
6666 }
67+
6768 _output = { 'xdata_instrument' : 'OIF411' } ;
6869
6970 // Instrument number is common to all XDATA types.
@@ -136,6 +137,60 @@ function parseOIF411(xdata, pressure){
136137 }
137138}
138139
140+ function parseCFH ( xdata ) {
141+ // Attempt to parse an XDATA string from an CFH Cryogenic Frostpoint Hygrometer
142+ // Returns an object with parameters to be added to the sondes telemetry.
143+ //
144+ // References:
145+ // https://eprints.lib.hokudai.ac.jp/dspace/bitstream/2115/72249/1/GRUAN-TD-5_MeiseiRadiosondes_v1_20180221.pdf
146+ //
147+ // Sample data: 0802E21FFD85C8CE078A0193 (length = 24 characters)
148+
149+ // Cast to string if not already
150+ xdata = String ( xdata ) ;
151+
152+ // Run some checks over the input
153+ if ( xdata . length != 24 ) {
154+ // Invalid CFH dataset
155+ return { } ;
156+ }
157+
158+ if ( xdata . substr ( 0 , 2 ) !== '08' ) {
159+ // Not an CFH (shouldn't get here)
160+ return { } ;
161+ }
162+
163+ _output = { 'xdata_instrument' : 'CFH' } ;
164+
165+ // Instrument number is common to all XDATA types.
166+ _output [ 'cfh_instrument_number' ] = parseInt ( xdata . substr ( 2 , 2 ) , 16 ) ;
167+
168+ // Mirror temperature
169+ _mirror_temperature = parseInt ( xdata . substr ( 4 , 6 ) , 16 ) ;
170+ if ( ( _mirror_temperature & 0x80000 ) > 0 ) {
171+ _mirror_temperature = _mirror_temperature - 0x1000000 ;
172+ }
173+ _mirror_temperature = _mirror_temperature * 0.00001 ; // Degrees C
174+ _output [ 'cfh_mirror_temperature' ] = Math . round ( _mirror_temperature * 100000 ) / 100000 ; // 5 DP
175+
176+ // Optics voltage
177+ _optics_voltage = parseInt ( xdata . substr ( 10 , 6 ) , 16 ) * 0.000001 ; // Volts
178+ _output [ 'cfh_optics_voltage' ] = Math . round ( _optics_voltage * 1000000 ) / 1000000 ; // 6 DP
179+
180+ // Optics temperature
181+ _optics_temperature = parseInt ( xdata . substr ( 16 , 4 ) , 16 ) * 0.01 ; // Degrees C
182+ if ( ( _optics_temperature & 0x8000 ) > 0 ) {
183+ _optics_temperature = _optics_temperature - 0x10000 ;
184+ }
185+ _output [ 'cfh_optics_temperature' ] = Math . round ( _optics_temperature * 100 ) / 100 ; // 2 DP
186+
187+ // CFH battery
188+ _battery = parseInt ( xdata . substr ( 20 , 4 ) , 16 ) * 0.01 ; // Volts
189+ _output [ 'cfh_battery' ] = Math . round ( _battery * 100 ) / 100 ; // 2 DP
190+
191+ return _output
192+ }
193+
139194function parseXDATA ( data , pressure ) {
140195 // Accept an XDATA string, or multiple XDATA entries, delimited by '#'
141196 // Attempt to parse each one, and return an object
@@ -144,6 +199,7 @@ function parseXDATA(data, pressure){
144199 // "0501R20234850000006EI"
145200 // "0501034F02CA08B06700#800261FCA6F80012F6F40A75"
146201 // "800262358C080012FE6C0A70#0501035902BA08908400"
202+ // "0802AC83D88AB61107A30175"
147203
148204 // Split apart any contatenated xdata.
149205 if ( data . includes ( '#' ) ) {
@@ -163,14 +219,17 @@ function parseXDATA(data, pressure){
163219
164220 if ( _instrument === '01' ) {
165221 // V7
222+ // 0102 time=1001 cnt=0 rpm=0
223+ // 0102 time=1001 cnt=7 rpm=419
166224 _output = { 'xdata_instrument' : 'V7' } ;
167225 } else if ( _instrument === '05' ) {
168226 // OIF411
169227 _xdata_temp = parseOIF411 ( _current_xdata , pressure ) ;
170228 _output = Object . assign ( _output , _xdata_temp ) ;
171229 } else if ( _instrument === '08' ) {
172230 // CFH
173- _output = { 'xdata_instrument' : 'CFH' } ;
231+ _xdata_temp = parseCFH ( _current_xdata ) ;
232+ _output = Object . assign ( _output , _xdata_temp ) ;
174233 } else if ( _instrument === '10' ) {
175234 // FPH
176235 _output = { 'xdata_instrument' : 'FPH' } ;
@@ -188,6 +247,10 @@ function parseXDATA(data, pressure){
188247 _output = { 'xdata_instrument' : 'OPC' } ;
189248 } else if ( _instrument === '3C' ) {
190249 // PCFH
250+ // 3c010000184b4b5754
251+ // 3c0103ce7b58647a98748befff
252+ // 3c010148719fff8e54b9af627e249fe0
253+ // 3c01028d696fff8db4b7865980cdbbb3
191254 _output = { 'xdata_instrument' : 'PCFH' } ;
192255 } else if ( _instrument === '3D' ) {
193256 // FLASH-B
0 commit comments