FreeCalypso > hg > ice1-trau-tester
comparison ater/main.c @ 16:4ffe22f5b4b5
ater: initial osmo_i460 framework
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 24 Jun 2024 07:19:38 +0000 |
parents | 98ae717734d6 |
children | 1e375472d5a5 |
comparison
equal
deleted
inserted
replaced
15:98ae717734d6 | 16:4ffe22f5b4b5 |
---|---|
9 | 9 |
10 #include <stdint.h> | 10 #include <stdint.h> |
11 #include <stdbool.h> | 11 #include <stdbool.h> |
12 #include <stdio.h> | 12 #include <stdio.h> |
13 #include <stdlib.h> | 13 #include <stdlib.h> |
14 #include <string.h> | |
14 #include <unistd.h> | 15 #include <unistd.h> |
15 | 16 |
16 #include <osmocom/core/talloc.h> | 17 #include <osmocom/core/talloc.h> |
17 #include <osmocom/core/select.h> | 18 #include <osmocom/core/select.h> |
18 #include <osmocom/core/application.h> | 19 #include <osmocom/core/application.h> |
19 #include <osmocom/e1d/proto_clnt.h> | 20 #include <osmocom/e1d/proto_clnt.h> |
21 #include <osmocom/isdn/i460_mux.h> | |
20 | 22 |
21 #include "../libutil/open_ts.h" | 23 #include "../libutil/open_ts.h" |
22 #include "../libutil/stdin_handler.h" | 24 #include "../libutil/stdin_handler.h" |
23 #include "globals.h" | 25 #include "globals.h" |
26 #include "submux.h" | |
24 | 27 |
25 struct osmo_e1dp_client *g_client; | 28 struct osmo_e1dp_client *g_client; |
26 int ts_fd; | 29 int ts_fd; |
30 struct osmo_i460_timeslot i460_ts; | |
31 struct ater_subslot subslots[ATER_SUBSLOTS]; | |
27 | 32 |
28 static const char *e1d_socket_path = E1DP_DEFAULT_SOCKET; | 33 static const char *e1d_socket_path = E1DP_DEFAULT_SOCKET; |
29 static const char *timeslot_spec; | 34 static const char *timeslot_spec; |
30 static void *g_ctx; | 35 static void *g_ctx; |
31 static struct osmo_fd ts_ofd, stdin_ofd; | 36 static struct osmo_fd ts_ofd, stdin_ofd; |
51 if (argc != optind + 1) | 56 if (argc != optind + 1) |
52 goto usage; | 57 goto usage; |
53 timeslot_spec = argv[optind]; | 58 timeslot_spec = argv[optind]; |
54 } | 59 } |
55 | 60 |
61 static void register_subslots(void) | |
62 { | |
63 int nr; | |
64 struct osmo_i460_schan_desc chd; | |
65 | |
66 memset(&chd, 0, sizeof chd); | |
67 chd.rate = OSMO_I460_RATE_16k; | |
68 chd.demux.num_bits = 320; | |
69 chd.demux.out_cb_bits = i460_rx_func; | |
70 | |
71 for (nr = 0; nr < ATER_SUBSLOTS; nr++) { | |
72 subslots[nr].nr = nr; | |
73 chd.demux.user_data = subslots + nr; | |
74 chd.mux.user_data = subslots + nr; | |
75 subslots[nr].schan = | |
76 osmo_i460_subchan_add(g_ctx, &i460_ts, &chd); | |
77 OSMO_ASSERT(subslots[nr].schan); | |
78 chd.bit_offset += 2; | |
79 } | |
80 } | |
81 | |
56 int main(int argc, char **argv) | 82 int main(int argc, char **argv) |
57 { | 83 { |
58 process_cmdline(argc, argv); | 84 process_cmdline(argc, argv); |
59 g_ctx = talloc_named_const(NULL, 0, "g_ctx"); | 85 g_ctx = talloc_named_const(NULL, 0, "g_ctx"); |
60 OSMO_ASSERT(g_ctx); | 86 OSMO_ASSERT(g_ctx); |
66 e1d_socket_path); | 92 e1d_socket_path); |
67 exit(1); | 93 exit(1); |
68 } | 94 } |
69 ts_fd = open_e1d_ts(g_client, timeslot_spec); | 95 ts_fd = open_e1d_ts(g_client, timeslot_spec); |
70 | 96 |
97 osmo_i460_ts_init(&i460_ts); | |
98 register_subslots(); | |
99 | |
71 osmo_fd_setup(&ts_ofd, ts_fd, OSMO_FD_READ, ts_fd_cb, NULL, 0); | 100 osmo_fd_setup(&ts_ofd, ts_fd, OSMO_FD_READ, ts_fd_cb, NULL, 0); |
72 OSMO_ASSERT(osmo_fd_register(&ts_ofd) == 0); | 101 OSMO_ASSERT(osmo_fd_register(&ts_ofd) == 0); |
73 | 102 |
74 osmo_fd_setup(&stdin_ofd, 0, OSMO_FD_READ, stdin_select_cb, | 103 osmo_fd_setup(&stdin_ofd, 0, OSMO_FD_READ, stdin_select_cb, |
75 handle_user_cmd, 0); | 104 handle_user_cmd, 0); |