removing the code that set the serial io stuff, and the extra options to comport....
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@577 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
parent
c614f83b19
commit
3b15cec51b
@ -119,11 +119,11 @@ usage(char *program)
|
||||
fprintf(stderr, " -a: connection colour depth\n");
|
||||
fprintf(stderr, " -r: enable specified device redirection (this flag can be repeated)\n");
|
||||
fprintf(stderr, " '-r comport:COM1=/dev/ttyS0': enable serial redirection of /dev/ttyS0 to COM1\n");
|
||||
fprintf(stderr, " or :COM1=/dev/ttyS0:9600,0|1|2,0|2,5|6|7|8:dtr \n");
|
||||
fprintf(stderr, " or COM1=/dev/ttyS0,COM2=/dev/ttyS1\n");
|
||||
fprintf(stderr, " '-r disk:A=/mnt/floppy': enable redirection of /mnt/floppy to A:\n");
|
||||
fprintf(stderr, " or A=/mnt/floppy,D=/mnt/cdrom'\n");
|
||||
fprintf(stderr, " '-r lptport:LPT1=/dev/lp0': enable parallel redirection of /dev/lp0 to LPT1\n");
|
||||
fprintf(stderr, " or LPT1=/dev/lp0,LPT2=/dev/lp1\n");
|
||||
fprintf(stderr, " or LPT1=/dev/lp0,LPT2=/dev/lp1\n");
|
||||
fprintf(stderr, " '-r printer:mydeskjet': enable printer redirection\n");
|
||||
fprintf(stderr, " or mydeskjet:\"HP Laserjet IIIP\" to enter server driver as well\n");
|
||||
fprintf(stderr, " '-r sound': enable sound redirection\n");
|
||||
|
125
serial.c
125
serial.c
@ -254,97 +254,42 @@ set_termios(void)
|
||||
/* returns numer of units found and initialized. */
|
||||
/* optarg looks like ':com1=/dev/ttyS0' */
|
||||
/* when it arrives to this function. */
|
||||
/* windev u*dev baud, parity, stop bits, wordlength */
|
||||
/* :com1=/dev/ttyS0:9600,0|1|2,0|2,5|6|7|8:dtr */
|
||||
/* :com1=/dev/ttyS0,com2=/dev/ttyS1 */
|
||||
int
|
||||
serial_enum_devices(int *id, char* optarg)
|
||||
{
|
||||
SERIAL_DEVICE* pser_inf;
|
||||
|
||||
int argcount=0;
|
||||
char* pos = optarg;
|
||||
char* pos2;
|
||||
char* pos3;
|
||||
char *pos = optarg;
|
||||
char *pos2;
|
||||
int count = 0;
|
||||
|
||||
if(*id<RDPDR_MAX_DEVICES){
|
||||
// skip the first colon
|
||||
optarg++;
|
||||
while ((pos = next_arg(optarg, ',')) && *id < RDPDR_MAX_DEVICES)
|
||||
{
|
||||
// Init data structures for device
|
||||
pser_inf = (SERIAL_DEVICE *) xmalloc(sizeof(SERIAL_DEVICE));
|
||||
pser_inf->ptermios = (struct termios *) xmalloc(sizeof(struct termios));
|
||||
pser_inf->pold_termios = (struct termios *) xmalloc(sizeof(struct termios));
|
||||
|
||||
// skip the first colon
|
||||
optarg++;
|
||||
while( (pos = next_arg( optarg, ':')) ){
|
||||
pos2 = next_arg(optarg, '=');
|
||||
strcpy(g_rdpdr_device[*id].name, optarg);
|
||||
|
||||
switch(argcount){
|
||||
/* com1=/dev/ttyS0 */
|
||||
case 0:
|
||||
pos2 = next_arg(optarg,'=');
|
||||
if( !pos2 || *pos2 == (char)0x00 ){
|
||||
error("-r comport arguments should look like: -r comport:com1=/dev/ttyS0\n");
|
||||
return 0;
|
||||
}
|
||||
/* optarg = com1, pos2 = /dev/ttyS0 */
|
||||
strcpy(g_rdpdr_device[*id].name,optarg);
|
||||
|
||||
toupper_str(g_rdpdr_device[*id].name);
|
||||
|
||||
g_rdpdr_device[*id].local_path = xmalloc( strlen(pos2) + 1 );
|
||||
strcpy(g_rdpdr_device[*id].local_path,pos2);
|
||||
break;
|
||||
/* 9600,0|1|2,O|2,5|6|7|8 */
|
||||
/* TODO: values should be set in serial_create()... ??? */
|
||||
case 1:
|
||||
pos2 = next_arg(optarg,',');
|
||||
/*optarg=9600*/
|
||||
pser_inf->baud_rate = atoi(optarg);
|
||||
if( !pos2 || *pos2 == (char)0x00 )
|
||||
break;
|
||||
pos3 = next_arg(pos2,',');
|
||||
/* pos2 = 0|1|2 */
|
||||
pser_inf->parity = atoi(pos2);
|
||||
/* pos3 = 0|2,5|6|7|8*/
|
||||
pos2 = next_arg(pos3,',');
|
||||
if( !pos3 || *pos3 == (char)0x00 )
|
||||
break;
|
||||
pser_inf->stop_bits = atoi(pos3);
|
||||
/* pos2 = 5|6|7|8 */
|
||||
if( !pos2 || *pos2 == (char)0x00 )
|
||||
break;
|
||||
pser_inf->word_length = atoi(pos2);
|
||||
break;
|
||||
default:
|
||||
if( (*optarg != (char)0x00) && (strcmp( optarg, "dtr" ) == 0) ){
|
||||
pser_inf->dtr = 1;
|
||||
}
|
||||
/* TODO: add more switches here, like xon, xoff. they will be separated by colon
|
||||
if( (*optarg != (char)0x00) && (strcmp( optarg, "xon" ) == 0) ){
|
||||
}
|
||||
*/
|
||||
break;
|
||||
}
|
||||
argcount++;
|
||||
optarg=pos;
|
||||
}
|
||||
|
||||
printf("SERIAL %s to %s", g_rdpdr_device[*id].name, g_rdpdr_device[*id].local_path );
|
||||
if( pser_inf->baud_rate != 0 ){
|
||||
printf(" with baud: %u, parity: %u, stop bits: %u word length: %u", pser_inf->baud_rate, pser_inf->parity, pser_inf->stop_bits, pser_inf->word_length );
|
||||
if( pser_inf->dtr )
|
||||
printf( " dtr set\n");
|
||||
else
|
||||
printf( "\n" );
|
||||
}else
|
||||
printf("\n");
|
||||
toupper_str(g_rdpdr_device[*id].name);
|
||||
|
||||
g_rdpdr_device[*id].local_path = xmalloc(strlen(pos2) + 1);
|
||||
strcpy(g_rdpdr_device[*id].local_path, pos2);
|
||||
printf("SERIAL %s to %s\n", g_rdpdr_device[*id].name, g_rdpdr_device[*id].local_path);
|
||||
// set device type
|
||||
g_rdpdr_device[*id].device_type = DEVICE_TYPE_SERIAL;
|
||||
g_rdpdr_device[*id].pdevice_data = (void *) pser_inf;
|
||||
count++;
|
||||
(*id)++;
|
||||
|
||||
return 1;
|
||||
optarg = pos;
|
||||
}
|
||||
return 0;
|
||||
return count;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
@ -353,7 +298,6 @@ serial_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposi
|
||||
HANDLE serial_fd;
|
||||
SERIAL_DEVICE *pser_inf;
|
||||
struct termios *ptermios;
|
||||
SERIAL_DEVICE tmp_inf;
|
||||
|
||||
pser_inf = (SERIAL_DEVICE *) g_rdpdr_device[device_id].pdevice_data;
|
||||
ptermios = pser_inf->ptermios;
|
||||
@ -362,38 +306,21 @@ serial_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposi
|
||||
if (serial_fd == -1)
|
||||
return STATUS_ACCESS_DENIED;
|
||||
|
||||
// before we clog the user inserted args store them locally
|
||||
//
|
||||
memcpy(&tmp_inf,pser_inf, sizeof(pser_inf) );
|
||||
|
||||
if (!get_termios(pser_inf, serial_fd))
|
||||
if (!get_termios(pser_inf, serial_fd ))
|
||||
return STATUS_ACCESS_DENIED;
|
||||
|
||||
// Store handle for later use
|
||||
// Store handle for later use
|
||||
g_rdpdr_device[device_id].handle = serial_fd;
|
||||
tcgetattr(serial_fd, pser_inf->pold_termios); // Backup original settings
|
||||
|
||||
// Initial configuration.
|
||||
bzero(ptermios, sizeof(ptermios));
|
||||
ptermios->c_cflag = B9600 | CRTSCTS | CS8 | CLOCAL | CREAD;
|
||||
ptermios->c_iflag = IGNPAR;
|
||||
ptermios->c_oflag = 0;
|
||||
ptermios->c_lflag = 0; //non-canonical, no echo
|
||||
ptermios->c_cc[VTIME] = 0;
|
||||
tcsetattr(serial_fd, TCSANOW, ptermios);
|
||||
/* some sane information */
|
||||
printf("INFO: SERIAL %s to %s\nINFO: speed %u baud, stop bits %u, parity %u, word length %u bits, dtr %u\n",
|
||||
g_rdpdr_device[device_id].name, g_rdpdr_device[device_id].local_path,
|
||||
pser_inf->baud_rate, pser_inf->stop_bits, pser_inf->parity, pser_inf->word_length, pser_inf->dtr );
|
||||
printf("INFO: use stty to change settings\n" );
|
||||
|
||||
// overload with user settings
|
||||
// -- if there are any
|
||||
if( tmp_inf.baud_rate != 0 ){
|
||||
dtr = tmp_inf.dtr;
|
||||
baud_rate = tmp_inf.baud_rate;
|
||||
parity = tmp_inf.parity;
|
||||
stop_bits = tmp_inf.stop_bits;
|
||||
word_length = tmp_inf.word_length;
|
||||
set_termios();
|
||||
}
|
||||
//tcgetattr(serial_fd, pser_inf->ptermios);
|
||||
|
||||
*handle = serial_fd;
|
||||
*handle = serial_fd;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user