| 1 | /*****************************************************************************/ |
| 2 | |
| 3 | /* |
| 4 | * xfhdlcchpar_main.C -- kernel hdlc radio modem driver channel parameter setting utility. |
| 5 | * |
| 6 | * Copyright (C) 1996,1997,2000 Thomas Sailer ([email protected]) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA |
| 21 | * 02110-1301, USA. |
| 22 | * |
| 23 | * Please note that the GPL allows you to use the driver, NOT the radio. |
| 24 | * In order to use the radio, you need a license from the communications |
| 25 | * authority of your country. |
| 26 | * |
| 27 | * |
| 28 | * History: |
| 29 | * 0.1 14.12.1996 Started |
| 30 | * 0.2 11.05.1997 introduced hdrvcomm.h |
| 31 | * 0.3 05.01.2000 upgraded to fltk 1.0.7 |
| 32 | */ |
| 33 | |
| 34 | /*****************************************************************************/ |
| 35 | |
| 36 | #include <stdlib.h> |
| 37 | #include <stdio.h> |
| 38 | #include <unistd.h> |
| 39 | #include <string.h> |
| 40 | #include <sys/types.h> |
| 41 | #include <net/if.h> |
| 42 | #include "hdrvcomm.h" |
| 43 | #include "xfhdlcchpar.h" |
| 44 | |
| 45 | #include <config.h> |
| 46 | #include <scm-version.h> |
| 47 | |
| 48 | /* ---------------------------------------------------------------------- */ |
| 49 | |
| 50 | static char *progname; |
| 51 | |
| 52 | /* ---------------------------------------------------------------------- */ |
| 53 | |
| 54 | void cb_update(Fl_Widget *widget, void *udata) |
| 55 | { |
| 56 | int ret; |
| 57 | struct hdrvc_channel_params cp; |
| 58 | |
| 59 | cp.tx_delay = (int)(0.1*txdelay->value()); |
| 60 | cp.tx_tail = (int)(0.1*txtail->value()); |
| 61 | cp.slottime = (int)(0.1*slottime->value()); |
| 62 | cp.ppersist = (int)(ppersist->value()); |
| 63 | cp.fulldup = !!fulldup->value(); |
| 64 | ret = hdrvc_set_channel_access_param(cp); |
| 65 | if (ret < 0) |
| 66 | perror("hdrvc_set_channel_access_param"); |
| 67 | } |
| 68 | |
| 69 | /* ---------------------------------------------------------------------- */ |
| 70 | |
| 71 | void cb_quit(Fl_Button *, long) |
| 72 | { |
| 73 | exit(0); |
| 74 | } |
| 75 | |
| 76 | /* ---------------------------------------------------------------------- */ |
| 77 | |
| 78 | static const char *usage_str = |
| 79 | "[-i smif]\n" |
| 80 | " -i: specify the name of the baycom kernel driver interface\n\n"; |
| 81 | |
| 82 | /* ---------------------------------------------------------------------- */ |
| 83 | |
| 84 | int main(int argc, char *argv[]) |
| 85 | { |
| 86 | int c, i; |
| 87 | int ret; |
| 88 | struct hdrvc_channel_params cp; |
| 89 | |
| 90 | progname = *argv; |
| 91 | printf("%s: Version " FULL_VER "; (C) 1996,1997,2000 by Thomas Sailer HB9JNX/AE4WA\n", progname); |
| 92 | hdrvc_args(&argc, argv, "bc0"); |
| 93 | for (i = 1; i < argc; ) { |
| 94 | c = i; |
| 95 | Fl::arg(argc, argv, c); |
| 96 | if (c <= 0) { |
| 97 | i++; |
| 98 | continue; |
| 99 | } |
| 100 | memmove(&argv[i], &argv[i+c], (argc-i) * sizeof(char *)); |
| 101 | argc -= c; |
| 102 | } |
| 103 | #if 0 |
| 104 | while ((ret = getopt(argc, argv, "")) != -1) { |
| 105 | switch (ret) { |
| 106 | default: |
| 107 | printf("usage: %s %s", progname, usage_str); |
| 108 | exit(-1); |
| 109 | } |
| 110 | } |
| 111 | #endif |
| 112 | hdrvc_init(); |
| 113 | |
| 114 | create_the_forms(); |
| 115 | ifname->value(hdrvc_ifname()); |
| 116 | /* |
| 117 | * set channel params |
| 118 | */ |
| 119 | ret = hdrvc_get_channel_access_param(&cp); |
| 120 | if (ret < 0) { |
| 121 | perror("hdrvc_get_channel_access_param"); |
| 122 | exit(1); |
| 123 | } |
| 124 | txdelay->step(10); |
| 125 | txdelay->bounds(0, 2550); |
| 126 | txdelay->value(cp.tx_delay*10); |
| 127 | txtail->step(10); |
| 128 | txtail->bounds(0, 2550); |
| 129 | txtail->value(cp.tx_tail*10); |
| 130 | slottime->step(10); |
| 131 | slottime->bounds(0, 2550); |
| 132 | slottime->value(cp.slottime*10); |
| 133 | ppersist->step(1); |
| 134 | ppersist->bounds(0, 255); |
| 135 | ppersist->value(cp.ppersist); |
| 136 | fulldup->value(!!cp.fulldup); |
| 137 | chpar->show(); |
| 138 | Fl::run(); |
| 139 | exit(0); |
| 140 | } |