blob: 457e90f080d44489e68fb410c498cbba74a58608 [file] [log] [blame]
Harald Welte61e42ad2009-01-18 19:10:46 +00001/* Siemens BS-11 microBTS configuration tool */
2
3/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
4 * All Rights Reserved
5 *
6 * This software is based on ideas (but not code) of BS11Config
7 * (C) 2009 by Dieter Spaar <spaar@mirider.augusta.de>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 */
24
25#include <unistd.h>
26#include <stdlib.h>
27#include <stdio.h>
28#include <errno.h>
29#include <string.h>
30#include <getopt.h>
31#include <fcntl.h>
Harald Weltef186c462009-01-29 08:45:19 +000032#include <termios.h>
Harald Welte14f09342009-01-29 19:28:38 +000033#include <signal.h>
Harald Welte61e42ad2009-01-18 19:10:46 +000034
35#include <sys/types.h>
36#include <sys/stat.h>
37
38#include <openbsc/gsm_data.h>
39#include <openbsc/abis_nm.h>
40#include <openbsc/msgb.h>
41#include <openbsc/tlv.h>
42#include <openbsc/debug.h>
Harald Welte14f09342009-01-29 19:28:38 +000043#include <openbsc/select.h>
Harald Welte61e42ad2009-01-18 19:10:46 +000044
Harald Welte3b8ba212009-01-29 12:27:58 +000045/* state of our bs11_config application */
46enum bs11cfg_state {
47 STATE_NONE,
48 STATE_LOGON_WAIT,
49 STATE_LOGON_ACK,
50 STATE_SWLOAD,
51};
52static enum bs11cfg_state bs11cfg_state = STATE_NONE;
53
Harald Welte61e42ad2009-01-18 19:10:46 +000054static const u_int8_t obj_li_attr[] = {
55 0xa0, 0x09, 0x00,
56 0xab, 0x00,
57 0xac, 0x00,
58};
59static const u_int8_t obj_bbsig0_attr[] = {
60 0x3d, 0x02, 0x00, 0x00,
61 0x3f, 0x01, 0x00,
62};
63static const u_int8_t obj_pa0_attr[] = {
64 NM_ATT_BS11_TXPWR, 0x01, BS11_TRX_POWER_30mW,
65};
66static const char *trx1_password = "1111111111";
67#define TEI_OML 25
68
Harald Welte3b8ba212009-01-29 12:27:58 +000069static const u_int8_t too_fast[] = { 0x12, 0x80, 0x00, 0x00, 0x02, 0x02 };
70
Harald Welte14f09342009-01-29 19:28:38 +000071struct serial_handle {
72 struct bsc_fd fd;
73 struct llist_head tx_queue;
74
75 struct msgb *rx_msg;
76 unsigned int rxmsg_bytes_missing;
77};
78
79/* FIXME: this needs to go */
80static struct serial_handle _ser_handle, *ser_handle = &_ser_handle;
81
82static int handle_serial_msg(struct msgb *rx_msg);
83
Harald Welte61e42ad2009-01-18 19:10:46 +000084/* create all objects for an initial configuration */
85static int create_objects(struct gsm_bts *bts, int trx1)
86{
Harald Welte623d5312009-01-29 21:14:05 +000087 abis_nm_bs11_factory_logon(bts, 1);
Harald Welte61e42ad2009-01-18 19:10:46 +000088 abis_nm_bs11_create_object(bts, BS11_OBJ_LI, 0, sizeof(obj_li_attr),
89 obj_li_attr);
90 abis_nm_bs11_create_object(bts, BS11_OBJ_GPSU, 0, 0, NULL);
91 abis_nm_bs11_create_object(bts, BS11_OBJ_ALCO, 0, 0, NULL);
Harald Welte623d5312009-01-29 21:14:05 +000092 abis_nm_bs11_create_object(bts, BS11_OBJ_CCLK, 0, 0, NULL);
Harald Welte61e42ad2009-01-18 19:10:46 +000093 abis_nm_bs11_create_object(bts, BS11_OBJ_BBSIG, 0,
94 sizeof(obj_bbsig0_attr), obj_bbsig0_attr);
95 abis_nm_bs11_create_object(bts, BS11_OBJ_PA, 0,
96 sizeof(obj_pa0_attr), obj_pa0_attr);
97 if (trx1) {
98 u_int8_t bbsig1_attr[sizeof(obj_bbsig0_attr)+12];
99 u_int8_t *cur = bbsig1_attr;
100
101 abis_nm_bs11_set_trx1_pw(bts, trx1_password);
102
103 cur = tlv_put(cur, NM_ATT_BS11_PASSWORD, 10,
104 (u_int8_t *)trx1_password);
105 memcpy(cur, obj_bbsig0_attr, sizeof(obj_bbsig0_attr));
106 abis_nm_bs11_create_object(bts, BS11_OBJ_BBSIG, 1,
107 sizeof(bbsig1_attr), bbsig1_attr);
108
109 abis_nm_bs11_create_object(bts, BS11_OBJ_PA, 1,
110 sizeof(obj_pa0_attr), obj_pa0_attr);
111 }
112
113 abis_nm_bs11_create_envaBTSE(bts, 0);
114 abis_nm_bs11_create_envaBTSE(bts, 1);
115 abis_nm_bs11_create_envaBTSE(bts, 2);
116 abis_nm_bs11_create_envaBTSE(bts, 3);
117
118 abis_nm_bs11_conn_oml(bts, 0, 1, 0xff);
119 abis_nm_bs11_set_oml_tei(bts, TEI_OML);
120
121 abis_nm_bs11_set_trx_power(&bts->trx[0], BS11_TRX_POWER_30mW);
122
123 if (trx1)
124 abis_nm_bs11_set_trx_power(&bts->trx[1], BS11_TRX_POWER_30mW);
125
Harald Welte623d5312009-01-29 21:14:05 +0000126 abis_nm_bs11_factory_logon(bts, 0);
Harald Welte61e42ad2009-01-18 19:10:46 +0000127
128 return 0;
129}
130
131static char *serial_port = "/dev/ttyUSB0";
132static char *fname_safety = "BTSBMC76.SWI";
133static char *fname_software = "HS011106.SWL";
Harald Welte623d5312009-01-29 21:14:05 +0000134static int delay_ms = 0;
Harald Welte61e42ad2009-01-18 19:10:46 +0000135static int serial_fd = -1;
136static int have_trx1 = 0;
Harald Welte623d5312009-01-29 21:14:05 +0000137static int win_size = 8;
Harald Welte61e42ad2009-01-18 19:10:46 +0000138static struct gsm_bts *g_bts;
139
140/* adaption layer from GSM 08.59 + 12.21 to RS232 */
141
142#define LAPD_HDR_LEN 10
143
144/* callback from abis_nm */
145int _abis_nm_sendmsg(struct msgb *msg)
146{
Harald Welte14f09342009-01-29 19:28:38 +0000147 struct serial_handle *sh = ser_handle;
Harald Welte61e42ad2009-01-18 19:10:46 +0000148 u_int8_t *lapd;
Harald Welte14f09342009-01-29 19:28:38 +0000149 unsigned int len;
Harald Welte61e42ad2009-01-18 19:10:46 +0000150
151 msg->l2h = msg->data;
152
153 /* prepend LAPD header */
154 lapd = msgb_push(msg, LAPD_HDR_LEN);
155
Harald Welte14f09342009-01-29 19:28:38 +0000156 len = msg->len - 2;
157
158 lapd[0] = (len >> 8) & 0xff;
159 lapd[1] = len & 0xff; /* length of bytes startign at lapd[2] */
Harald Welte61e42ad2009-01-18 19:10:46 +0000160 lapd[2] = 0x00;
161 lapd[3] = 0x07;
162 lapd[4] = 0x01;
163 lapd[5] = 0x3e;
164 lapd[6] = 0x00;
165 lapd[7] = 0x00;
166 lapd[8] = msg->len - 10; /* length of bytes starting at lapd[10] */
167 lapd[9] = lapd[8] ^ 0x38;
168
Harald Welte14f09342009-01-29 19:28:38 +0000169 msgb_enqueue(&sh->tx_queue, msg);
170 sh->fd.when |= BSC_FD_WRITE;
171
172 return 0;
173}
174
175static int handle_ser_write(struct bsc_fd *bfd)
176{
177 struct serial_handle *sh = bfd->data;
178 struct msgb *msg;
179 int written;
180
181 msg = msgb_dequeue(&sh->tx_queue);
182 if (!msg) {
183 bfd->when &= ~BSC_FD_WRITE;
184 return 0;
185 }
186
Harald Welte61e42ad2009-01-18 19:10:46 +0000187 fprintf(stdout, "TX: ");
188 hexdump(msg->data, msg->len);
189
190 /* send over serial line */
191 written = write(serial_fd, msg->data, msg->len);
192 if (written < msg->len) {
193 perror("short write:");
194 msgb_free(msg);
195 return -1;
196 }
197
198 msgb_free(msg);
Harald Welte3b8ba212009-01-29 12:27:58 +0000199 usleep(delay_ms*1000);
Harald Welte61e42ad2009-01-18 19:10:46 +0000200
201 return 0;
202}
203
204#define SERIAL_ALLOC_SIZE 300
205
Harald Welte14f09342009-01-29 19:28:38 +0000206static int handle_ser_read(struct bsc_fd *bfd)
Harald Welte61e42ad2009-01-18 19:10:46 +0000207{
Harald Welte14f09342009-01-29 19:28:38 +0000208 struct serial_handle *sh = bfd->data;
209 struct msgb *msg;
210 int rc = 0;
Harald Welte61e42ad2009-01-18 19:10:46 +0000211
Harald Welte14f09342009-01-29 19:28:38 +0000212 if (!sh->rx_msg) {
213 sh->rx_msg = msgb_alloc(SERIAL_ALLOC_SIZE);
214 sh->rx_msg->l2h = NULL;
215 }
216 msg = sh->rx_msg;
Harald Welte3b8ba212009-01-29 12:27:58 +0000217
Harald Welte61e42ad2009-01-18 19:10:46 +0000218 /* first read two byes to obtain length */
Harald Welte14f09342009-01-29 19:28:38 +0000219 if (msg->len < 2) {
220 rc = read(sh->fd.fd, msg->tail, 2 - msg->len);
Harald Welte61e42ad2009-01-18 19:10:46 +0000221 if (rc < 0) {
Harald Welte14f09342009-01-29 19:28:38 +0000222 perror("ERROR reading from serial port");
Harald Welte61e42ad2009-01-18 19:10:46 +0000223 msgb_free(msg);
Harald Welte14f09342009-01-29 19:28:38 +0000224 return rc;
Harald Welte61e42ad2009-01-18 19:10:46 +0000225 }
226 msgb_put(msg, rc);
Harald Welte61e42ad2009-01-18 19:10:46 +0000227
Harald Welte14f09342009-01-29 19:28:38 +0000228 if (msg->len >= 2) {
229 /* parse LAPD payload length */
230 if (msg->data[0] != 0)
231 fprintf(stderr, "Suspicious header byte 0: 0x%02x\n",
232 msg->data[0]);
Harald Welte61e42ad2009-01-18 19:10:46 +0000233
Harald Welte14f09342009-01-29 19:28:38 +0000234 sh->rxmsg_bytes_missing = msg->data[0] << 8;
235 sh->rxmsg_bytes_missing += msg->data[1];
236
237 if (sh->rxmsg_bytes_missing < LAPD_HDR_LEN -2)
238 fprintf(stderr, "Invalid length in hdr: %u\n",
239 sh->rxmsg_bytes_missing);
240 }
241 } else {
242 /* try to read as many of the missing bytes as are available */
243 rc = read(sh->fd.fd, msg->tail, sh->rxmsg_bytes_missing);
Harald Welte61e42ad2009-01-18 19:10:46 +0000244 if (rc < 0) {
Harald Welte14f09342009-01-29 19:28:38 +0000245 perror("ERROR reading from serial port");
Harald Welte61e42ad2009-01-18 19:10:46 +0000246 msgb_free(msg);
Harald Welte14f09342009-01-29 19:28:38 +0000247 return rc;
Harald Welte61e42ad2009-01-18 19:10:46 +0000248 }
249 msgb_put(msg, rc);
Harald Welte14f09342009-01-29 19:28:38 +0000250 sh->rxmsg_bytes_missing -= rc;
251
252 if (sh->rxmsg_bytes_missing == 0) {
253 /* we have one complete message now */
254 sh->rx_msg = NULL;
255
256 if (msg->len > LAPD_HDR_LEN)
257 msg->l2h = msg->data + LAPD_HDR_LEN;
258
259 fprintf(stdout, "RX: ");
260 hexdump(msg->data, msg->len);
261 rc = handle_serial_msg(msg);
262 }
Harald Welte61e42ad2009-01-18 19:10:46 +0000263 }
264
Harald Welte14f09342009-01-29 19:28:38 +0000265 return rc;
266}
Harald Welte61e42ad2009-01-18 19:10:46 +0000267
Harald Welte14f09342009-01-29 19:28:38 +0000268static int serial_fd_cb(struct bsc_fd *bfd, unsigned int what)
269{
270 int rc = 0;
Harald Welte61e42ad2009-01-18 19:10:46 +0000271
Harald Welte14f09342009-01-29 19:28:38 +0000272 if (what & BSC_FD_READ)
273 rc = handle_ser_read(bfd);
274
275 if (rc < 0)
276 return rc;
277
278 if (what & BSC_FD_WRITE)
279 rc = handle_ser_write(bfd);
280
281 return rc;
Harald Welte61e42ad2009-01-18 19:10:46 +0000282}
283
284static int file_is_readable(const char *fname)
285{
286 int rc;
287 struct stat st;
288
289 rc = stat(fname, &st);
290 if (rc < 0)
291 return 0;
292
293 if (S_ISREG(st.st_mode) && (st.st_mode & S_IRUSR))
294 return 1;
295
296 return 0;
297}
298
299
300static int handle_state_resp(u_int8_t state)
301{
Harald Welte3b8ba212009-01-29 12:27:58 +0000302 int rc = 0;
303
Harald Welte61e42ad2009-01-18 19:10:46 +0000304 printf("STATE: ");
Harald Welte3b8ba212009-01-29 12:27:58 +0000305
Harald Welte61e42ad2009-01-18 19:10:46 +0000306 switch (state) {
307 case BS11_STATE_WARM_UP:
308 printf("Warm Up...\n");
309 sleep(5);
310 break;
311 case BS11_STATE_LOAD_SMU_SAFETY:
312 printf("Load SMU Safety...\n");
313 sleep(5);
314 break;
315 case BS11_STATE_SOFTWARE_RQD:
316 printf("Software required...\n");
Harald Welte3b8ba212009-01-29 12:27:58 +0000317 bs11cfg_state = STATE_SWLOAD;
Harald Welte61e42ad2009-01-18 19:10:46 +0000318 /* send safety load */
319 if (file_is_readable(fname_safety))
Harald Welte623d5312009-01-29 21:14:05 +0000320 rc = abis_nm_software_load(g_bts, fname_safety,
321 win_size);
Harald Welte61e42ad2009-01-18 19:10:46 +0000322 else
Harald Welte071f34d2009-01-29 09:24:38 +0000323 fprintf(stderr, "No valid Safety Load file \"%s\"\n",
324 fname_safety);
Harald Welte61e42ad2009-01-18 19:10:46 +0000325 break;
326 case BS11_STATE_WAIT_MIN_CFG:
327 case BS11_STATE_WAIT_MIN_CFG_2:
328 printf("Wait minimal config...\n");
Harald Welte3b8ba212009-01-29 12:27:58 +0000329 bs11cfg_state = STATE_SWLOAD;
330 rc = create_objects(g_bts, have_trx1);
Harald Welte61e42ad2009-01-18 19:10:46 +0000331 break;
332 case BS11_STATE_MAINTENANCE:
333 printf("Maintenance...\n");
Harald Welte3b8ba212009-01-29 12:27:58 +0000334 bs11cfg_state = STATE_SWLOAD;
Harald Welte61e42ad2009-01-18 19:10:46 +0000335 /* send software (FIXME: over A-bis?) */
336 if (file_is_readable(fname_software))
Harald Welte623d5312009-01-29 21:14:05 +0000337 rc = abis_nm_software_load(g_bts, fname_software,
338 win_size);
Harald Welte61e42ad2009-01-18 19:10:46 +0000339 else
Harald Welte071f34d2009-01-29 09:24:38 +0000340 fprintf(stderr, "No valid Software file \"%s\"\n",
341 fname_software);
Harald Welte61e42ad2009-01-18 19:10:46 +0000342 break;
343 case BS11_STATE_NORMAL:
344 printf("Normal...\n");
345 return 1;
346 default:
347 printf("Unknown state 0x%02u\n", state);
348 sleep(5);
349 break;
350 }
Harald Welte3b8ba212009-01-29 12:27:58 +0000351 return rc;
Harald Welte61e42ad2009-01-18 19:10:46 +0000352}
353
Harald Welte14f09342009-01-29 19:28:38 +0000354static int handle_serial_msg(struct msgb *rx_msg)
355{
356 struct abis_om_hdr *oh;
357 struct abis_om_fom_hdr *foh;
358 int rc = -1;
359
360 if (rx_msg->len < LAPD_HDR_LEN
361 + sizeof(struct abis_om_fom_hdr)
362 + sizeof(struct abis_om_hdr)) {
363 if (!memcmp(rx_msg->data + 2, too_fast,
364 sizeof(too_fast))) {
365 fprintf(stderr, "BS11 tells us we're too "
366 "fast, try --delay bigger than %u\n",
367 delay_ms);
368 return -E2BIG;
369 } else
370 fprintf(stderr, "unknown BS11 message\n");
371 }
372
373 oh = (struct abis_om_hdr *) msgb_l2(rx_msg);
374 foh = (struct abis_om_fom_hdr *) oh->data;
375 switch (foh->msg_type) {
Harald Welte043d04a2009-01-29 23:15:30 +0000376 case NM_MT_BS11_LMT_LOGON_ACK:
377 printf("LMT LOGON: ACK\n");
Harald Welte14f09342009-01-29 19:28:38 +0000378 if (bs11cfg_state == STATE_NONE)
379 bs11cfg_state = STATE_LOGON_ACK;
380 rc = 0;
381 break;
382 case NM_MT_BS11_GET_STATE_ACK:
383 rc = handle_state_resp(foh->data[2]);
384 break;
385 default:
386 rc = abis_nm_rcvmsg(rx_msg);
387 }
388 if (rc < 0) {
389 perror("ERROR in main loop");
390 //break;
391 }
392 if (rc == 1)
393 return rc;
394
395 switch (bs11cfg_state) {
396 case STATE_NONE:
397 abis_nm_bs11_factory_logon(g_bts, 1);
398 break;
399 case STATE_LOGON_ACK:
400 abis_nm_bs11_get_state(g_bts);
401 break;
402 default:
403 break;
404 }
405
406 return rc;
407}
408
Harald Welte61e42ad2009-01-18 19:10:46 +0000409static void print_banner(void)
410{
411 printf("bs11_config (C) 2009 by Harald Welte and Dieter Spaar\n");
412 printf("THIS SOFTWARE IS FREE SOFTWARE WIH NO WARRANTY\n\n");
413}
414
415static void print_help(void)
416{
417 printf("Supported arguments:\n");
418 printf("\t--help\t\t\t-h\tPrint this help text\n");
419 printf("\t--port /dev/ttyXXX\t-p\tSpecify serial port\n");
420 printf("\t--with-trx1\t\t-t\tAssume the BS-11 has 2 TRX\n");
421 printf("\t--software file\t\t-s\tSpecify Software file\n");
Harald Welte3b8ba212009-01-29 12:27:58 +0000422 printf("\t--safety file\t\t-S\tSpecify Safety Load file\n");
Harald Welte623d5312009-01-29 21:14:05 +0000423 printf("\t--delay file\t\t-d\tSpecify delay\n");
424 printf("\t--win-size num\t\t-w\tSpecify Window Size\n");
Harald Welte61e42ad2009-01-18 19:10:46 +0000425}
426
427static void handle_options(int argc, char **argv)
428{
429 print_banner();
430
431 while (1) {
432 int option_index = 0, c;
433 static struct option long_options[] = {
434 { "help", 0, 0, 'h' },
435 { "port", 1, 0, 'p' },
436 { "with-trx1", 0, 0, 't' },
437 { "software", 1, 0, 's' },
438 { "safety", 1, 0, 'S' },
Harald Welte3b8ba212009-01-29 12:27:58 +0000439 { "delay", 1, 0, 'd' },
Harald Welte623d5312009-01-29 21:14:05 +0000440 { "win-size", 1, 0, 'w' },
Harald Welte61e42ad2009-01-18 19:10:46 +0000441 };
442
Harald Welte623d5312009-01-29 21:14:05 +0000443 c = getopt_long(argc, argv, "hp:s:S:td:w:",
Harald Welte61e42ad2009-01-18 19:10:46 +0000444 long_options, &option_index);
445
446 if (c == -1)
447 break;
448
449 switch (c) {
450 case 'h':
451 print_help();
452 exit(0);
453 case 'p':
454 serial_port = optarg;
455 break;
456 case 't':
457 have_trx1 = 1;
458 break;
459 case 's':
460 fname_software = optarg;
461 break;
462 case 'S':
463 fname_safety = optarg;
464 break;
Harald Welte3b8ba212009-01-29 12:27:58 +0000465 case 'd':
466 delay_ms = atoi(optarg);
467 break;
Harald Welte623d5312009-01-29 21:14:05 +0000468 case 'w':
469 win_size = atoi(optarg);
470 break;
Harald Welte61e42ad2009-01-18 19:10:46 +0000471 default:
472 break;
473 }
474 }
475}
476
Harald Welte14f09342009-01-29 19:28:38 +0000477static void signal_handler(int signal)
478{
479 fprintf(stdout, "signal %u received\n", signal);
480
481 switch (signal) {
482 case SIGABRT:
483 abis_nm_bs11_factory_logon(g_bts, 0);
484 break;
485 }
486}
487
Harald Welte61e42ad2009-01-18 19:10:46 +0000488int main(int argc, char **argv)
489{
490 struct gsm_network *gsmnet;
Harald Weltef186c462009-01-29 08:45:19 +0000491 struct termios tio;
492 int rc;
Harald Welte61e42ad2009-01-18 19:10:46 +0000493
494 handle_options(argc, argv);
495
496 serial_fd = open(serial_port, O_RDWR);
497 if (serial_fd < 0) {
498 perror("cannot open serial port:");
499 exit(1);
500 }
501
Harald Weltef186c462009-01-29 08:45:19 +0000502 /* set baudrate */
503 rc = tcgetattr(serial_fd, &tio);
504 if (rc < 0) {
505 perror("tcgetattr()");
506 exit(1);
507 }
508 cfsetispeed(&tio, B19200);
509 cfsetospeed(&tio, B19200);
Harald Welte071f34d2009-01-29 09:24:38 +0000510 tio.c_cflag |= (CREAD | CLOCAL | CS8);
511 tio.c_cflag &= ~(PARENB | CSTOPB | CSIZE | CRTSCTS);
512 tio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
513 tio.c_iflag |= (INPCK | ISTRIP);
514 tio.c_iflag &= ~(ISTRIP | IXON | IXOFF | IGNBRK | INLCR | ICRNL | IGNCR);
Harald Welte623d5312009-01-29 21:14:05 +0000515 tio.c_oflag &= ~(OPOST);
Harald Weltef186c462009-01-29 08:45:19 +0000516 rc = tcsetattr(serial_fd, TCSADRAIN, &tio);
517 if (rc < 0) {
518 perror("tcsetattr()");
519 exit(1);
520 }
Harald Welte61e42ad2009-01-18 19:10:46 +0000521
522 gsmnet = gsm_network_init(1, 1, 1);
523 if (!gsmnet) {
524 fprintf(stderr, "Unable to allocate gsm network\n");
525 exit(1);
526 }
527 g_bts = &gsmnet->bts[0];
528
Harald Welte14f09342009-01-29 19:28:38 +0000529 INIT_LLIST_HEAD(&ser_handle->tx_queue);
530 ser_handle->fd.fd = serial_fd;
531 ser_handle->fd.when = BSC_FD_READ;
532 ser_handle->fd.cb = serial_fd_cb;
533 ser_handle->fd.data = ser_handle;
534 rc = bsc_register_fd(&ser_handle->fd);
535 if (rc < 0) {
536 fprintf(stderr, "could not register FD: %s\n",
537 strerror(rc));
538 exit(1);
539 }
540
541 signal(SIGABRT, &signal_handler);
542
Harald Welte61e42ad2009-01-18 19:10:46 +0000543 abis_nm_bs11_factory_logon(g_bts, 1);
544
545 while (1) {
Harald Welte14f09342009-01-29 19:28:38 +0000546 bsc_select_main();
Harald Welte61e42ad2009-01-18 19:10:46 +0000547 }
548
549 abis_nm_bs11_factory_logon(g_bts, 0);
550
551 close(serial_fd);
552 exit(0);
553}