mirror of
https://github.com/D-Modem/gui.git
synced 2026-11-28 14:19:58 -08:00
Support the MultiTech MT9234MU: find it on Linux, page ATI11
- libdmodemctl: a command's response in pages (ATI11 on the Agere modems, the MultiTech MT9234 among them) stops at "Press any key". The session now sends a space at that prompt, for 8 pages at most, and keeps the prompt out of the response. So the Call Stats page gets the full report instead of a timeout. Text typed in the terminal is left to the user. A test covers it. - Linux: usbmodem.c finds an MT9234MU or MT9234ZBA-USB in sysfs. The line settings show its ttyUSB with a "Use" button, or say that it needs mts_mt9234mu.fw (or the ti_usb_3410_5052 driver). Its port opens with RTS/CTS (the modem's &K3). - docs/design.md: hardware modems on each system, the firmware file and the country setting (AT%T19). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRTNWiwCE3duMg28226
This commit is contained in:
9 files changed
+312
-4
No files matched your search
@@ -23,7 +23,7 @@ libdmodemctl. Thus they operate in the same way.
|
||||
LGPL-2.0-or-later: `core/licenses/syncterm-fonts-LGPL-2.0.txt`)
|
||||
- **Settings**: each modem setting as a native control, from AT!M
|
||||
- **Call Stats**: the rate, modulation, error control and line figures of the last call (AT#UD, ATI11)
|
||||
- **Line settings**: a SIP account, a USB modem, or a modem that already runs
|
||||
- **Line settings**: a SIP account, a USB modem, or a modem that already runs (dmodemd, or a hardware modem such as the MultiTech MT9234MU)
|
||||
- **Windows 95 and later**: plain Win32, built with Open Watcom. On Windows 9x, the app connects to a modem through TCP or a COM port
|
||||
|
||||
| | Windows | macOS | Linux |
|
||||
@@ -59,7 +59,7 @@ D-Modem 1.0.
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Design](docs/design.md): how the apps are built, what they share, and the Windows 9x notes
|
||||
- [Design](docs/design.md): how the apps are built, what they share, hardware modems (the MultiTech MT9234MU), and the Windows 9x notes
|
||||
- [libdmodemctl](core/include/dmodemctl.h): the API of the library
|
||||
- [Documentation style](docs/STYLE.md): the rules for ASD-STE100 Simplified Technical English
|
||||
|
||||
|
||||
+39
-1
@@ -43,6 +43,8 @@
|
||||
/* a line longer than this keeps only its end (a configurator's
|
||||
screens come with no line ends, and its OK after the last one) */
|
||||
#define LINE_MAX 4096
|
||||
/* the most pages of one response that the session pages on */
|
||||
#define PAGES_MAX 8
|
||||
|
||||
/* voice: how far ahead of the line our samples go (60 ms), how many of
|
||||
the far end's are kept (1 s), how many of ours may wait (a third of
|
||||
@@ -120,6 +122,10 @@ struct dmc_session {
|
||||
struct command *queue, *active;
|
||||
int64_t active_until;
|
||||
int echo_seen;
|
||||
/* the pages of its response that the session paged on (a key sent
|
||||
to "Press any key") */
|
||||
int pages;
|
||||
int prompt; /* the rest of the prompt's line: dropped */
|
||||
dmc_buf response;
|
||||
int next_tag;
|
||||
/* the events, and the one dmc_next_event() last gave */
|
||||
@@ -378,6 +384,8 @@ static void pump(dmc_session *s)
|
||||
s->active = c;
|
||||
s->active_until = s->now + c->timeout_ms;
|
||||
s->echo_seen = 0;
|
||||
s->pages = 0;
|
||||
s->prompt = 0;
|
||||
buf_clear(&s->response);
|
||||
buf_adds(&s->out, c->cmd);
|
||||
buf_addc(&s->out, '\r');
|
||||
@@ -770,6 +778,17 @@ static void line_in(dmc_session *s, const char *l)
|
||||
|
||||
static void voice_byte(dmc_session *s, unsigned char c);
|
||||
|
||||
/* whether l is a pager's prompt: a modem that shows a long response in
|
||||
pages (ATI11 on the Agere modems, the MultiTech MT9234 among them)
|
||||
stops after each page at "Press any key to continue; ESC to quit" */
|
||||
static int pager_prompt(const char *l)
|
||||
{
|
||||
for (; *l; l++)
|
||||
if (starts_ci(l, "any key"))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dmc_feed(dmc_session *s, const char *data, int n)
|
||||
{
|
||||
if (s->state == DMC_CLOSED)
|
||||
@@ -783,16 +802,35 @@ void dmc_feed(dmc_session *s, const char *data, int n)
|
||||
int quiet = s->active && (s->active->flags & DMC_QUIET);
|
||||
if (!quiet)
|
||||
buf_addc(&s->term, c);
|
||||
if (c == '\n' && s->prompt) {
|
||||
s->prompt = 0;
|
||||
continue;
|
||||
}
|
||||
if (c == '\n') {
|
||||
line_in(s, buf_str(&s->line));
|
||||
buf_clear(&s->line);
|
||||
continue;
|
||||
}
|
||||
if (c == '\r')
|
||||
if (c == '\r') {
|
||||
s->prompt = 0;
|
||||
continue;
|
||||
}
|
||||
if (s->prompt)
|
||||
continue;
|
||||
if (s->line.n >= LINE_MAX)
|
||||
buf_drop(&s->line, s->line.n - LINE_MAX / 2);
|
||||
buf_addc(&s->line, c);
|
||||
/* a command's response in pages: the next page asked for
|
||||
(a space), the prompt kept out of the response */
|
||||
if (s->active && (s->state == DMC_IDLE ||
|
||||
s->state == DMC_ONLINE_COMMAND) &&
|
||||
s->pages < PAGES_MAX && pager_prompt(buf_str(&s->line))) {
|
||||
buf_addc(&s->out, ' ');
|
||||
buf_clear(&s->line);
|
||||
s->prompt = 1;
|
||||
s->pages++;
|
||||
s->active_until = s->now + s->active->timeout_ms;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,6 +140,32 @@ static void test_command(void)
|
||||
dmc_session_free(s);
|
||||
}
|
||||
|
||||
/* a response in pages (ATI11 on an Agere modem, a MultiTech MT9234):
|
||||
a space for each "Press any key", the prompt kept out of the response */
|
||||
static void test_pages(void)
|
||||
{
|
||||
dmc_session *s = dmc_session_new();
|
||||
dmc_event ev;
|
||||
dmc_open(s, 0);
|
||||
int tag = dmc_command(s, "ATI11", DMC_QUIET, 0);
|
||||
CHECK_STR(out(s), "ATI11\r");
|
||||
feed(s, "ATI11\r\r\nLast Connection V.92\r\n"
|
||||
"Press any key to continue; ESC to quit");
|
||||
CHECK_STR(out(s), " ");
|
||||
CHECK(!next_of(s, DMC_EV_RESPONSE, &ev));
|
||||
feed(s, "\r\nNear Echo Level NA\r\n\r\nOK\r\n");
|
||||
CHECK_STR(out(s), "");
|
||||
CHECK(next_of(s, DMC_EV_RESPONSE, &ev));
|
||||
CHECK(ev.tag == tag && ev.ok);
|
||||
CHECK_STR(ev.text, "Last Connection V.92\n\nNear Echo Level NA");
|
||||
/* text typed in the terminal is the user's own: no key sent */
|
||||
dmc_type(s, "ATI11\r", 6);
|
||||
out(s);
|
||||
feed(s, "ATI11\r\r\nPress any key to continue");
|
||||
CHECK_STR(out(s), "");
|
||||
dmc_session_free(s);
|
||||
}
|
||||
|
||||
/* a call: dial, connect, online data, hang up through the escape */
|
||||
static void test_call(void)
|
||||
{
|
||||
@@ -1185,6 +1211,7 @@ int main(int argc, char **argv)
|
||||
const char *dir = argc > 1 ? argv[1] : ".";
|
||||
CHECK(dmc_version() == DMC_VERSION);
|
||||
test_command();
|
||||
test_pages();
|
||||
test_call();
|
||||
test_unsolicited();
|
||||
test_typed();
|
||||
|
||||
@@ -109,6 +109,47 @@ the pty in the group of the user (`-g`). Thus dmodemd does not need root.
|
||||
Each app can also use a modem that already runs: a device path on Linux and
|
||||
macOS, or a TCP address or a COM port on Windows.
|
||||
|
||||
## Hardware modems: the MultiTech MT9234MU
|
||||
|
||||
The "device" line can also open a hardware modem. The apps send AT commands
|
||||
to it and read its result codes, as they do with dmodemd. The Settings page
|
||||
needs `AT!M`, thus it operates only with dmodemd.
|
||||
|
||||
The MultiTech MultiMobile MT9234MU (USB 06E0:F114) and the MT9234ZBA-USB
|
||||
(06E0:F115, 06E0:0319) are V.92 data and fax modems. They have a TI TUSB3410
|
||||
USB UART. The TUSB3410 has no firmware of its own. The host downloads the
|
||||
firmware into the chip each time you connect the modem.
|
||||
|
||||
| | Linux | macOS | Windows |
|
||||
| --- | --- | --- | --- |
|
||||
| Driver | `ti_usb_3410_5052` (in the kernel) | we do not know a driver for the MT9234MU. The CDC-ACM models (MT9234MU-CDC) use the driver of the system | the driver of MultiTech |
|
||||
| Firmware | `mts_mt9234mu.fw` in `/lib/firmware` | not applicable | the driver of MultiTech has it |
|
||||
| The port | `/dev/ttyUSB0` | `/dev/cu.usbmodem*` (CDC-ACM models) | a COM port |
|
||||
|
||||
Linux does not include `mts_mt9234mu.fw` after June 2026. MultiTech gave no
|
||||
license that lets other persons distribute it, thus linux-firmware removed
|
||||
it. Get the file from the Linux driver of MultiTech, or from a
|
||||
linux-firmware package from before that date. Put it in `/lib/firmware`,
|
||||
then disconnect the modem and connect it again.
|
||||
|
||||
On Linux, the app finds the modem in sysfs (`linux/src/usbmodem.c`). The
|
||||
line settings show where the modem is, with a "Use" button. If the modem
|
||||
has no firmware, they show what to do. When the app opens the port of the
|
||||
modem, it sets RTS/CTS flow control (`CRTSCTS`). The modem uses `&K3` from
|
||||
the factory.
|
||||
|
||||
Set the country of the line with `AT%T19,0,<code>` and `AT&F&W` in the
|
||||
"Commands when the modem opens" field one time, or in the Terminal page.
|
||||
`AT%T19,0,34` is the default (North America and Europe).
|
||||
|
||||
`ATI11` on these modems (and on other Agere modems) shows its report on two
|
||||
pages. After each page, the modem waits for a key ("Press any key"). The
|
||||
library sends a space when a command of the app gets this prompt, thus the
|
||||
Call Stats page gets the full report. It does this for 8 pages at most. In
|
||||
the Terminal page, you push the key.
|
||||
|
||||
We did not test this yet with a real MT9234MU.
|
||||
|
||||
## Remote logins
|
||||
|
||||
The Remote page logs in to a server, next to the modem, in a separate
|
||||
|
||||
@@ -5,6 +5,7 @@ add_executable(dmodem-gui
|
||||
src/window.c
|
||||
src/modem.c
|
||||
src/config.c
|
||||
src/usbmodem.c
|
||||
src/settings.c
|
||||
src/stats.c
|
||||
src/voice.c
|
||||
|
||||
@@ -102,6 +102,23 @@ gboolean config_sip_ready(const Config *c);
|
||||
/* the line settings dialog */
|
||||
void prefs_show(App *a);
|
||||
|
||||
/* usbmodem.c: a MultiTech MT9234MU (or MT9234ZBA-USB) on USB, from
|
||||
sysfs */
|
||||
typedef struct UsbModem {
|
||||
char *name; /* "MultiTech MT9234MU" */
|
||||
char *tty; /* "/dev/ttyUSB0", or NULL if it has none */
|
||||
gboolean no_firmware; /* in the boot ROM: no firmware loaded */
|
||||
} UsbModem;
|
||||
/* the first one plugged in, or NULL */
|
||||
UsbModem *usbmodem_find(void);
|
||||
/* what it is and where, or what it needs, for the user */
|
||||
char *usbmodem_describe(const UsbModem *m);
|
||||
/* whether Linux has its firmware file (mts_mt9234mu.fw) */
|
||||
gboolean usbmodem_firmware_present(void);
|
||||
/* whether tty path is such a modem's */
|
||||
gboolean usbmodem_is(const char *path);
|
||||
void usbmodem_free(UsbModem *m);
|
||||
|
||||
/* modem.c */
|
||||
void modem_start(App *a);
|
||||
void modem_stop(App *a);
|
||||
|
||||
+34
-1
@@ -305,6 +305,37 @@ static AdwPreferencesGroup *group(AdwPreferencesPage *page, const char *title,
|
||||
return ADW_PREFERENCES_GROUP(g);
|
||||
}
|
||||
|
||||
static void use_found(GtkButton *b, gpointer data)
|
||||
{
|
||||
Prefs *p = data;
|
||||
gtk_editable_set_text(GTK_EDITABLE(p->device),
|
||||
g_object_get_data(G_OBJECT(b), "tty"));
|
||||
}
|
||||
|
||||
/* a MultiTech MT9234MU plugged in: a row that says where it is (with a
|
||||
button that puts it in Device), or what it needs */
|
||||
static void device_found(Prefs *p)
|
||||
{
|
||||
UsbModem *m = usbmodem_find();
|
||||
if (!m)
|
||||
return;
|
||||
char *d = usbmodem_describe(m);
|
||||
GtkWidget *r = adw_action_row_new();
|
||||
adw_preferences_row_set_title(ADW_PREFERENCES_ROW(r), "Found");
|
||||
adw_action_row_set_subtitle(ADW_ACTION_ROW(r), d);
|
||||
if (m->tty) {
|
||||
GtkWidget *b = gtk_button_new_with_label("Use");
|
||||
gtk_widget_set_valign(b, GTK_ALIGN_CENTER);
|
||||
g_object_set_data_full(G_OBJECT(b), "tty", g_strdup(m->tty),
|
||||
g_free);
|
||||
g_signal_connect(b, "clicked", G_CALLBACK(use_found), p);
|
||||
adw_action_row_add_suffix(ADW_ACTION_ROW(r), b);
|
||||
}
|
||||
adw_preferences_group_add(p->device_g, r);
|
||||
g_free(d);
|
||||
usbmodem_free(m);
|
||||
}
|
||||
|
||||
static char *text_of(AdwEntryRow *r)
|
||||
{
|
||||
return g_strstrip(g_strdup(gtk_editable_get_text(GTK_EDITABLE(r))));
|
||||
@@ -388,8 +419,10 @@ void prefs_show(App *a)
|
||||
p->alsa = entry(p->alsa_g, "ALSA device", c->alsa);
|
||||
p->device_g = group(page, "A modem that already runs",
|
||||
"dmodemd started as a service, or any modem's "
|
||||
"serial port.");
|
||||
"serial port (a MultiTech MT9234MU is "
|
||||
"/dev/ttyUSB0).");
|
||||
p->device = entry(p->device_g, "Device", c->device);
|
||||
device_found(p);
|
||||
|
||||
AdwPreferencesGroup *adv = group(page, "Advanced", NULL);
|
||||
p->init = entry(adv, "Commands when the modem opens", c->init);
|
||||
|
||||
@@ -157,6 +157,10 @@ static gboolean open_dte(App *a, const char *path)
|
||||
cfsetispeed(&t, B115200);
|
||||
cfsetospeed(&t, B115200);
|
||||
t.c_cflag |= CLOCAL | CREAD;
|
||||
/* (a MultiTech MT9234MU: RTS/CTS, its &K3, so that the
|
||||
modem's buffer does not overflow in a fast call) */
|
||||
if (usbmodem_is(path))
|
||||
t.c_cflag |= CRTSCTS;
|
||||
tcsetattr(fd, TCSANOW, &t);
|
||||
}
|
||||
a->fd = fd;
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright (C) 2026 D-Modem Authors
|
||||
*
|
||||
* usbmodem.c - hardware modems on USB that the "device" line can open:
|
||||
* the MultiTech MT9234MU and MT9234ZBA-USB, found in sysfs
|
||||
*
|
||||
* These modems have a TI TUSB3410 USB UART. Linux's ti_usb_3410_5052
|
||||
* driver downloads its firmware (mts_mt9234mu.fw) into the chip; then
|
||||
* the modem is a ttyUSB. Without the firmware file the modem stays in
|
||||
* the chip's boot ROM (one configuration) and has no tty.
|
||||
*/
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "app.h"
|
||||
|
||||
/* MultiTech's vendor ID and the products with a TUSB3410 */
|
||||
static const struct {
|
||||
const char *product, *name;
|
||||
} models[] = {
|
||||
{ "f114", "MultiTech MT9234MU" },
|
||||
{ "f115", "MultiTech MT9234ZBA-USB" },
|
||||
{ "0319", "MultiTech MT9234ZBA-USB" },
|
||||
};
|
||||
|
||||
/* the firmware file's places that Linux looks in */
|
||||
static const char *const firmware[] = {
|
||||
"/lib/firmware/updates/mts_mt9234mu.fw",
|
||||
"/lib/firmware/mts_mt9234mu.fw",
|
||||
"/usr/lib/firmware/updates/mts_mt9234mu.fw",
|
||||
"/usr/lib/firmware/mts_mt9234mu.fw",
|
||||
NULL
|
||||
};
|
||||
|
||||
/* the trimmed text of sysfs file dir/name, or NULL */
|
||||
static char *attr(const char *dir, const char *name)
|
||||
{
|
||||
char *path = g_build_filename(dir, name, NULL);
|
||||
char *t = NULL;
|
||||
if (g_file_get_contents(path, &t, NULL, NULL))
|
||||
g_strstrip(t);
|
||||
g_free(path);
|
||||
return t;
|
||||
}
|
||||
|
||||
/* the first ttyUSB under USB device dir's interfaces, as /dev/ttyUSBn,
|
||||
or NULL */
|
||||
static char *tty_of(const char *dir)
|
||||
{
|
||||
char *found = NULL;
|
||||
GDir *d = g_dir_open(dir, 0, NULL);
|
||||
if (!d)
|
||||
return NULL;
|
||||
const char *e;
|
||||
while (!found && (e = g_dir_read_name(d))) {
|
||||
/* (its interfaces: "1-2:2.0") */
|
||||
if (!strchr(e, ':'))
|
||||
continue;
|
||||
char *itf = g_build_filename(dir, e, NULL);
|
||||
GDir *i = g_dir_open(itf, 0, NULL);
|
||||
const char *t;
|
||||
while (i && !found && (t = g_dir_read_name(i)))
|
||||
if (g_str_has_prefix(t, "ttyUSB"))
|
||||
found = g_strconcat("/dev/", t, NULL);
|
||||
if (i)
|
||||
g_dir_close(i);
|
||||
g_free(itf);
|
||||
}
|
||||
g_dir_close(d);
|
||||
return found;
|
||||
}
|
||||
|
||||
gboolean usbmodem_firmware_present(void)
|
||||
{
|
||||
for (int i = 0; firmware[i]; i++)
|
||||
if (g_file_test(firmware[i], G_FILE_TEST_EXISTS))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UsbModem *usbmodem_find(void)
|
||||
{
|
||||
const char *root = "/sys/bus/usb/devices";
|
||||
GDir *d = g_dir_open(root, 0, NULL);
|
||||
if (!d)
|
||||
return NULL;
|
||||
UsbModem *m = NULL;
|
||||
const char *e;
|
||||
while (!m && (e = g_dir_read_name(d))) {
|
||||
char *dir = g_build_filename(root, e, NULL);
|
||||
char *vid = attr(dir, "idVendor");
|
||||
char *pid = vid ? attr(dir, "idProduct") : NULL;
|
||||
for (size_t k = 0; pid && !m &&
|
||||
k < sizeof(models) / sizeof(models[0]); k++) {
|
||||
if (g_ascii_strcasecmp(vid, "06e0") ||
|
||||
g_ascii_strcasecmp(pid, models[k].product))
|
||||
continue;
|
||||
m = g_new0(UsbModem, 1);
|
||||
m->name = g_strdup(models[k].name);
|
||||
m->tty = tty_of(dir);
|
||||
char *nc = attr(dir, "bNumConfigurations");
|
||||
/* (one configuration: the boot ROM's) */
|
||||
m->no_firmware = !m->tty && nc && !strcmp(nc, "1");
|
||||
g_free(nc);
|
||||
}
|
||||
g_free(vid);
|
||||
g_free(pid);
|
||||
g_free(dir);
|
||||
}
|
||||
g_dir_close(d);
|
||||
return m;
|
||||
}
|
||||
|
||||
char *usbmodem_describe(const UsbModem *m)
|
||||
{
|
||||
if (m->tty)
|
||||
return g_strdup_printf("%s at %s", m->name, m->tty);
|
||||
if (m->no_firmware && !usbmodem_firmware_present())
|
||||
return g_strdup_printf("%s, with no firmware: put "
|
||||
"mts_mt9234mu.fw in /lib/firmware, "
|
||||
"then connect the modem again", m->name);
|
||||
if (m->no_firmware)
|
||||
return g_strdup_printf("%s, with no firmware: load the "
|
||||
"ti_usb_3410_5052 driver, then connect "
|
||||
"the modem again", m->name);
|
||||
return g_strdup_printf("%s, with no serial port: load the "
|
||||
"ti_usb_3410_5052 driver", m->name);
|
||||
}
|
||||
|
||||
gboolean usbmodem_is(const char *path)
|
||||
{
|
||||
UsbModem *m = usbmodem_find();
|
||||
gboolean is = m && m->tty && path && !strcmp(m->tty, path);
|
||||
usbmodem_free(m);
|
||||
return is;
|
||||
}
|
||||
|
||||
void usbmodem_free(UsbModem *m)
|
||||
{
|
||||
if (!m)
|
||||
return;
|
||||
g_free(m->name);
|
||||
g_free(m->tty);
|
||||
g_free(m);
|
||||
}
|
||||
Reference in new issue
Block a user