Skip to content
Snippets Groups Projects
Commit 1df142e3 authored by rswindell's avatar rswindell
Browse files

Make modem/comm rate configurable (defaults to "current").

First attempt at making dialing abortable.
Some minor cosmetic/wording updates.
parent 763317c1
No related branches found
No related tags found
No related merge requests found
...@@ -1056,8 +1056,8 @@ void change_settings(void) ...@@ -1056,8 +1056,8 @@ void change_settings(void)
char inipath[MAX_PATH+1]; char inipath[MAX_PATH+1];
FILE *inifile; FILE *inifile;
str_list_t inicontents; str_list_t inicontents;
char opts[8][80]; char opts[9][80];
char *opt[9]; char *opt[10];
int i,j; int i,j;
char str[64]; char str[64];
int cur=0; int cur=0;
...@@ -1071,7 +1071,7 @@ void change_settings(void) ...@@ -1071,7 +1071,7 @@ void change_settings(void)
inicontents=strListInit(); inicontents=strListInit();
} }
for(i=0; i<8; i++) for(i=0; i<9; i++)
opt[i]=opts[i]; opt[i]=opts[i];
opt[i]=NULL; opt[i]=NULL;
...@@ -1084,12 +1084,14 @@ void change_settings(void) ...@@ -1084,12 +1084,14 @@ void change_settings(void)
" Prompt to save new URIs on before exiting\n\n" " Prompt to save new URIs on before exiting\n\n"
"~ Startup Screen Mode ~\n" "~ Startup Screen Mode ~\n"
" Set the initial screen screen mode/size.\n\n" " Set the initial screen screen mode/size.\n\n"
"~ Output Mode ~\n" "~ Video Output Mode ~\n"
" Set video output mode.\n\n" " Set video output mode (used during startup).\n\n"
"~ Scrollback Buffer Lines ~\n" "~ Scrollback Buffer Lines ~\n"
" The number of lines in the scrollback buffer.\n\n" " The number of lines in the scrollback buffer.\n\n"
"~ Modem Device ~\n" "~ Modem/Comm Device ~\n"
" The device name of the modem's communications port.\n\n" " The device name of the modem's communications port.\n\n"
"~ Modem/Comm Rate ~\n"
" The DTE rate of the modem's communications port.\n\n"
"~ Modem Init String ~\n" "~ Modem Init String ~\n"
" The command string to use to initialize the modem.\n\n" " The command string to use to initialize the modem.\n\n"
"~ Modem Dial String ~\n" "~ Modem Dial String ~\n"
...@@ -1097,11 +1099,16 @@ void change_settings(void) ...@@ -1097,11 +1099,16 @@ void change_settings(void)
sprintf(opts[0],"Confirm Program Exit %s",settings.confirm_close?"Yes":"No"); sprintf(opts[0],"Confirm Program Exit %s",settings.confirm_close?"Yes":"No");
sprintf(opts[1],"Prompt to Save %s",settings.prompt_save?"Yes":"No"); sprintf(opts[1],"Prompt to Save %s",settings.prompt_save?"Yes":"No");
sprintf(opts[2],"Startup Screen Mode %s",screen_modes[settings.startup_mode]); sprintf(opts[2],"Startup Screen Mode %s",screen_modes[settings.startup_mode]);
sprintf(opts[3],"Output Mode %s",output_descrs[settings.output_mode]); sprintf(opts[3],"Video Output Mode %s",output_descrs[settings.output_mode]);
sprintf(opts[4],"Scrollback Buffer Lines %d",settings.backlines); sprintf(opts[4],"Scrollback Buffer Lines %d",settings.backlines);
sprintf(opts[5],"Modem Device %s",settings.mdm.device_name); sprintf(opts[5],"Modem/Comm Device %s",settings.mdm.device_name);
sprintf(opts[6],"Modem Init String %s",settings.mdm.init_string); if(settings.mdm.com_rate)
sprintf(opts[7],"Modem Dial String %s",settings.mdm.dial_string); sprintf(str,"%ubps",settings.mdm.com_rate);
else
strcpy(str,"Current");
sprintf(opts[6],"Modem/Comm Rate %s",str);
sprintf(opts[7],"Modem Init String %s",settings.mdm.init_string);
sprintf(opts[8],"Modem Dial String %s",settings.mdm.dial_string);
switch(uifc.list(WIN_MID|WIN_SAV|WIN_ACT,0,0,0,&cur,NULL,"Program Settings",opt)) { switch(uifc.list(WIN_MID|WIN_SAV|WIN_ACT,0,0,0,&cur,NULL,"Program Settings",opt)) {
case -1: case -1:
goto write_ini; goto write_ini;
...@@ -1132,7 +1139,7 @@ void change_settings(void) ...@@ -1132,7 +1139,7 @@ void change_settings(void)
break; break;
if(output_types[j]==NULL) if(output_types[j]==NULL)
j=0; j=0;
uifc.helpbuf= "`Output Mode`\n\n" uifc.helpbuf= "`Video Output Mode`\n\n"
"~ Autodetect ~\n" "~ Autodetect ~\n"
" Attempt to use the \"best\" display mode possible. The order\n" " Attempt to use the \"best\" display mode possible. The order\n"
" these are attempted is:" " these are attempted is:"
...@@ -1189,7 +1196,7 @@ void change_settings(void) ...@@ -1189,7 +1196,7 @@ void change_settings(void)
" As above, but starts in full-screen mode rather than a window\n\n" " As above, but starts in full-screen mode rather than a window\n\n"
#endif #endif
; ;
switch(i=uifc.list(WIN_SAV,0,0,0,&j,NULL,"Output Mode",output_types)) { switch(i=uifc.list(WIN_SAV,0,0,0,&j,NULL,"Video Output Mode",output_types)) {
case -1: case -1:
continue; continue;
default: default:
...@@ -1229,20 +1236,32 @@ void change_settings(void) ...@@ -1229,20 +1236,32 @@ void change_settings(void)
} }
break; break;
case 5: case 5:
uifc.helpbuf= "`Modem Device`\n\n" uifc.helpbuf= "`Modem/Comm Device`\n\n"
"Enter the name of the device used to communicate with the modem.\n\n" "Enter the name of the device used to communicate with the modem.\n\n"
"Example: \"`" "Example: \"`"
DEFAULT_MODEM_DEV DEFAULT_MODEM_DEV
"`\""; "`\"";
if(uifc.input(WIN_MID|WIN_SAV,0,0,"Modem Device",settings.mdm.device_name,LIST_NAME_MAX,K_EDIT)>=0) if(uifc.input(WIN_MID|WIN_SAV,0,0,"Modem/Comm Device",settings.mdm.device_name,LIST_NAME_MAX,K_EDIT)>=0)
iniSetString(&inicontents,"SyncTERM","ModemDevice",settings.mdm.device_name,&ini_style); iniSetString(&inicontents,"SyncTERM","ModemDevice",settings.mdm.device_name,&ini_style);
break; break;
case 6: case 6:
uifc.helpbuf= "`Modem/Comm Rate`\n\n"
"Enter the rate (in bits-per-second) used to communicate with the modem.\n"
"Use the highest `DTE Rate` supported by your communication port and modem.\n\n"
"Examples: `38400`, `57600`, `115200`";
sprintf(str,"%u",settings.mdm.com_rate ? settings.mdm.com_rate : 115200);
if(uifc.input(WIN_MID|WIN_SAV,0,0,"Modem/Comm Rate",str,LIST_NAME_MAX,K_EDIT)>=0) {
settings.mdm.com_rate=strtol(str,NULL,10);
iniSetLongInt(&inicontents,"SyncTERM","ModemComRate",settings.mdm.com_rate,&ini_style);
}
break;
case 7:
uifc.helpbuf= "`Modem Init String`\n\n" uifc.helpbuf= "`Modem Init String`\n\n"
"Your modem initialization string goes here.\n\n" "Your modem initialization string goes here.\n\n"
"Example:\n" "Example:\n"
"\"`AT&F`\" will load a Hayes compatible modem's factory default settings.\n\n" "\"`AT&F`\" will load a Hayes compatible modem's factory default settings.\n\n"
"For reference, here are the expected Hayes-compatible settings:\n\n" "~For reference, here are the expected Hayes-compatible settings:~\n\n"
"State Command\n" "State Command\n"
"----------------------------------\n" "----------------------------------\n"
"Echo on E1\n" "Echo on E1\n"
...@@ -1250,7 +1269,7 @@ void change_settings(void) ...@@ -1250,7 +1269,7 @@ void change_settings(void)
"Normal CD Handling &C1\n" "Normal CD Handling &C1\n"
"Normal DTR &D2\n" "Normal DTR &D2\n"
"\n\n" "\n\n"
"For reference, here are the expected USRobotics-compatible settings:\n\n" "~For reference, here are the expected USRobotics-compatible settings:~\n\n"
"State Command\n" "State Command\n"
"----------------------------------\n" "----------------------------------\n"
"Include connection speed &X4\n" "Include connection speed &X4\n"
...@@ -1260,7 +1279,7 @@ void change_settings(void) ...@@ -1260,7 +1279,7 @@ void change_settings(void)
if(uifc.input(WIN_MID|WIN_SAV,0,0,"Modem Init String",settings.mdm.init_string,LIST_NAME_MAX,K_EDIT)>=0) if(uifc.input(WIN_MID|WIN_SAV,0,0,"Modem Init String",settings.mdm.init_string,LIST_NAME_MAX,K_EDIT)>=0)
iniSetString(&inicontents,"SyncTERM","ModemInit",settings.mdm.init_string,&ini_style); iniSetString(&inicontents,"SyncTERM","ModemInit",settings.mdm.init_string,&ini_style);
break; break;
case 7: case 8:
uifc.helpbuf= "`Modem Dial String`\n\n" uifc.helpbuf= "`Modem Dial String`\n\n"
"The command string to dial the modem goes here.\n\n" "The command string to dial the modem goes here.\n\n"
"Example: \"`ATDT`\" will dial a Hayes-compatible modem in touch-tone mode."; "Example: \"`ATDT`\" will dial a Hayes-compatible modem in touch-tone mode.";
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "comio.h" #include "comio.h"
#include "ciolib.h"
#include "sockwrap.h" #include "sockwrap.h"
...@@ -117,12 +118,14 @@ int modem_connect(struct bbslist *bbs) ...@@ -117,12 +118,14 @@ int modem_connect(struct bbslist *bbs)
conn_api.terminate=-1; conn_api.terminate=-1;
return(-1); return(-1);
} }
if(!comSetBaudRate(com, 115200)) { if(settings.mdm.com_rate) {
if(!comSetBaudRate(com, settings.mdm.com_rate)) {
uifcmsg("Cannot Set Baudrate", "`Cannot Set Baudrate`\n\n" uifcmsg("Cannot Set Baudrate", "`Cannot Set Baudrate`\n\n"
"Cannot open the specified modem device.\n"); "Cannot open the specified modem device.\n");
conn_api.terminate=-1; conn_api.terminate=-1;
return(-1); return(-1);
} }
}
if(!comRaiseDTR(com)) { if(!comRaiseDTR(com)) {
uifcmsg("Cannot Raise DTR", "`Cannot Raise DTR`\n\n" uifcmsg("Cannot Raise DTR", "`Cannot Raise DTR`\n\n"
"comRaiseDTR() returned an error.\n"); "comRaiseDTR() returned an error.\n");
...@@ -178,6 +181,14 @@ int modem_connect(struct bbslist *bbs) ...@@ -178,6 +181,14 @@ int modem_connect(struct bbslist *bbs)
} }
if(strstr(respbuf, bbs->addr)) /* Dial command echoed */ if(strstr(respbuf, bbs->addr)) /* Dial command echoed */
continue; continue;
/* Abort with keystroke */
if(kbhit()) {
modem_close();
uifc.pop(NULL);
uifcmsg("Aborted", "Dialing aborted");
conn_api.terminate=-1;
return(-1);
}
break; break;
} }
......
...@@ -979,7 +979,7 @@ void load_settings(struct syncterm_settings *set) ...@@ -979,7 +979,7 @@ void load_settings(struct syncterm_settings *set)
iniReadString(inifile, "SyncTERM", "ModemInit", "AT&F", set->mdm.init_string); iniReadString(inifile, "SyncTERM", "ModemInit", "AT&F", set->mdm.init_string);
iniReadString(inifile, "SyncTERM", "ModemDial", "ATDT", set->mdm.dial_string); iniReadString(inifile, "SyncTERM", "ModemDial", "ATDT", set->mdm.dial_string);
iniReadString(inifile, "SyncTERM", "ModemDevice", DEFAULT_MODEM_DEV, set->mdm.device_name); iniReadString(inifile, "SyncTERM", "ModemDevice", DEFAULT_MODEM_DEV, set->mdm.device_name);
set->mdm.com_rate=iniReadLongInt(inifile, "SyncTERM", "ModemComRate", 0);
/* Sort order */ /* Sort order */
sortby=iniReadStringList(inifile, "SyncTERM", "SortOrder", ",", "5,1"); sortby=iniReadStringList(inifile, "SyncTERM", "SortOrder", ",", "5,1");
while((order=strListRemove(&sortby,0))!=NULL) { while((order=strListRemove(&sortby,0))!=NULL) {
......
...@@ -31,6 +31,7 @@ struct modem_settings { ...@@ -31,6 +31,7 @@ struct modem_settings {
char init_string[INI_MAX_VALUE_LEN]; char init_string[INI_MAX_VALUE_LEN];
char dial_string[INI_MAX_VALUE_LEN]; char dial_string[INI_MAX_VALUE_LEN];
char device_name[INI_MAX_VALUE_LEN+1]; char device_name[INI_MAX_VALUE_LEN+1];
ulong com_rate;
}; };
struct syncterm_settings { struct syncterm_settings {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment