altos: Send "metrum" telemetry packets for TeleMetrum v3.0 boards
[fw/altos] / src / kernel / ao_telemetry.c
1 /*
2  * Copyright © 2011 Keth Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 #include "ao.h"
20 #include "ao_log.h"
21 #include "ao_product.h"
22
23 static uint16_t ao_telemetry_interval;
24
25 #if HAS_RADIO_RATE
26 static uint16_t ao_telemetry_desired_interval;
27 #endif
28
29 /* TeleMetrum v1.0 just doesn't have enough space to
30  * manage the more complicated telemetry scheduling, so
31  * it loses the ability to disable telem/rdf separately
32  */
33
34 #if defined(TELEMETRUM_V_1_0)
35 #define SIMPLIFY
36 #endif
37
38 #ifdef SIMPLIFY
39 #define ao_telemetry_time time
40 #define RDF_SPACE       
41 #else
42 #define RDF_SPACE       
43 static uint16_t ao_telemetry_time;
44 #endif
45
46 #if HAS_RDF
47 static RDF_SPACE uint8_t ao_rdf = 0;
48 static RDF_SPACE uint16_t ao_rdf_time;
49 #endif
50
51 #if HAS_APRS
52 static uint16_t ao_aprs_time;
53
54 #include <ao_aprs.h>
55 #endif
56
57 #if defined(TELEMEGA)
58 #define AO_SEND_MEGA    1
59 #endif
60
61 #if defined (TELEMETRUM_V_2_0) || defined (TELEMETRUM_V_3_0)
62 #define AO_SEND_METRUM  1
63 #endif
64
65 #if defined(TELEMETRUM_V_0_1) || defined(TELEMETRUM_V_0_2) || defined(TELEMETRUM_V_1_0) || defined(TELEMETRUM_V_1_1) || defined(TELEBALLOON_V_1_1) || defined(TELEMETRUM_V_1_2)
66 #define AO_TELEMETRY_SENSOR     AO_TELEMETRY_SENSOR_TELEMETRUM
67 #endif
68
69 #if defined(TELEMINI_V_1_0)
70 #define AO_TELEMETRY_SENSOR     AO_TELEMETRY_SENSOR_TELEMINI
71 #endif
72
73 #if defined(TELENANO_V_0_1)
74 #define AO_TELEMETRY_SENSOR     AO_TELEMETRY_SENSOR_TELENANO
75 #endif
76
77 static union ao_telemetry_all   telemetry;
78
79 static void
80 ao_telemetry_send(void)
81 {
82         ao_radio_send(&telemetry, sizeof (telemetry));
83         ao_delay(1);
84 }
85
86 #if defined AO_TELEMETRY_SENSOR
87 /* Send sensor packet */
88 static void
89 ao_send_sensor(void)
90 {
91                 struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
92
93         telemetry.generic.tick = packet->tick;
94         telemetry.generic.type = AO_TELEMETRY_SENSOR;
95
96         telemetry.sensor.state = ao_flight_state;
97 #if HAS_ACCEL
98         telemetry.sensor.accel = packet->adc.accel;
99 #else
100         telemetry.sensor.accel = 0;
101 #endif
102         telemetry.sensor.pres = ao_data_pres(packet);
103         telemetry.sensor.temp = packet->adc.temp;
104         telemetry.sensor.v_batt = packet->adc.v_batt;
105 #if HAS_IGNITE
106         telemetry.sensor.sense_d = packet->adc.sense_d;
107         telemetry.sensor.sense_m = packet->adc.sense_m;
108 #else
109         telemetry.sensor.sense_d = 0;
110         telemetry.sensor.sense_m = 0;
111 #endif
112
113         telemetry.sensor.acceleration = ao_accel;
114         telemetry.sensor.speed = ao_speed;
115         telemetry.sensor.height = ao_height;
116
117         telemetry.sensor.ground_pres = ao_ground_pres;
118 #if HAS_ACCEL
119         telemetry.sensor.ground_accel = ao_ground_accel;
120         telemetry.sensor.accel_plus_g = ao_config.accel_plus_g;
121         telemetry.sensor.accel_minus_g = ao_config.accel_minus_g;
122 #else
123         telemetry.sensor.ground_accel = 0;
124         telemetry.sensor.accel_plus_g = 0;
125         telemetry.sensor.accel_minus_g = 0;
126 #endif
127
128         ao_telemetry_send();
129 }
130 #endif
131
132
133 #ifdef AO_SEND_MEGA
134
135 /* Send mega sensor packet */
136 static void
137 ao_send_mega_sensor(void)
138 {
139                 struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
140
141         telemetry.generic.tick = packet->tick;
142         telemetry.generic.type = AO_TELEMETRY_MEGA_SENSOR;
143
144 #if HAS_MPU6000 || HAS_MPU9250
145         telemetry.mega_sensor.orient = ao_sample_orient;
146 #endif
147         telemetry.mega_sensor.accel = ao_data_accel(packet);
148         telemetry.mega_sensor.pres = ao_data_pres(packet);
149         telemetry.mega_sensor.temp = ao_data_temp(packet);
150
151 #if HAS_MPU6000
152         telemetry.mega_sensor.accel_x = packet->mpu6000.accel_x;
153         telemetry.mega_sensor.accel_y = packet->mpu6000.accel_y;
154         telemetry.mega_sensor.accel_z = packet->mpu6000.accel_z;
155
156         telemetry.mega_sensor.gyro_x = packet->mpu6000.gyro_x;
157         telemetry.mega_sensor.gyro_y = packet->mpu6000.gyro_y;
158         telemetry.mega_sensor.gyro_z = packet->mpu6000.gyro_z;
159 #endif
160
161 #if HAS_HMC5883
162         telemetry.mega_sensor.mag_x = packet->hmc5883.x;
163         telemetry.mega_sensor.mag_z = packet->hmc5883.z;
164         telemetry.mega_sensor.mag_y = packet->hmc5883.y;
165 #endif
166
167 #if HAS_MPU9250
168         telemetry.mega_sensor.accel_x = packet->mpu9250.accel_x;
169         telemetry.mega_sensor.accel_y = packet->mpu9250.accel_y;
170         telemetry.mega_sensor.accel_z = packet->mpu9250.accel_z;
171
172         telemetry.mega_sensor.gyro_x = packet->mpu9250.gyro_x;
173         telemetry.mega_sensor.gyro_y = packet->mpu9250.gyro_y;
174         telemetry.mega_sensor.gyro_z = packet->mpu9250.gyro_z;
175
176         telemetry.mega_sensor.mag_x = packet->mpu9250.mag_x;
177         telemetry.mega_sensor.mag_z = packet->mpu9250.mag_z;
178         telemetry.mega_sensor.mag_y = packet->mpu9250.mag_y;
179 #endif
180
181         ao_telemetry_send();
182 }
183
184 static int8_t ao_telemetry_mega_data_max;
185 static int8_t ao_telemetry_mega_data_cur;
186
187 /* Send mega data packet */
188 static void
189 ao_send_mega_data(void)
190 {
191         if (--ao_telemetry_mega_data_cur <= 0) {
192                         struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
193                 uint8_t i;
194
195                 telemetry.generic.tick = packet->tick;
196                 telemetry.generic.type = AO_TELEMETRY_MEGA_DATA;
197
198                 telemetry.mega_data.state = ao_flight_state;
199                 telemetry.mega_data.v_batt = packet->adc.v_batt;
200                 telemetry.mega_data.v_pyro = packet->adc.v_pbatt;
201
202                 /* ADC range is 0-4095, so shift by four to save the high 8 bits */
203                 for (i = 0; i < AO_ADC_NUM_SENSE; i++)
204                         telemetry.mega_data.sense[i] = packet->adc.sense[i] >> 4;
205
206                 telemetry.mega_data.ground_pres = ao_ground_pres;
207                 telemetry.mega_data.ground_accel = ao_ground_accel;
208                 telemetry.mega_data.accel_plus_g = ao_config.accel_plus_g;
209                 telemetry.mega_data.accel_minus_g = ao_config.accel_minus_g;
210
211                 telemetry.mega_data.acceleration = ao_accel;
212                 telemetry.mega_data.speed = ao_speed;
213                 telemetry.mega_data.height = ao_height;
214
215                 ao_telemetry_mega_data_cur = ao_telemetry_mega_data_max;
216                 ao_telemetry_send();
217         }
218 }
219 #endif /* AO_SEND_MEGA */
220
221 #ifdef AO_SEND_METRUM
222 /* Send telemetrum sensor packet */
223 static void
224 ao_send_metrum_sensor(void)
225 {
226                 struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
227
228         telemetry.generic.tick = packet->tick;
229         telemetry.generic.type = AO_TELEMETRY_METRUM_SENSOR;
230
231         telemetry.metrum_sensor.state = ao_flight_state;
232 #if HAS_ACCEL
233         telemetry.metrum_sensor.accel = ao_data_accel(packet);
234 #endif
235         telemetry.metrum_sensor.pres = ao_data_pres(packet);
236         telemetry.metrum_sensor.temp = ao_data_temp(packet);
237
238         telemetry.metrum_sensor.acceleration = ao_accel;
239         telemetry.metrum_sensor.speed = ao_speed;
240         telemetry.metrum_sensor.height = ao_height;
241
242         telemetry.metrum_sensor.v_batt = packet->adc.v_batt;
243         telemetry.metrum_sensor.sense_a = packet->adc.sense_a;
244         telemetry.metrum_sensor.sense_m = packet->adc.sense_m;
245
246         ao_telemetry_send();
247 }
248
249 static int8_t ao_telemetry_metrum_data_max;
250 static int8_t ao_telemetry_metrum_data_cur;
251
252 /* Send telemetrum data packet */
253 static void
254 ao_send_metrum_data(void)
255 {
256         if (--ao_telemetry_metrum_data_cur <= 0) {
257                         struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
258
259                 telemetry.generic.tick = packet->tick;
260                 telemetry.generic.type = AO_TELEMETRY_METRUM_DATA;
261
262                 telemetry.metrum_data.ground_pres = ao_ground_pres;
263 #if HAS_ACCEL
264                 telemetry.metrum_data.ground_accel = ao_ground_accel;
265                 telemetry.metrum_data.accel_plus_g = ao_config.accel_plus_g;
266                 telemetry.metrum_data.accel_minus_g = ao_config.accel_minus_g;
267 #else
268                 telemetry.metrum_data.ground_accel = 1;
269                 telemetry.metrum_data.accel_plus_g = 0;
270                 telemetry.metrum_data.accel_minus_g = 2;
271 #endif
272
273                 ao_telemetry_metrum_data_cur = ao_telemetry_metrum_data_max;
274                 ao_telemetry_send();
275         }
276 }
277 #endif /* AO_SEND_METRUM */
278
279 #ifdef AO_SEND_MINI
280
281 static void
282 ao_send_mini(void)
283 {
284                 struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
285
286         telemetry.generic.tick = packet->tick;
287         telemetry.generic.type = AO_SEND_MINI;
288
289         telemetry.mini.state = ao_flight_state;
290
291         telemetry.mini.v_batt = packet->adc.v_batt;
292         telemetry.mini.sense_a = packet->adc.sense_a;
293         telemetry.mini.sense_m = packet->adc.sense_m;
294
295         telemetry.mini.pres = ao_data_pres(packet);
296         telemetry.mini.temp = ao_data_temp(packet);
297
298         telemetry.mini.acceleration = ao_accel;
299         telemetry.mini.speed = ao_speed;
300         telemetry.mini.height = ao_height;
301
302         telemetry.mini.ground_pres = ao_ground_pres;
303
304         ao_telemetry_send();
305 }
306
307 #endif /* AO_SEND_MINI */
308
309 static int8_t ao_telemetry_config_max;
310 static int8_t ao_telemetry_config_cur;
311 static uint16_t ao_telemetry_flight_number;
312
313 #ifndef ao_telemetry_battery_convert
314 #define ao_telemetry_battery_convert(a) (a)
315 #endif
316
317 static void
318 ao_send_configuration(void)
319 {
320         if (--ao_telemetry_config_cur <= 0)
321         {
322                 telemetry.generic.type = AO_TELEMETRY_CONFIGURATION;
323                 telemetry.configuration.device = AO_idProduct_NUMBER;
324                 telemetry.configuration.flight = ao_telemetry_flight_number;
325                 telemetry.configuration.config_major = AO_CONFIG_MAJOR;
326                 telemetry.configuration.config_minor = AO_CONFIG_MINOR;
327 #if AO_idProduct_NUMBER == 0x25 && HAS_ADC
328                 /* TeleGPS gets battery voltage instead of apogee delay */
329                 telemetry.configuration.apogee_delay = ao_telemetry_battery_convert(ao_data_ring[ao_data_ring_prev(ao_data_head)].adc.v_batt);
330 #else
331                 telemetry.configuration.apogee_delay = ao_config.apogee_delay;
332                 telemetry.configuration.main_deploy = ao_config.main_deploy;
333 #endif
334
335                 telemetry.configuration.flight_log_max = ao_config.flight_log_max >> 10;
336                 memcpy (telemetry.configuration.callsign,
337                         ao_config.callsign,
338                         AO_MAX_CALLSIGN);
339                 memcpy (telemetry.configuration.version,
340                         ao_version,
341                         AO_MAX_VERSION);
342                 ao_telemetry_config_cur = ao_telemetry_config_max;
343                 ao_telemetry_send();
344         }
345 }
346
347 #if HAS_GPS
348
349 static int8_t ao_telemetry_gps_max;
350 static int8_t ao_telemetry_loc_cur;
351 static int8_t ao_telemetry_sat_cur;
352
353 static inline void *
354 telemetry_bits(struct ao_telemetry_location *l)
355 {
356         return ((uint8_t *) l) + offsetof(struct ao_telemetry_location, flags);
357 }
358
359 static inline int
360 telemetry_size(void)
361 {
362         return sizeof(struct ao_telemetry_location) - offsetof(struct ao_telemetry_location, flags);
363 }
364
365 static void
366 ao_send_location(void)
367 {
368         if (--ao_telemetry_loc_cur <= 0)
369         {
370                 telemetry.generic.type = AO_TELEMETRY_LOCATION;
371                 ao_mutex_get(&ao_gps_mutex);
372                 memcpy(telemetry_bits(&telemetry.location),
373                        telemetry_bits(&ao_gps_data),
374                        telemetry_size());
375                 telemetry.location.tick = ao_gps_tick;
376                 ao_mutex_put(&ao_gps_mutex);
377                 ao_telemetry_loc_cur = ao_telemetry_gps_max;
378                 ao_telemetry_send();
379         }
380 }
381
382 static void
383 ao_send_satellite(void)
384 {
385         if (--ao_telemetry_sat_cur <= 0)
386         {
387                 telemetry.generic.type = AO_TELEMETRY_SATELLITE;
388                 ao_mutex_get(&ao_gps_mutex);
389                 telemetry.satellite.channels = ao_gps_tracking_data.channels;
390                 memcpy(&telemetry.satellite.sats,
391                        &ao_gps_tracking_data.sats,
392                        AO_MAX_GPS_TRACKING * sizeof (struct ao_telemetry_satellite_info));
393                 ao_mutex_put(&ao_gps_mutex);
394                 ao_telemetry_sat_cur = ao_telemetry_gps_max;
395                 ao_telemetry_send();
396         }
397 }
398 #endif
399
400 #if HAS_COMPANION
401
402 static int8_t ao_telemetry_companion_max;
403 static int8_t ao_telemetry_companion_cur;
404
405 static void
406 ao_send_companion(void)
407 {
408         if (--ao_telemetry_companion_cur <= 0) {
409                 telemetry.generic.type = AO_TELEMETRY_COMPANION;
410                 telemetry.companion.board_id = ao_companion_setup.board_id;
411                 telemetry.companion.update_period = ao_companion_setup.update_period;
412                 telemetry.companion.channels = ao_companion_setup.channels;
413                 ao_mutex_get(&ao_companion_mutex);
414                 memcpy(&telemetry.companion.companion_data,
415                        ao_companion_data,
416                        ao_companion_setup.channels * 2);
417                 ao_mutex_put(&ao_companion_mutex);
418                 ao_telemetry_companion_cur = ao_telemetry_companion_max;
419                 ao_telemetry_send();
420         }
421 }
422 #endif
423
424 static void
425 ao_telemetry(void)
426 {
427         uint16_t        time;
428         int16_t         delay;
429
430         ao_config_get();
431         if (!ao_config.radio_enable)
432                 ao_exit();
433         while (!ao_flight_number)
434                 ao_sleep(&ao_flight_number);
435
436         ao_telemetry_flight_number = ao_flight_number;
437 #if HAS_LOG
438         if (ao_log_full())
439                 ao_telemetry_flight_number = 0;
440 #endif
441         telemetry.generic.serial = ao_serial_number;
442         for (;;) {
443                 while (ao_telemetry_interval == 0)
444                         ao_sleep(&telemetry);
445                 time = ao_time();
446                 ao_telemetry_time = time;
447 #if HAS_RDF
448                 ao_rdf_time = time;
449 #endif
450 #if HAS_APRS
451                 ao_aprs_time = time;
452 #endif
453                 while (ao_telemetry_interval) {
454                         time = ao_time() + AO_SEC_TO_TICKS(100);
455 #ifndef SIMPLIFY
456                         if (!(ao_config.radio_enable & AO_RADIO_DISABLE_TELEMETRY))
457 #endif
458                         {
459 #ifndef SIMPLIFY
460                                 if ( (int16_t) (ao_time() - ao_telemetry_time) >= 0)
461 #endif
462                                 {
463                                         ao_telemetry_time = ao_time() + ao_telemetry_interval;
464 # ifdef AO_SEND_MEGA
465                                         ao_send_mega_sensor();
466                                         ao_send_mega_data();
467 # endif
468 # ifdef AO_SEND_METRUM
469                                         ao_send_metrum_sensor();
470                                         ao_send_metrum_data();
471 # endif
472 # ifdef AO_SEND_MINI
473                                         ao_send_mini();
474 # endif
475 # ifdef AO_TELEMETRY_SENSOR
476                                         ao_send_sensor();
477 # endif
478 #if HAS_COMPANION
479                                         if (ao_companion_running)
480                                                 ao_send_companion();
481 #endif
482 #if HAS_GPS
483                                         ao_send_location();
484                                         ao_send_satellite();
485 #endif
486                                         ao_send_configuration();
487                                 }
488 #ifndef SIMPLIFY
489                                 time = ao_telemetry_time;
490 #endif
491                         }
492 #if HAS_RDF
493                         if (ao_rdf
494 #ifndef SIMPLIFY
495                             && !(ao_config.radio_enable & AO_RADIO_DISABLE_RDF)
496 #endif
497                                 )
498                         {
499                                 if ((int16_t) (ao_time() - ao_rdf_time) >= 0) {
500 #if HAS_IGNITE_REPORT
501                                         uint8_t c;
502 #endif
503                                         ao_rdf_time = ao_time() + AO_RDF_INTERVAL_TICKS;
504 #if HAS_IGNITE_REPORT
505                                         if (ao_flight_state == ao_flight_pad && (c = ao_report_igniter()))
506                                                 ao_radio_continuity(c);
507                                         else
508 #endif
509                                                 ao_radio_rdf();
510                                 }
511 #ifndef SIMPLIFY
512                                 if ((int16_t) (time - ao_rdf_time) > 0)
513                                         time = ao_rdf_time;
514 #endif
515                         }
516 #endif /* HAS_RDF */
517 #if HAS_APRS
518                         if (ao_config.aprs_interval != 0) {
519                                 if ((int16_t) (ao_time() - ao_aprs_time) >= 0) {
520                                         ao_aprs_time = ao_time() + AO_SEC_TO_TICKS(ao_config.aprs_interval);
521                                         ao_aprs_send();
522                                 }
523                                 if ((int16_t) (time - ao_aprs_time) > 0)
524                                         time = ao_aprs_time;
525                         }
526 #endif /* HAS_APRS */
527                         delay = time - ao_time();
528                         if (delay > 0) {
529                                 ao_sleep_for(&telemetry, delay);
530                         }
531                 }
532         }
533 }
534
535 #if HAS_RADIO_RATE
536 void
537 ao_telemetry_reset_interval(void)
538 {
539         ao_telemetry_set_interval(ao_telemetry_desired_interval);
540 }
541 #endif
542
543 void
544 ao_telemetry_set_interval(uint16_t interval)
545 {
546         int8_t  cur = 0;
547
548 #if HAS_RADIO_RATE
549         /* Limit max telemetry rate based on available radio bandwidth.
550          */
551         static const uint16_t min_interval[] = {
552                 /* [AO_RADIO_RATE_38400] = */ AO_MS_TO_TICKS(100),
553                 /* [AO_RADIO_RATE_9600] = */ AO_MS_TO_TICKS(500),
554                 /* [AO_RADIO_RATE_2400] = */ AO_MS_TO_TICKS(1000)
555         };
556
557         ao_telemetry_desired_interval = interval;
558         if (interval && interval < min_interval[ao_config.radio_rate])
559                 interval = min_interval[ao_config.radio_rate];
560 #endif
561         ao_telemetry_interval = interval;
562 #if AO_SEND_MEGA
563         if (interval > 1)
564                 ao_telemetry_mega_data_max = 1;
565         else
566                 ao_telemetry_mega_data_max = 2;
567         if (ao_telemetry_mega_data_max > cur)
568                 cur++;
569         ao_telemetry_mega_data_cur = cur;
570 #endif
571 #if AO_SEND_METRUM
572         ao_telemetry_metrum_data_max = AO_SEC_TO_TICKS(1) / interval;
573         if (ao_telemetry_metrum_data_max > cur)
574                 cur++;
575         ao_telemetry_metrum_data_cur = cur;
576 #endif
577
578 #if HAS_COMPANION
579         if (!ao_companion_setup.update_period)
580                 ao_companion_setup.update_period = AO_SEC_TO_TICKS(1);
581         ao_telemetry_companion_max = ao_companion_setup.update_period / interval;
582         if (ao_telemetry_companion_max > cur)
583                 cur++;
584         ao_telemetry_companion_cur = cur;
585 #endif
586
587 #if HAS_GPS
588         ao_telemetry_gps_max = AO_SEC_TO_TICKS(1) / interval;
589         if (ao_telemetry_gps_max > cur)
590                 cur++;
591         ao_telemetry_loc_cur = cur;
592         if (ao_telemetry_gps_max > cur)
593                 cur++;
594         ao_telemetry_sat_cur = cur;
595 #endif
596
597         ao_telemetry_config_max = AO_SEC_TO_TICKS(5) / interval;
598         if (ao_telemetry_config_max > cur)
599                 cur++;
600         ao_telemetry_config_cur = cur;
601
602 #ifndef SIMPLIFY
603         ao_telemetry_time = 
604 #if HAS_RDF
605                 ao_rdf_time =
606 #endif
607 #if HAS_APRS
608                 ao_aprs_time =
609 #endif
610                 ao_time();
611 #endif
612         ao_wakeup(&telemetry);
613 }
614
615 #if HAS_RDF
616 void
617 ao_rdf_set(uint8_t rdf)
618 {
619         ao_rdf = rdf;
620         if (rdf == 0)
621                 ao_radio_rdf_abort();
622         else {
623                 ao_rdf_time = ao_time() + AO_RDF_INTERVAL_TICKS;
624         }
625 }
626 #endif
627
628 struct ao_task  ao_telemetry_task;
629
630 void
631 ao_telemetry_init()
632 {
633         ao_add_task(&ao_telemetry_task, ao_telemetry, "telemetry");
634 }