Add the Call menu and the COM port settings

HyperTerminal's Call menu for the Windows app: Call (sessions with a
name and a number, kept in [sessions]), Wait for a Call (ATS0=1, sent
again when the modem opens), Disconnect, and Send Break.

Line Settings gets the COM port settings: bits per second, data bits,
parity, stop bits and flow control (none, Xon/Xoff, hardware).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRekyRUhR43KbmGNXK
This commit is contained in:
Claude committed 2026-11-20 23:05:50 +00:00
1 parent afa2c42587
commit 4cd7fc8f56
10 files changed
+447 -17

No files matched your search

+2 -1
View File
@@ -24,7 +24,8 @@ libdmodemctl. Thus they operate in the same way.
- **File transfers** (Windows app): send and receive files on the modem line or on a Telnet, rlogin or SSH login. The protocols are the same as the D-Modem app: ZMODEM (with Automatic Receive when the remote side starts sz, rz or kermit -s, and with Crash Recovery), YMODEM, YMODEM-G, XMODEM, XMODEM-1K, Kermit, Intel HEX, Motorola S-records and plain text. Use the Transfer menu, or the Send and Receive buttons of the Terminal page
- **Copy and capture** (Windows app): select text with the mouse (Shift and the mouse when the remote side uses the mouse), then copy it. Paste to Host, Select All, Capture Text (to a file), Capture to Printer, and Print (the screen or the selection). Text that the remote side sends to its printer port goes to the printer. Use the Edit and Transfer menus, or click the right mouse button on the terminal
- **ASCII Setup** (Windows app, Modem menu): the same items as HyperTerminal. For the data that you send: Enter sends CR LF, the local echo, and the line delay and character delay of a text file. For the data that you receive: an LF after each CR, 7-bit ASCII, and the wrap of long lines. The settings apply to the modem terminal and to the Remote terminal
- **Terminal Settings** (Windows app, Modem menu): the same items as HyperTerminal, for the modem terminal and for the Remote terminal. They are what Backspace sends (Ctrl+H, Del, or Ctrl+H, Space, Ctrl+H), the function, arrow and Ctrl keys as terminal keys or Windows keys, the backscroll buffer lines, the font, the cursor, the Telnet terminal ID, and Exit program upon disconnecting. The status bar shows the connect timer during a call. Send Break (Modem menu, or Ctrl+Break) sends a break on a COM port or a Telnet connection
- **Terminal Settings** (Windows app, Modem menu): the same items as HyperTerminal, for the modem terminal and for the Remote terminal. They are what Backspace sends (Ctrl+H, Del, or Ctrl+H, Space, Ctrl+H), the function, arrow and Ctrl keys as terminal keys or Windows keys, the backscroll buffer lines, the font, the cursor, the Telnet terminal ID, and Exit program upon disconnecting. The status bar shows the connect timer during a call
- **Call menu** (Windows app): Call (sessions with a name and a number, as the connection files of HyperTerminal), Wait for a Call (ATS0=1), Disconnect, and Send Break (Ctrl+Break: a COM port or a Telnet connection). Line Settings has the COM port settings: bits per second, data bits, parity, stop bits and flow control
- **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 (dmodemd, or a hardware modem such as the MultiTech MT9234MU)
+23 -2
View File
@@ -173,11 +173,32 @@ modem's. `dmodem.ini` keeps the settings in `[terminal]` (the modem) and
- `exit_on_disconnect` (modem only): the app closes when a call ends.
The status bar shows the connect timer during a call ("Online 0:01:05").
Send Break (Modem menu, or Ctrl+Break in a terminal) sends a break. On a
Send Break (Call menu, or Ctrl+Break in a terminal) sends a break. On a
COM port, the app holds the line at space for 250 ms (`SetCommBreak`). On
Telnet, the app sends IAC BRK (`dmc_net_break`). TCP to dmodemd, rlogin
and SSH cannot send a break, and the status bar tells you.
`calls.cpp` has the Call menu, as HyperTerminal has it:
- Call opens the Call dialog. A session is a name and a number (or a SIP
address). `dmodem.ini` keeps the sessions in the `[sessions]` section
(`count`, `name1`, `number1` ...). Save adds or changes a session, and
Delete removes it. Call dials the number (ATD) and shows the Terminal
page.
- Wait for a Call sends ATS0=1: the modem answers at the first ring. The
app sends ATS0=1 again each time the modem opens. When you clear the
check mark, the app sends ATS0=0.
- Disconnect hangs up the call (`dmc_hangup`), or closes the Remote
connection when the Remote page shows.
The Line Settings dialog has the settings of a COM port, as the Configure
dialog of HyperTerminal: bits per second (110 to 921,600), data bits (5 to
8), parity (none, odd, even, mark, space), stop bits (1, 1.5, 2) and flow
control (none, Xon/Xoff, hardware). `dmodem.ini` keeps them as `com-bps`,
`com-data-bits`, `com-parity`, `com-stop-bits` and `com-flow`. The default
is 115,200 bps, 8 data bits, no parity, 1 stop bit and hardware flow
control.
`capture.cpp` has the captures. Each capture is of one line (the modem or
the Remote login). The capture does not get the bytes of a file transfer.
@@ -522,7 +543,7 @@ Windows.
| Function | The stand-in |
| --- | --- |
| `waveOut*`, `waveIn*` (`mmsystem.h`), `acm*` (`msacm.h`) | Returns `MMSYSERR_NODRIVER`. The Phone page cannot play or record. |
| `GetCommState`, `SetCommState`, `SetCommTimeouts` (COM ports) | Returns `FALSE` (`ERROR_NOT_SUPPORTED`). Do not use a COM port. |
| `GetCommState`, `SetCommState`, `SetCommTimeouts`, `SetCommBreak`, `ClearCommBreak` (COM ports) | Returns `FALSE` (`ERROR_NOT_SUPPORTED`). Do not use a COM port. |
| `CreatePipe`, `PeekNamedPipe` | Returns `FALSE`. The app cannot start dmodemd. |
| `GetEnvironmentStrings`, `GetUserName`, `Beep` | Uses `environ`, `$USER` and `MessageBeep`. |
| `ListView_*`, `TabCtrl_*` (`commctrl.h`), `winsock.h` | Macros and an include of `winsock2.h`. |
+41 -6
View File
@@ -21,12 +21,19 @@ BEGIN
MENUITEM "&Line Settings...", IDM_LINE
MENUITEM "&ASCII Setup...", IDM_ASCII
MENUITEM "&Terminal Settings...", IDM_TERMSET
MENUITEM "Send &Break\tCtrl+Break", IDM_BREAK
MENUITEM SEPARATOR
MENUITEM "&Print...", IDM_FPRINT
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_EXIT
END
POPUP "&Call"
BEGIN
MENUITEM "&Call...", IDM_CALL
MENUITEM "&Wait for a Call", IDM_WAITCALL
MENUITEM "&Disconnect", IDM_DISCONNECT
MENUITEM SEPARATOR
MENUITEM "Send &Break\tCtrl+Break", IDM_BREAK
END
POPUP "&Edit"
BEGIN
MENUITEM "&Copy\tCtrl+Insert", IDM_EDCOPY
@@ -56,7 +63,7 @@ BEGIN
END
END
IDD_LINE DIALOG 0, 0, 300, 286
IDD_LINE DIALOG 0, 0, 300, 318
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Line Settings"
FONT 8, "MS Shell Dlg"
@@ -88,10 +95,20 @@ BEGIN
AUTORADIOBUTTON "A modem on a &serial port", IDC_L_COM, 8, 198, 284, 10, WS_TABSTOP
LTEXT "P&ort:", -1, 20, 214, 60, 8
COMBOBOX IDC_L_PORT, 84, 212, 80, 120, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
LTEXT "Commands when the modem &opens:", -1, 8, 236, 140, 8
EDITTEXT IDC_L_INIT, 8, 246, 284, 12, ES_AUTOHSCROLL
DEFPUSHBUTTON "OK", IDOK, 186, 266, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 242, 266, 50, 14
LTEXT "Bits per s&econd:", -1, 172, 214, 58, 8
COMBOBOX IDC_L_BPS, 232, 212, 60, 160, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
LTEXT "Data b&its:", -1, 20, 230, 60, 8
COMBOBOX IDC_L_DATA, 84, 228, 30, 80, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Parit&y:", -1, 120, 230, 28, 8
COMBOBOX IDC_L_PARITY, 150, 228, 50, 80, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Stop bi&ts:", -1, 206, 230, 40, 8
COMBOBOX IDC_L_STOP, 248, 228, 44, 80, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "&Flow control:", -1, 20, 246, 60, 8
COMBOBOX IDC_L_FLOW, 84, 244, 80, 80, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Commands when the modem &opens:", -1, 8, 266, 140, 8
EDITTEXT IDC_L_INIT, 8, 276, 284, 12, ES_AUTOHSCROLL
DEFPUSHBUTTON "OK", IDOK, 186, 298, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 242, 298, 50, 14
END
IDD_SETTING DIALOG 0, 0, 240, 110
@@ -194,6 +211,24 @@ BEGIN
PUSHBUTTON "Cancel", IDCANCEL, 222, 130, 50, 14
END
/* the Call menu's Call: a session (a name and a number) chosen, saved or
deleted, and the number called */
IDD_CALL DIALOG 0, 0, 240, 90
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Call"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "&Session:", -1, 8, 10, 60, 8
COMBOBOX IDC_C_NAME, 70, 8, 162, 140, CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
LTEXT "&Phone number:", -1, 8, 28, 60, 8
EDITTEXT IDC_C_NUMBER, 70, 26, 162, 12, ES_AUTOHSCROLL
LTEXT "A number, or a SIP address (sip:user@host).", -1, 70, 42, 162, 8
PUSHBUTTON "Sa&ve", IDC_C_SAVE, 8, 68, 50, 14
PUSHBUTTON "&Delete", IDC_C_DELETE, 62, 68, 50, 14
DEFPUSHBUTTON "&Call", IDOK, 128, 68, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 182, 68, 50, 14
END
/* the Modem menu's Terminal Settings, as HyperTerminal has them, for the
terminal of the page shown (the Remote page's, else the modem's) */
IDD_TERMSET DIALOG 0, 0, 284, 232
+2 -1
View File
@@ -15,5 +15,6 @@ set(DMODEM_WIN_SOURCES
xfer.cpp
capture.cpp
ascii.cpp
termset.cpp)
termset.cpp
calls.cpp)
list(TRANSFORM DMODEM_WIN_SOURCES PREPEND "${CMAKE_CURRENT_LIST_DIR}/src/")
+13
View File
@@ -79,6 +79,11 @@ struct Config {
char dmodemd[MAX_PATH]; /* dmodemd.exe, "" next to the app */
char tcp[256]; /* host:port */
char com[32]; /* COM1 */
/* the COM port's settings, as HyperTerminal's Configure: bits per
second, data bits (5 to 8), parity (0 none, 1 odd, 2 even, 3 mark,
4 space), stop bits (0 one, 1 one and a half, 2 two), flow control
(0 none, 1 Xon/Xoff, 2 hardware) */
int com_bps, com_data, com_parity, com_stop, com_flow;
char init[256]; /* commands when the modem opens */
/* the answering machine ([voice]): on, after how many RINGs, a
message's longest (s) */
@@ -249,6 +254,14 @@ void xfer_set_auto(bool on);
/* the transfer's dialog's keys (IsDialogMessage) */
bool xfer_dialog_key(MSG *m);
/* calls.cpp: the Call dialog (the sessions in [sessions]): the number
chosen into number; Wait for a Call (ATS0=1), sent again when the
modem opens */
bool call_dialog(HWND parent, char *number, int n);
bool call_waiting();
void call_wait(bool on);
void call_opened();
/* termset.cpp: Terminal Settings, for the modem's terminal or the
Remote page's ([terminal], [remote_terminal] in dmodem.ini) */
void termset_apply(HWND view, bool remote);
+208
View File
@@ -0,0 +1,208 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright (C) 2026 D-Modem Authors
*
* calls.cpp - the Call menu's Call dialog: the sessions, as
* HyperTerminal's connection files have them (a name and a
* number, kept in [sessions] of dmodem.ini), the number to
* dial chosen or typed; and Wait for a Call (ATS0=1).
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "app.h"
#include "resource.h"
#define MAX_SESSIONS 64
struct Session {
char name[64];
char number[128];
};
static Session sessions[MAX_SESSIONS];
static int n_sessions;
static char *dial_out; /* the number chosen, for the caller */
static int dial_max;
static void ini(char *out, int n)
{
char dir[MAX_PATH];
app_data_dir(dir, sizeof(dir));
_snprintf(out, n, "%s\\dmodem.ini", dir);
out[n - 1] = '\0';
}
static void load()
{
char path[MAX_PATH], key[32];
ini(path, sizeof(path));
n_sessions = 0;
int n = (int)GetPrivateProfileInt("sessions", "count", 0, path);
for (int i = 0; i < n && n_sessions < MAX_SESSIONS; i++) {
Session *s = &sessions[n_sessions];
_snprintf(key, sizeof(key), "name%d", i + 1);
GetPrivateProfileString("sessions", key, "", s->name, sizeof(s->name), path);
_snprintf(key, sizeof(key), "number%d", i + 1);
GetPrivateProfileString("sessions", key, "", s->number, sizeof(s->number), path);
if (s->name[0])
n_sessions++;
}
}
static void save()
{
char path[MAX_PATH], key[32], v[16];
ini(path, sizeof(path));
/* (the section written again: no entries left from before) */
WritePrivateProfileString("sessions", NULL, NULL, path);
_snprintf(v, sizeof(v), "%d", n_sessions);
WritePrivateProfileString("sessions", "count", v, path);
for (int i = 0; i < n_sessions; i++) {
_snprintf(key, sizeof(key), "name%d", i + 1);
WritePrivateProfileString("sessions", key, sessions[i].name, path);
_snprintf(key, sizeof(key), "number%d", i + 1);
WritePrivateProfileString("sessions", key, sessions[i].number, path);
}
}
static int find(const char *name)
{
for (int i = 0; i < n_sessions; i++)
if (!lstrcmpi(sessions[i].name, name))
return i;
return -1;
}
static void fill(HWND d, const char *sel)
{
HWND c = GetDlgItem(d, IDC_C_NAME);
SendMessage(c, CB_RESETCONTENT, 0, 0);
for (int i = 0; i < n_sessions; i++)
SendMessage(c, CB_ADDSTRING, 0, (LPARAM)sessions[i].name);
SetWindowText(c, sel);
}
/* the session chosen in the list: its number */
static void picked(HWND d)
{
int i = (int)SendDlgItemMessage(d, IDC_C_NAME, CB_GETCURSEL, 0, 0);
char name[64];
if (i < 0)
return;
SendDlgItemMessage(d, IDC_C_NAME, CB_GETLBTEXT, (WPARAM)i, (LPARAM)name);
int k = find(name);
if (k >= 0)
SetDlgItemText(d, IDC_C_NUMBER, sessions[k].number);
}
static INT_PTR CALLBACK call_proc(HWND d, UINT m, WPARAM wp, LPARAM lp)
{
(void)lp;
char name[64], number[128];
switch (m) {
case WM_INITDIALOG:
fill(d, n_sessions ? sessions[0].name : "");
if (n_sessions)
SetDlgItemText(d, IDC_C_NUMBER, sessions[0].number);
return TRUE;
case WM_COMMAND:
GetDlgItemText(d, IDC_C_NAME, name, sizeof(name));
GetDlgItemText(d, IDC_C_NUMBER, number, sizeof(number));
switch (LOWORD(wp)) {
case IDC_C_NAME:
if (HIWORD(wp) == CBN_SELCHANGE)
picked(d);
return TRUE;
case IDC_C_SAVE: {
if (!name[0] || !number[0]) {
MessageBox(d, "Type a name and a number to save the session.",
"Call", MB_OK | MB_ICONINFORMATION);
return TRUE;
}
int k = find(name);
if (k < 0) {
if (n_sessions >= MAX_SESSIONS)
return TRUE;
k = n_sessions++;
}
_snprintf(sessions[k].name, sizeof(sessions[k].name), "%s", name);
_snprintf(sessions[k].number, sizeof(sessions[k].number), "%s", number);
save();
fill(d, name);
return TRUE;
}
case IDC_C_DELETE: {
int k = find(name);
if (k < 0)
return TRUE;
memmove(&sessions[k], &sessions[k + 1],
(size_t)(n_sessions - k - 1) * sizeof(Session));
n_sessions--;
save();
fill(d, "");
SetDlgItemText(d, IDC_C_NUMBER, "");
return TRUE;
}
case IDOK:
if (!number[0]) {
MessageBox(d, "Type a number or a SIP address (sip:user@host) to call.",
"Call", MB_OK | MB_ICONINFORMATION);
return TRUE;
}
_snprintf(dial_out, dial_max, "%s", number);
dial_out[dial_max - 1] = '\0';
EndDialog(d, IDOK);
return TRUE;
case IDCANCEL:
EndDialog(d, IDCANCEL);
return TRUE;
}
break;
}
return FALSE;
}
bool call_dialog(HWND parent, char *number, int n)
{
load();
dial_out = number;
dial_max = n;
return DialogBoxParam(app.inst, MAKEINTRESOURCE(IDD_CALL), parent,
call_proc, 0) == IDOK;
}
static bool waiting;
bool call_waiting()
{
return waiting;
}
static void wait_done(const dmc_event *ev, void *data)
{
(void)data;
if (!ev->ok) {
waiting = false;
app_message(ev->result);
}
}
void call_wait(bool on)
{
waiting = on;
if (!link_open()) {
/* (sent when the modem opens: call_opened) */
return;
}
link_command(on ? "ATS0=1" : "ATS0=0", 0, wait_done, NULL);
app_message(on ? "Waiting for a call: the modem answers at the first ring" :
"Not waiting for a call");
}
void call_opened()
{
if (waiting)
link_command("ATS0=1", 0, wait_done, NULL);
}
+77 -1
View File
@@ -112,6 +112,22 @@ void config_load(Config *c)
get(ini, "dmodemd", "", c->dmodemd, sizeof(c->dmodemd));
get(ini, "tcp", "127.0.0.1:2323", c->tcp, sizeof(c->tcp));
get(ini, "com", "COM1", c->com, sizeof(c->com));
/* (115,200 bps, 8N1, RTS/CTS: as it was before these settings) */
c->com_bps = get_i(ini, "com-bps", 115200);
if (c->com_bps < 110)
c->com_bps = 115200;
c->com_data = get_i(ini, "com-data-bits", 8);
if (c->com_data < 5 || c->com_data > 8)
c->com_data = 8;
c->com_parity = get_i(ini, "com-parity", 0);
if (c->com_parity < 0 || c->com_parity > 4)
c->com_parity = 0;
c->com_stop = get_i(ini, "com-stop-bits", 0);
if (c->com_stop < 0 || c->com_stop > 2)
c->com_stop = 0;
c->com_flow = get_i(ini, "com-flow", 2);
if (c->com_flow < 0 || c->com_flow > 2)
c->com_flow = 2;
get(ini, "init", "", c->init, sizeof(c->init));
/* the answering machine: off until the user turns it on */
c->voicemail = (int)GetPrivateProfileInt("voice", "voicemail", 0, ini);
@@ -141,6 +157,11 @@ void config_save(const Config *c)
put(ini, "dmodemd", c->dmodemd);
put(ini, "tcp", c->tcp);
put(ini, "com", c->com);
put_i(ini, "com-bps", c->com_bps);
put_i(ini, "com-data-bits", c->com_data);
put_i(ini, "com-parity", c->com_parity);
put_i(ini, "com-stop-bits", c->com_stop);
put_i(ini, "com-flow", c->com_flow);
put(ini, "init", c->init);
char b[16];
_snprintf(b, sizeof(b), "%d", c->voicemail);
@@ -161,7 +182,10 @@ void config_summary(const Config *c, char *out, int n)
_snprintf(out, n, "dmodemd at %s", c->tcp);
break;
case LINE_COM:
_snprintf(out, n, "The modem on %s", c->com);
/* (as HyperTerminal's status bar: 115200 8-N-1) */
_snprintf(out, n, "The modem on %s (%d %d-%c-%s)", c->com,
c->com_bps, c->com_data, "NOEMS"[c->com_parity],
c->com_stop == 1 ? "1.5" : c->com_stop == 2 ? "2" : "1");
break;
default:
if (c->usb[0])
@@ -190,6 +214,30 @@ bool config_sip_ready(const Config *c)
static Config *editing;
/* the choices of the COM port's settings, as HyperTerminal lists them */
static const int bps_list[] = {
110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600,
115200, 230400, 460800, 921600, 0
};
static const char *const parity_names[] = { "None", "Odd", "Even", "Mark", "Space", NULL };
static const char *const stop_names[] = { "1", "1.5", "2", NULL };
static const char *const flow_names[] = { "None", "Xon / Xoff", "Hardware", NULL };
/* a list of names into a combo box, [sel] chosen */
static void fill(HWND d, int id, const char *const *names, int sel)
{
HWND c = GetDlgItem(d, id);
for (int i = 0; names[i]; i++)
SendMessage(c, CB_ADDSTRING, 0, (LPARAM)names[i]);
SendMessage(c, CB_SETCURSEL, (WPARAM)sel, 0);
}
static int chosen(HWND d, int id, int def)
{
int i = (int)SendDlgItemMessage(d, id, CB_GETCURSEL, 0, 0);
return i < 0 ? def : i;
}
static void enable(HWND d)
{
bool here = IsDlgButtonChecked(d, IDC_L_DMODEMD) == BST_CHECKED;
@@ -211,6 +259,11 @@ static void enable(HWND d)
EnableWindow(GetDlgItem(d, account_ids[i]), here && !anon);
EnableWindow(GetDlgItem(d, IDC_L_ADDRESS), tcp);
EnableWindow(GetDlgItem(d, IDC_L_PORT), com);
static const int com_ids[] = {
IDC_L_BPS, IDC_L_DATA, IDC_L_PARITY, IDC_L_STOP, IDC_L_FLOW, 0
};
for (int i = 0; com_ids[i]; i++)
EnableWindow(GetDlgItem(d, com_ids[i]), com);
}
static void check(HWND d, int id, int on)
@@ -268,6 +321,19 @@ static BOOL CALLBACK line_proc(HWND d, UINT m, WPARAM wp, LPARAM lp)
SendMessage(port, CB_ADDSTRING, 0, (LPARAM)n);
}
SetWindowText(port, c->com);
HWND bps = GetDlgItem(d, IDC_L_BPS);
for (int i = 0; bps_list[i]; i++) {
char n[16];
_snprintf(n, sizeof(n), "%d", bps_list[i]);
n[sizeof(n) - 1] = '\0';
SendMessage(bps, CB_ADDSTRING, 0, (LPARAM)n);
}
SetDlgItemInt(d, IDC_L_BPS, (UINT)c->com_bps, FALSE);
static const char *const data_names[] = { "5", "6", "7", "8", NULL };
fill(d, IDC_L_DATA, data_names, c->com_data - 5);
fill(d, IDC_L_PARITY, parity_names, c->com_parity);
fill(d, IDC_L_STOP, stop_names, c->com_stop);
fill(d, IDC_L_FLOW, flow_names, c->com_flow);
SetDlgItemText(d, IDC_L_INIT, c->init);
enable(d);
return TRUE;
@@ -301,6 +367,16 @@ static BOOL CALLBACK line_proc(HWND d, UINT m, WPARAM wp, LPARAM lp)
GetDlgItemText(d, IDC_L_PATH, c->dmodemd, sizeof(c->dmodemd));
GetDlgItemText(d, IDC_L_ADDRESS, c->tcp, sizeof(c->tcp));
GetDlgItemText(d, IDC_L_PORT, c->com, sizeof(c->com));
{
char b[16];
GetDlgItemText(d, IDC_L_BPS, b, sizeof(b));
int v = atoi(b);
c->com_bps = v >= 110 ? v : 115200;
}
c->com_data = 5 + chosen(d, IDC_L_DATA, 3);
c->com_parity = chosen(d, IDC_L_PARITY, 0);
c->com_stop = chosen(d, IDC_L_STOP, 0);
c->com_flow = chosen(d, IDC_L_FLOW, 2);
GetDlgItemText(d, IDC_L_INIT, c->init, sizeof(c->init));
EndDialog(d, IDOK);
return TRUE;
+15 -6
View File
@@ -166,14 +166,23 @@ static bool open_com(const char *name)
memset(&dcb, 0, sizeof(dcb));
dcb.DCBlength = sizeof(dcb);
GetCommState(com, &dcb);
dcb.BaudRate = CBR_115200;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
/* Line Settings' bits per second, data bits, parity, stop bits and
flow control (Xon/Xoff: DC1 and DC3, both ways; hardware: RTS and
CTS) */
dcb.BaudRate = (DWORD)app.cfg.com_bps;
dcb.ByteSize = (BYTE)app.cfg.com_data;
dcb.Parity = (BYTE)app.cfg.com_parity;
dcb.fParity = app.cfg.com_parity != 0;
dcb.StopBits = (BYTE)app.cfg.com_stop;
dcb.fBinary = TRUE;
dcb.fDtrControl = DTR_CONTROL_ENABLE;
dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
dcb.fOutxCtsFlow = TRUE;
dcb.fRtsControl = app.cfg.com_flow == 2 ? RTS_CONTROL_HANDSHAKE : 0x01;
dcb.fOutxCtsFlow = app.cfg.com_flow == 2;
dcb.fOutX = dcb.fInX = app.cfg.com_flow == 1;
dcb.XonChar = 0x11;
dcb.XoffChar = 0x13;
dcb.XonLim = 256;
dcb.XoffLim = 256;
SetCommState(com, &dcb);
/* reads return at once with what there is */
COMMTIMEOUTS t;
+51
View File
@@ -163,6 +163,7 @@ void app_state()
void app_opened()
{
app_state();
call_opened();
settings_load();
stats_refresh();
}
@@ -244,6 +245,14 @@ static HWND view_now()
return l->view ? *l->view : NULL;
}
/* a call's ATD answered: its result when it failed (NO CARRIER, BUSY) */
static void call_done(const dmc_event *ev, void *data)
{
(void)data;
if (!ev->ok)
app_message(ev->result);
}
static void show_page(int i)
{
page_now = i;
@@ -352,6 +361,36 @@ static LRESULT CALLBACK main_proc(HWND w, UINT m, WPARAM wp, LPARAM lp)
case IDM_ASCII:
ascii_dialog(w);
return 0;
case IDM_CALL: {
char n[128];
if (dmc_state(app.s) != DMC_IDLE) {
app_message(link_running() ?
"The modem is not idle: disconnect first" :
"Start the modem first (Modem menu)");
return 0;
}
if (!call_dialog(w, n, sizeof(n)))
return 0;
char cmd[140];
_snprintf(cmd, sizeof(cmd), "ATD%s", n);
cmd[sizeof(cmd) - 1] = '\0';
link_command(cmd, 0, call_done, NULL);
/* (the call on the Terminal page, as HyperTerminal) */
TabCtrl_SetCurSel(app.tabs, PAGE_TERM);
show_page(PAGE_TERM);
return 0;
}
case IDM_WAITCALL:
call_wait(!call_waiting());
return 0;
case IDM_DISCONNECT:
if (line_now() == &remote_line) {
remote_stop();
} else {
dmc_hangup(app.s);
link_pump();
}
return 0;
case IDM_TERMSET:
termset_dialog(w, line_now() == &remote_line);
return 0;
@@ -428,6 +467,18 @@ static LRESULT CALLBACK main_proc(HWND w, UINT m, WPARAM wp, LPARAM lp)
EnableMenuItem(m, IDM_SEND, MF_BYCOMMAND | (busy ? MF_GRAYED : MF_ENABLED));
EnableMenuItem(m, IDM_RECEIVE, MF_BYCOMMAND | (busy ? MF_GRAYED : MF_ENABLED));
EnableMenuItem(m, IDM_XCANCEL, MF_BYCOMMAND | (busy ? MF_ENABLED : MF_GRAYED));
{
int st = dmc_state(app.s);
bool remote = line_now() == &remote_line;
EnableMenuItem(m, IDM_CALL, MF_BYCOMMAND |
(st == DMC_IDLE ? MF_ENABLED : MF_GRAYED));
CheckMenuItem(m, IDM_WAITCALL, MF_BYCOMMAND |
(call_waiting() ? MF_CHECKED : MF_UNCHECKED));
EnableMenuItem(m, IDM_DISCONNECT, MF_BYCOMMAND |
(remote || st == DMC_DIALING ||
st == DMC_ANSWERING || st == DMC_ONLINE ||
st == DMC_ONLINE_COMMAND ? MF_ENABLED : MF_GRAYED));
}
CheckMenuItem(m, IDM_AUTORECV, MF_BYCOMMAND |
(xfer_auto() ? MF_CHECKED : MF_UNCHECKED));
HWND v = view_now();
+15
View File
@@ -30,6 +30,9 @@
#define IDM_ASCII 217
#define IDM_TERMSET 218
#define IDM_BREAK 219
#define IDM_CALL 220
#define IDM_WAITCALL 221
#define IDM_DISCONNECT 222
#define IDC_STATUS 300
#define IDC_TABS 301
@@ -139,6 +142,11 @@
#define IDC_L_PORT 916
#define IDC_L_INIT 917
#define IDC_L_ANONYMOUS 918
#define IDC_L_BPS 919
#define IDC_L_DATA 920
#define IDC_L_PARITY 921
#define IDC_L_STOP 922
#define IDC_L_FLOW 923
/* the Change Setting dialog */
#define IDD_SETTING 950
@@ -204,6 +212,13 @@
#define IDC_A_7BIT 1246
#define IDC_A_WRAP 1247
/* the Call dialog */
#define IDD_CALL 1270
#define IDC_C_NAME 1271
#define IDC_C_NUMBER 1272
#define IDC_C_SAVE 1273
#define IDC_C_DELETE 1274
/* Terminal Settings */
#define IDD_TERMSET 1250
#define IDC_T_BSH 1251