comparison simtool/hlread.c @ 103:90eff13a72fd

fc-simtool: implemented alpha field decoding and spn command
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 25 Jan 2021 04:54:47 +0000
parents 597c4e87a1f4
children
comparison
equal deleted inserted replaced
102:29cc5612797a 103:90eff13a72fd
90 decode_reversed_nibbles(sim_resp_data + 1, 8, buf); 90 decode_reversed_nibbles(sim_resp_data + 1, 8, buf);
91 buf[16] = '\0'; 91 buf[16] = '\0';
92 printf("%s parity=%c len=%u\n", buf + 1, buf[0], sim_resp_data[0]); 92 printf("%s parity=%c len=%u\n", buf + 1, buf[0], sim_resp_data[0]);
93 return(0); 93 return(0);
94 } 94 }
95
96 cmd_spn()
97 {
98 int rc;
99 unsigned textlen;
100
101 rc = select_op(DF_GSM);
102 if (rc < 0)
103 return(rc);
104 rc = select_op(EF_SPN);
105 if (rc < 0)
106 return(rc);
107 rc = parse_ef_select_response();
108 if (rc < 0)
109 return(rc);
110 if (curfile_structure != 0x00 || curfile_total_size != 17) {
111 fprintf(stderr, "error: expected transparent EF of 17 bytes\n");
112 return(-1);
113 }
114 rc = readbin_op(0, 17);
115 if (rc < 0)
116 return(rc);
117 printf("Display condition: %02X\n", sim_resp_data[0]);
118 printf("SPN: ");
119 rc = validate_alpha_field(sim_resp_data + 1, 16, &textlen);
120 if (rc >= 0)
121 print_alpha_field(sim_resp_data, textlen, stdout);
122 else
123 printf("malformed alpha field");
124 putchar('\n');
125 return(0);
126 }