2
0

v17_tests.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. //#define ADD_MAINS_INTERFERENCE
  2. /*
  3. * SpanDSP - a series of DSP components for telephony
  4. *
  5. * v17_tests.c
  6. *
  7. * Written by Steve Underwood <steveu@coppice.org>
  8. *
  9. * Copyright (C) 2004 Steve Underwood
  10. *
  11. * All rights reserved.
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License version 2, as
  15. * published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25. */
  26. /*! \page v17_tests_page V.17 modem tests
  27. \section v17_tests_page_sec_1 What does it do?
  28. These tests test one way paths, as V.17 is a half-duplex modem. They allow either:
  29. - A V.17 transmit modem to feed a V.17 receive modem through a telephone line
  30. model. BER testing is then used to evaluate performance under various line
  31. conditions. This is effective for testing the basic performance of the
  32. receive modem. It is also the only test mode provided for evaluating the
  33. transmit modem.
  34. - A V.17 receive modem is used to decode V.17 audio, stored in a audio file.
  35. This is good way to evaluate performance with audio recorded from other
  36. models of modem, and with real world problematic telephone lines.
  37. If the appropriate GUI environment exists, the tests are built such that a visual
  38. display of modem status is maintained.
  39. \section v17_tests_page_sec_2 How is it used?
  40. */
  41. #if defined(HAVE_CONFIG_H)
  42. #include "config.h"
  43. #endif
  44. #if defined(HAVE_FL_FL_H) && defined(HAVE_FL_FL_CARTESIAN_H) && defined(HAVE_FL_FL_AUDIO_METER_H)
  45. #define ENABLE_GUI
  46. #endif
  47. #include <stdlib.h>
  48. #include <stdio.h>
  49. #include <fcntl.h>
  50. #include <unistd.h>
  51. #include <string.h>
  52. #include <sndfile.h>
  53. #include <signal.h>
  54. #if defined(HAVE_FENV_H)
  55. #define __USE_GNU
  56. #include <fenv.h>
  57. #endif
  58. #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
  59. #include "spandsp.h"
  60. #include "spandsp-sim.h"
  61. #if defined(ENABLE_GUI)
  62. #include "modem_monitor.h"
  63. #include "line_model_monitor.h"
  64. #endif
  65. #define BLOCK_LEN 160
  66. #define OUT_FILE_NAME "v17.wav"
  67. char *decode_test_file = NULL;
  68. bool use_gui = false;
  69. int symbol_no = 0;
  70. int rx_bits = 0;
  71. int tx_bits = 0;
  72. int test_bps;
  73. bert_state_t bert;
  74. one_way_line_model_state_t *line_model;
  75. #if defined(ENABLE_GUI)
  76. qam_monitor_t *qam_monitor;
  77. #endif
  78. bert_results_t latest_results;
  79. static void reporter(void *user_data, int reason, bert_results_t *results)
  80. {
  81. switch (reason)
  82. {
  83. case BERT_REPORT_REGULAR:
  84. fprintf(stderr, "BERT report regular - %d bits, %d bad bits, %d resyncs\n", results->total_bits, results->bad_bits, results->resyncs);
  85. memcpy(&latest_results, results, sizeof(latest_results));
  86. break;
  87. default:
  88. fprintf(stderr, "BERT report %s\n", bert_event_to_str(reason));
  89. break;
  90. }
  91. }
  92. /*- End of function --------------------------------------------------------*/
  93. static void v17_rx_status(void *user_data, int status)
  94. {
  95. v17_rx_state_t *s;
  96. int i;
  97. int len;
  98. #if defined(SPANDSP_USE_FIXED_POINT)
  99. complexi16_t *coeffs;
  100. #else
  101. complexf_t *coeffs;
  102. #endif
  103. printf("V.17 rx status is %s (%d)\n", signal_status_to_str(status), status);
  104. s = (v17_rx_state_t *) user_data;
  105. switch (status)
  106. {
  107. case SIG_STATUS_TRAINING_SUCCEEDED:
  108. printf("Training succeeded\n");
  109. if ((len = v17_rx_equalizer_state(s, &coeffs)))
  110. {
  111. printf("Equalizer:\n");
  112. for (i = 0; i < len; i++)
  113. #if defined(SPANDSP_USE_FIXED_POINT)
  114. printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V17_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V17_CONSTELLATION_SCALING_FACTOR);
  115. #else
  116. printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
  117. #endif
  118. }
  119. break;
  120. }
  121. }
  122. /*- End of function --------------------------------------------------------*/
  123. static void v17putbit(void *user_data, int bit)
  124. {
  125. if (bit < 0)
  126. {
  127. v17_rx_status(user_data, bit);
  128. return;
  129. }
  130. if (decode_test_file)
  131. printf("Rx bit %d - %d\n", rx_bits++, bit);
  132. else
  133. bert_put_bit(&bert, bit);
  134. }
  135. /*- End of function --------------------------------------------------------*/
  136. static void v17_tx_status(void *user_data, int status)
  137. {
  138. printf("V.17 tx status is %s (%d)\n", signal_status_to_str(status), status);
  139. }
  140. /*- End of function --------------------------------------------------------*/
  141. static int v17getbit(void *user_data)
  142. {
  143. return bert_get_bit(&bert);
  144. }
  145. /*- End of function --------------------------------------------------------*/
  146. #if defined(SPANDSP_USE_FIXED_POINT)
  147. static void qam_report(void *user_data, const complexi16_t *constel, const complexi16_t *target, int symbol)
  148. #else
  149. static void qam_report(void *user_data, const complexf_t *constel, const complexf_t *target, int symbol)
  150. #endif
  151. {
  152. int i;
  153. int len;
  154. #if defined(SPANDSP_USE_FIXED_POINT)
  155. complexi16_t *coeffs;
  156. #else
  157. complexf_t *coeffs;
  158. #endif
  159. complexf_t constel_point;
  160. complexf_t target_point;
  161. float fpower;
  162. v17_rx_state_t *rx;
  163. static float smooth_power = 0.0f;
  164. static int update_interval = 100;
  165. rx = (v17_rx_state_t *) user_data;
  166. if (constel)
  167. {
  168. constel_point.re = constel->re/V17_CONSTELLATION_SCALING_FACTOR;
  169. constel_point.im = constel->im/V17_CONSTELLATION_SCALING_FACTOR;
  170. target_point.re = target->re/V17_CONSTELLATION_SCALING_FACTOR,
  171. target_point.im = target->im/V17_CONSTELLATION_SCALING_FACTOR,
  172. fpower = (constel_point.re - target_point.re)*(constel_point.re - target_point.re)
  173. + (constel_point.im - target_point.im)*(constel_point.im - target_point.im);
  174. smooth_power = 0.95f*smooth_power + 0.05f*fpower;
  175. #if defined(ENABLE_GUI)
  176. if (use_gui)
  177. {
  178. qam_monitor_update_constel(qam_monitor, &constel_point);
  179. qam_monitor_update_carrier_tracking(qam_monitor, v17_rx_carrier_frequency(rx));
  180. qam_monitor_update_symbol_tracking(qam_monitor, v17_rx_symbol_timing_correction(rx));
  181. }
  182. #endif
  183. printf("%8d [%8.4f, %8.4f] [%8.4f, %8.4f] %2x %8.4f %8.4f %9.4f %7.3f %7.4f\n",
  184. symbol_no,
  185. constel_point.re,
  186. constel_point.im,
  187. target_point.re,
  188. target_point.im,
  189. symbol,
  190. fpower,
  191. smooth_power,
  192. v17_rx_carrier_frequency(rx),
  193. v17_rx_signal_power(rx),
  194. v17_rx_symbol_timing_correction(rx));
  195. symbol_no++;
  196. if (--update_interval <= 0)
  197. {
  198. if ((len = v17_rx_equalizer_state(rx, &coeffs)))
  199. {
  200. printf("Equalizer A:\n");
  201. for (i = 0; i < len; i++)
  202. #if defined(SPANDSP_USE_FIXED_POINT)
  203. printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V17_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V17_CONSTELLATION_SCALING_FACTOR);
  204. #else
  205. printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
  206. #endif
  207. #if defined(ENABLE_GUI)
  208. if (use_gui)
  209. {
  210. #if defined(SPANDSP_USE_FIXED_POINT)
  211. qam_monitor_update_int_equalizer(qam_monitor, coeffs, len);
  212. #else
  213. qam_monitor_update_equalizer(qam_monitor, coeffs, len);
  214. #endif
  215. }
  216. #endif
  217. }
  218. update_interval = 100;
  219. }
  220. }
  221. }
  222. /*- End of function --------------------------------------------------------*/
  223. #if defined(HAVE_FENV_H)
  224. static void sigfpe_handler(int sig_num, siginfo_t *info, void *data)
  225. {
  226. switch (sig_num)
  227. {
  228. case SIGFPE:
  229. switch (info->si_code)
  230. {
  231. case FPE_INTDIV:
  232. fprintf(stderr, "integer divide by zero at %p\n", info->si_addr);
  233. break;
  234. case FPE_INTOVF:
  235. fprintf(stderr, "integer overflow at %p\n", info->si_addr);
  236. break;
  237. case FPE_FLTDIV:
  238. fprintf(stderr, "FP divide by zero at %p\n", info->si_addr);
  239. break;
  240. case FPE_FLTOVF:
  241. fprintf(stderr, "FP overflow at %p\n", info->si_addr);
  242. break;
  243. case FPE_FLTUND:
  244. fprintf(stderr, "FP underflow at %p\n", info->si_addr);
  245. break;
  246. case FPE_FLTRES:
  247. fprintf(stderr, "FP inexact result at %p\n", info->si_addr);
  248. break;
  249. case FPE_FLTINV:
  250. fprintf(stderr, "FP invalid operation at %p\n", info->si_addr);
  251. break;
  252. case FPE_FLTSUB:
  253. fprintf(stderr, "subscript out of range at %p\n", info->si_addr);
  254. break;
  255. }
  256. break;
  257. default:
  258. fprintf(stderr, "Unexpected signal %d\n", sig_num);
  259. break;
  260. }
  261. exit(2);
  262. }
  263. /*- End of function --------------------------------------------------------*/
  264. static void fpe_trap_setup(void)
  265. {
  266. struct sigaction trap;
  267. sigemptyset(&trap.sa_mask);
  268. trap.sa_flags = SA_SIGINFO;
  269. trap.sa_sigaction = sigfpe_handler;
  270. sigaction(SIGFPE, &trap, NULL);
  271. //feenableexcept(FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW);
  272. //feenableexcept(FE_ALL_EXCEPT);
  273. feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
  274. }
  275. /*- End of function --------------------------------------------------------*/
  276. #endif
  277. int main(int argc, char *argv[])
  278. {
  279. v17_rx_state_t *rx;
  280. v17_tx_state_t *tx;
  281. bert_results_t bert_results;
  282. int16_t gen_amp[BLOCK_LEN];
  283. int16_t amp[BLOCK_LEN];
  284. SNDFILE *inhandle;
  285. SNDFILE *outhandle;
  286. int outframes;
  287. int samples;
  288. int block_no;
  289. int noise_level;
  290. int signal_level;
  291. int bits_per_test;
  292. int line_model_no;
  293. int channel_codec;
  294. int rbs_pattern;
  295. int opt;
  296. bool tep;
  297. bool log_audio;
  298. logging_state_t *logging;
  299. channel_codec = MUNGE_CODEC_NONE;
  300. rbs_pattern = 0;
  301. test_bps = 14400;
  302. tep = false;
  303. line_model_no = 0;
  304. decode_test_file = NULL;
  305. use_gui = false;
  306. noise_level = -70;
  307. signal_level = -13;
  308. bits_per_test = 50000;
  309. log_audio = false;
  310. while ((opt = getopt(argc, argv, "b:B:c:d:glm:n:r:s:t")) != -1)
  311. {
  312. switch (opt)
  313. {
  314. case 'b':
  315. test_bps = atoi(optarg);
  316. if (test_bps != 14400
  317. &&
  318. test_bps != 12000
  319. &&
  320. test_bps != 9600
  321. &&
  322. test_bps != 7200
  323. &&
  324. test_bps != 4800)
  325. {
  326. /* 4800 is an extension of V.17, to provide full coverage of the V.32bis modes */
  327. fprintf(stderr, "Invalid bit rate specified\n");
  328. exit(2);
  329. }
  330. break;
  331. case 'B':
  332. bits_per_test = atoi(optarg);
  333. break;
  334. case 'c':
  335. channel_codec = atoi(optarg);
  336. break;
  337. case 'd':
  338. decode_test_file = optarg;
  339. break;
  340. case 'g':
  341. #if defined(ENABLE_GUI)
  342. use_gui = true;
  343. #else
  344. fprintf(stderr, "Graphical monitoring not available\n");
  345. exit(2);
  346. #endif
  347. break;
  348. case 'l':
  349. log_audio = true;
  350. break;
  351. case 'm':
  352. line_model_no = atoi(optarg);
  353. break;
  354. case 'n':
  355. noise_level = atoi(optarg);
  356. break;
  357. case 'r':
  358. rbs_pattern = atoi(optarg);
  359. break;
  360. case 's':
  361. signal_level = atoi(optarg);
  362. break;
  363. case 't':
  364. tep = true;
  365. break;
  366. default:
  367. //usage();
  368. exit(2);
  369. break;
  370. }
  371. }
  372. inhandle = NULL;
  373. outhandle = NULL;
  374. #if defined(HAVE_FENV_H)
  375. fpe_trap_setup();
  376. #endif
  377. if (log_audio)
  378. {
  379. if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
  380. {
  381. fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
  382. exit(2);
  383. }
  384. }
  385. if (decode_test_file)
  386. {
  387. /* We will decode the audio from a file. */
  388. tx = NULL;
  389. if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
  390. {
  391. fprintf(stderr, " Cannot open audio file '%s'\n", decode_test_file);
  392. exit(2);
  393. }
  394. }
  395. else
  396. {
  397. /* We will generate V.17 audio, and add some noise to it. */
  398. tx = v17_tx_init(NULL, test_bps, tep, v17getbit, NULL);
  399. logging = v17_tx_get_logging_state(tx);
  400. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  401. span_log_set_tag(logging, "V.17-tx");
  402. v17_tx_power(tx, signal_level);
  403. v17_tx_set_modem_status_handler(tx, v17_tx_status, (void *) tx);
  404. #if defined(SPANDSP_EXPOSE_INTERNAL_STRUCTURES)
  405. /* Move the carrier off a bit */
  406. tx->carrier_phase_rate = dds_phase_ratef(1792.0f);
  407. tx->carrier_phase = 0x40000000;
  408. #endif
  409. bert_init(&bert, bits_per_test, BERT_PATTERN_ITU_O152_11, test_bps, 20);
  410. bert_set_report(&bert, 10000, reporter, NULL);
  411. if ((line_model = one_way_line_model_init(line_model_no, (float) noise_level, channel_codec, rbs_pattern)) == NULL)
  412. {
  413. fprintf(stderr, " Failed to create line model\n");
  414. exit(2);
  415. }
  416. one_way_line_model_set_dc(line_model, 0.0f);
  417. #if defined(ADD_MAINS_INTERFERENCE)
  418. one_way_line_model_set_mains_pickup(line_model, 50, -40.0f);
  419. #endif
  420. }
  421. rx = v17_rx_init(NULL, test_bps, v17putbit, NULL);
  422. logging = v17_rx_get_logging_state(rx);
  423. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  424. span_log_set_tag(logging, "V.17-rx");
  425. v17_rx_set_modem_status_handler(rx, v17_rx_status, (void *) rx);
  426. v17_rx_set_qam_report_handler(rx, qam_report, (void *) rx);
  427. #if defined(ENABLE_GUI)
  428. if (use_gui)
  429. {
  430. qam_monitor = qam_monitor_init(10.0f, V17_CONSTELLATION_SCALING_FACTOR, NULL);
  431. if (!decode_test_file)
  432. {
  433. start_line_model_monitor(129);
  434. line_model_monitor_line_model_update(line_model->near_filter, line_model->near_filter_len);
  435. }
  436. }
  437. #endif
  438. memset(&latest_results, 0, sizeof(latest_results));
  439. for (block_no = 0; block_no < 100000000; block_no++)
  440. {
  441. if (decode_test_file)
  442. {
  443. samples = sf_readf_short(inhandle, amp, BLOCK_LEN);
  444. #if defined(ENABLE_GUI)
  445. if (use_gui)
  446. qam_monitor_update_audio_level(qam_monitor, amp, samples);
  447. #endif
  448. if (samples == 0)
  449. break;
  450. }
  451. else
  452. {
  453. samples = v17_tx(tx, gen_amp, BLOCK_LEN);
  454. #if defined(ENABLE_GUI)
  455. if (use_gui)
  456. qam_monitor_update_audio_level(qam_monitor, gen_amp, samples);
  457. #endif
  458. if (samples == 0)
  459. {
  460. printf("Restarting on zero output\n");
  461. /* Push a little silence through, to ensure all the data bits get out of the buffers */
  462. vec_zeroi16(amp, BLOCK_LEN);
  463. v17_rx(rx, amp, BLOCK_LEN);
  464. /* Note that we might get a few bad bits as the carrier shuts down. */
  465. bert_result(&bert, &bert_results);
  466. fprintf(stderr, "Final result %ddBm0/%ddBm0, %d bits, %d bad bits, %d resyncs\n", signal_level, noise_level, bert_results.total_bits, bert_results.bad_bits, bert_results.resyncs);
  467. fprintf(stderr, "Last report %ddBm0/%ddBm0, %d bits, %d bad bits, %d resyncs\n", signal_level, noise_level, latest_results.total_bits, latest_results.bad_bits, latest_results.resyncs);
  468. /* See if bit errors are appearing yet. Also check we are getting enough bits out of the receiver. The last regular report
  469. should be error free, though the final report will generally contain bits errors as the carrier was dying. The total
  470. number of bits out of the receiver should be at least the number we sent. Also, since BERT sync should have occurred
  471. rapidly at the start of transmission, the last report should have occurred at not much less than the total number of
  472. bits we sent. */
  473. if (bert_results.total_bits < bits_per_test
  474. ||
  475. latest_results.total_bits < bits_per_test - 100
  476. ||
  477. latest_results.bad_bits != 0)
  478. {
  479. break;
  480. }
  481. memset(&latest_results, 0, sizeof(latest_results));
  482. #if defined(SPANDSP_EXPOSE_INTERNAL_STRUCTURES)
  483. signal_level--;
  484. /* Bump the receiver AGC gain by 1dB, to compensate for the above */
  485. rx->agc_scaling_save *= 1.122f;
  486. #endif
  487. v17_tx_restart(tx, test_bps, tep, true);
  488. v17_tx_power(tx, signal_level);
  489. v17_rx_restart(rx, test_bps, true);
  490. //rx.eq_put_step = rand()%(192*10/3);
  491. bert_init(&bert, bits_per_test, BERT_PATTERN_ITU_O152_11, test_bps, 20);
  492. bert_set_report(&bert, 10000, reporter, NULL);
  493. one_way_line_model_free(line_model);
  494. if ((line_model = one_way_line_model_init(line_model_no, (float) noise_level, channel_codec, 0)) == NULL)
  495. {
  496. fprintf(stderr, " Failed to create line model\n");
  497. exit(2);
  498. }
  499. }
  500. if (log_audio)
  501. {
  502. outframes = sf_writef_short(outhandle, gen_amp, samples);
  503. if (outframes != samples)
  504. {
  505. fprintf(stderr, " Error writing audio file\n");
  506. exit(2);
  507. }
  508. }
  509. one_way_line_model(line_model, amp, gen_amp, samples);
  510. }
  511. #if defined(ENABLE_GUI)
  512. if (use_gui && !decode_test_file)
  513. line_model_monitor_line_spectrum_update(amp, samples);
  514. #endif
  515. v17_rx(rx, amp, samples);
  516. }
  517. if (!decode_test_file)
  518. {
  519. bert_result(&bert, &bert_results);
  520. fprintf(stderr, "At completion:\n");
  521. fprintf(stderr, "Final result %ddBm0/%ddBm0, %d bits, %d bad bits, %d resyncs\n", signal_level, noise_level, bert_results.total_bits, bert_results.bad_bits, bert_results.resyncs);
  522. fprintf(stderr, "Last report %ddBm0/%ddBm0, %d bits, %d bad bits, %d resyncs\n", signal_level, noise_level, latest_results.total_bits, latest_results.bad_bits, latest_results.resyncs);
  523. one_way_line_model_free(line_model);
  524. if (signal_level > -43)
  525. {
  526. printf("Tests failed.\n");
  527. exit(2);
  528. }
  529. printf("Tests passed.\n");
  530. }
  531. v17_rx_free(rx);
  532. if (tx)
  533. v17_tx_free(tx);
  534. #if defined(ENABLE_GUI)
  535. if (use_gui)
  536. qam_wait_to_end(qam_monitor);
  537. #endif
  538. if (decode_test_file)
  539. {
  540. if (sf_close_telephony(inhandle))
  541. {
  542. fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
  543. exit(2);
  544. }
  545. }
  546. if (log_audio)
  547. {
  548. if (sf_close_telephony(outhandle))
  549. {
  550. fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
  551. exit(2);
  552. }
  553. }
  554. return 0;
  555. }
  556. /*- End of function --------------------------------------------------------*/
  557. /*- End of file ------------------------------------------------------------*/