annotate simtool/opldump.c @ 71:a008f7a4bddf

doc/User-oriented-commands: dump-lnd documented
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 15 Feb 2021 04:57:51 +0000
parents 2d1679c7975b
children 440a4582d2a5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
54
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements the opl-dump command,
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * a companion command to pnn-dump.
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "simresp.h"
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "curfile.h"
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "file_id.h"
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 static void
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 dump_record(recno)
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 unsigned recno;
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 {
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 char ascbuf[8];
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 decode_plmn_3bytes(sim_resp_data, ascbuf, 0);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 printf("#%u: %s %02X%02X-%02X%02X %u\n", recno, ascbuf,
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 sim_resp_data[3], sim_resp_data[4], sim_resp_data[5],
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 sim_resp_data[6], sim_resp_data[7]);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 }
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 cmd_opl_dump()
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 {
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 int rc;
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 unsigned recno;
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 rc = select_op(DF_GSM);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 if (rc < 0)
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 return(rc);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 rc = select_op(EF_OPL);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 if (rc < 0)
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 return(rc);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 rc = parse_ef_select_response();
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 if (rc < 0)
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 return(rc);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 if (curfile_structure != 0x01) {
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 fprintf(stderr, "error: EF_OPL is not linear fixed\n");
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 return(-1);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 }
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (curfile_record_len < 8) {
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 fprintf(stderr,
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 "error: EF_OPL record length is less than the spec minimum of 8 bytes\n");
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 return(-1);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 }
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 for (recno = 1; recno <= curfile_record_count; recno++) {
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 rc = readrec_op(recno, 0x04, curfile_record_len);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 if (rc < 0)
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 return(rc);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 if (check_simresp_all_blank())
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 continue;
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 dump_record(recno);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 }
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 return(0);
2d1679c7975b fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 }