mirror of
https://github.com/FreeRDP/FreeRDP.git
synced 2025-06-03 00:00:20 +00:00
serial: ability to setup the server serial driver thanks to a third parameter on the command line
This commit is contained in:
parent
62298fcd95
commit
e6c82f99d5
@ -64,6 +64,7 @@ typedef struct _SERIAL_DEVICE SERIAL_DEVICE;
|
|||||||
struct _SERIAL_DEVICE
|
struct _SERIAL_DEVICE
|
||||||
{
|
{
|
||||||
DEVICE device;
|
DEVICE device;
|
||||||
|
SERIAL_DRIVER_ID ServerSerialDriverId;
|
||||||
HANDLE* hComm;
|
HANDLE* hComm;
|
||||||
|
|
||||||
/* TODO: use of log (prefered the old fashion DEBUG_SVC and
|
/* TODO: use of log (prefered the old fashion DEBUG_SVC and
|
||||||
@ -193,6 +194,8 @@ static void serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp)
|
|||||||
goto error_handle;
|
goto error_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_comm_setServerSerialDriver(serial->hComm, serial->ServerSerialDriverId);
|
||||||
|
|
||||||
/* FIXME: Appeared to be useful to setup some devices. Guess
|
/* FIXME: Appeared to be useful to setup some devices. Guess
|
||||||
* the device driver asked to setup some unsupported feature
|
* the device driver asked to setup some unsupported feature
|
||||||
* that were not eventually used. TODO: collecting more
|
* that were not eventually used. TODO: collecting more
|
||||||
@ -744,12 +747,14 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
|
|||||||
int i, len;
|
int i, len;
|
||||||
char* name;
|
char* name;
|
||||||
char* path;
|
char* path;
|
||||||
|
char* driver;
|
||||||
RDPDR_SERIAL* device;
|
RDPDR_SERIAL* device;
|
||||||
SERIAL_DEVICE* serial;
|
SERIAL_DEVICE* serial;
|
||||||
|
|
||||||
device = (RDPDR_SERIAL*) pEntryPoints->device;
|
device = (RDPDR_SERIAL*) pEntryPoints->device;
|
||||||
name = device->Name;
|
name = device->Name;
|
||||||
path = device->Path;
|
path = device->Path;
|
||||||
|
driver = device->Driver;
|
||||||
|
|
||||||
if (!name || (name[0] == '*'))
|
if (!name || (name[0] == '*'))
|
||||||
{
|
{
|
||||||
@ -782,6 +787,31 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
|
|||||||
for (i = 0; i <= len; i++)
|
for (i = 0; i <= len; i++)
|
||||||
Stream_Write_UINT8(serial->device.data, name[i] < 0 ? '_' : name[i]);
|
Stream_Write_UINT8(serial->device.data, name[i] < 0 ? '_' : name[i]);
|
||||||
|
|
||||||
|
if (driver != NULL)
|
||||||
|
{
|
||||||
|
if (_stricmp(driver, "Serial") == 0)
|
||||||
|
serial->ServerSerialDriverId = SerialDriverSerialSys;
|
||||||
|
else if (_stricmp(driver, "SerCx") == 0)
|
||||||
|
serial->ServerSerialDriverId = SerialDriverSerCxSys;
|
||||||
|
else if (_stricmp(driver, "SerCx2") == 0)
|
||||||
|
serial->ServerSerialDriverId = SerialDriverSerCx2Sys;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
assert(FALSE);
|
||||||
|
|
||||||
|
DEBUG_SVC("Unknown server's serial driver: %s. SerCx2 will be used", driver);
|
||||||
|
serial->ServerSerialDriverId = SerialDriverSerCx2Sys;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* default driver */
|
||||||
|
serial->ServerSerialDriverId = SerialDriverSerCx2Sys;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_SVC("Server's serial driver: %s (id: %d)", driver, serial->ServerSerialDriverId);
|
||||||
|
/* TODO: implement auto detection of the server's serial driver */
|
||||||
|
|
||||||
serial->MainIrpQueue = MessageQueue_New(NULL);
|
serial->MainIrpQueue = MessageQueue_New(NULL);
|
||||||
|
|
||||||
/* IrpThreads content only modified by create_irp_thread() */
|
/* IrpThreads content only modified by create_irp_thread() */
|
||||||
|
@ -385,6 +385,9 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p
|
|||||||
if (count > 2)
|
if (count > 2)
|
||||||
serial->Path = _strdup(params[2]);
|
serial->Path = _strdup(params[2]);
|
||||||
|
|
||||||
|
if (count > 3)
|
||||||
|
serial->Driver = _strdup(params[3]);
|
||||||
|
|
||||||
freerdp_device_collection_add(settings, (RDPDR_DEVICE*) serial);
|
freerdp_device_collection_add(settings, (RDPDR_DEVICE*) serial);
|
||||||
settings->DeviceRedirection = TRUE;
|
settings->DeviceRedirection = TRUE;
|
||||||
|
|
||||||
|
@ -466,6 +466,7 @@ struct _RDPDR_SERIAL
|
|||||||
UINT32 Type;
|
UINT32 Type;
|
||||||
char* Name;
|
char* Name;
|
||||||
char* Path;
|
char* Path;
|
||||||
|
char* Driver;
|
||||||
};
|
};
|
||||||
typedef struct _RDPDR_SERIAL RDPDR_SERIAL;
|
typedef struct _RDPDR_SERIAL RDPDR_SERIAL;
|
||||||
|
|
||||||
|
@ -287,8 +287,17 @@ out_smartc_name_error:
|
|||||||
goto out_serial_path_error;
|
goto out_serial_path_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (serial->Driver)
|
||||||
|
{
|
||||||
|
_serial->Driver = _strdup(serial->Driver);
|
||||||
|
if (!_serial->Driver)
|
||||||
|
goto out_serial_driver_error;
|
||||||
|
}
|
||||||
|
|
||||||
return (RDPDR_DEVICE*) _serial;
|
return (RDPDR_DEVICE*) _serial;
|
||||||
|
|
||||||
|
out_serial_driver_error:
|
||||||
|
free(_serial->Path);
|
||||||
out_serial_path_error:
|
out_serial_path_error:
|
||||||
free(_serial->Name);
|
free(_serial->Name);
|
||||||
out_serial_name_error:
|
out_serial_name_error:
|
||||||
@ -360,6 +369,7 @@ void freerdp_device_collection_free(rdpSettings* settings)
|
|||||||
else if (settings->DeviceArray[index]->Type == RDPDR_DTYP_SERIAL)
|
else if (settings->DeviceArray[index]->Type == RDPDR_DTYP_SERIAL)
|
||||||
{
|
{
|
||||||
free(((RDPDR_SERIAL*) device)->Path);
|
free(((RDPDR_SERIAL*) device)->Path);
|
||||||
|
free(((RDPDR_SERIAL*) device)->Driver);
|
||||||
}
|
}
|
||||||
else if (settings->DeviceArray[index]->Type == RDPDR_DTYP_PARALLEL)
|
else if (settings->DeviceArray[index]->Type == RDPDR_DTYP_PARALLEL)
|
||||||
{
|
{
|
||||||
|
@ -383,6 +383,20 @@ WINPR_API BOOL WaitCommEvent(HANDLE hFile, PDWORD lpEvtMask, LPOVERLAPPED lpOver
|
|||||||
#define MAXULONG (4294967295UL)
|
#define MAXULONG (4294967295UL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IOCTLs table according the server's serial driver:
|
||||||
|
* http://msdn.microsoft.com/en-us/library/windows/hardware/dn265347%28v=vs.85%29.aspx
|
||||||
|
*/
|
||||||
|
typedef enum _SERIAL_DRIVER_ID
|
||||||
|
{
|
||||||
|
SerialDriverUnknown = 0,
|
||||||
|
SerialDriverSerialSys,
|
||||||
|
SerialDriverSerCxSys,
|
||||||
|
SerialDriverSerCx2Sys /* default fallback, see also CommDeviceIoControl() */
|
||||||
|
} SERIAL_DRIVER_ID;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* About DefineCommDevice() / QueryDosDevice()
|
* About DefineCommDevice() / QueryDosDevice()
|
||||||
*
|
*
|
||||||
@ -534,6 +548,11 @@ static const _SERIAL_IOCTL_NAME _SERIAL_IOCTL_NAMES[] =
|
|||||||
*/
|
*/
|
||||||
const char* _comm_serial_ioctl_name(ULONG number);
|
const char* _comm_serial_ioctl_name(ULONG number);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FIXME: got a proper function name and place
|
||||||
|
*/
|
||||||
|
void _comm_setServerSerialDriver(HANDLE hComm, SERIAL_DRIVER_ID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME: got a proper function name and place
|
* FIXME: got a proper function name and place
|
||||||
*
|
*
|
||||||
|
@ -347,7 +347,7 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
|
|||||||
WINPR_COMM* pComm = (WINPR_COMM*) hFile;
|
WINPR_COMM* pComm = (WINPR_COMM*) hFile;
|
||||||
DWORD bytesReturned;
|
DWORD bytesReturned;
|
||||||
|
|
||||||
// TMP: FIXME: validate changes according GetCommProperties
|
/* FIXME: validate changes according GetCommProperties? */
|
||||||
|
|
||||||
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd )
|
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd )
|
||||||
{
|
{
|
||||||
@ -538,8 +538,6 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
|
|||||||
upcomingTermios.c_iflag &= ~INPCK;
|
upcomingTermios.c_iflag &= ~INPCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TMP: TODO:
|
|
||||||
// (...)
|
|
||||||
|
|
||||||
/* http://msdn.microsoft.com/en-us/library/windows/desktop/aa363423%28v=vs.85%29.aspx
|
/* http://msdn.microsoft.com/en-us/library/windows/desktop/aa363423%28v=vs.85%29.aspx
|
||||||
*
|
*
|
||||||
@ -1160,11 +1158,7 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
|
|||||||
|
|
||||||
InitializeCriticalSection(&pComm->WriteLock);
|
InitializeCriticalSection(&pComm->WriteLock);
|
||||||
|
|
||||||
|
/* can also be setup later on with _comm_setServerSerialDriver() */
|
||||||
/* TMP: TODO: FIXME: this information is at least needed for
|
|
||||||
* get/set baud functions. Is it possible to pull this
|
|
||||||
* information? Could be a command line argument.
|
|
||||||
*/
|
|
||||||
pComm->serverSerialDriverId = SerialDriverUnknown;
|
pComm->serverSerialDriverId = SerialDriverUnknown;
|
||||||
|
|
||||||
InitializeCriticalSection(&pComm->EventsLock);
|
InitializeCriticalSection(&pComm->EventsLock);
|
||||||
|
@ -30,18 +30,6 @@
|
|||||||
|
|
||||||
#include "../handle/handle.h"
|
#include "../handle/handle.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* IOCTLs table according the remote serial driver:
|
|
||||||
* http://msdn.microsoft.com/en-us/library/windows/hardware/dn265347%28v=vs.85%29.aspx
|
|
||||||
*/
|
|
||||||
typedef enum _SERIAL_DRIVER_ID
|
|
||||||
{
|
|
||||||
SerialDriverUnknown = 0,
|
|
||||||
SerialDriverSerialSys,
|
|
||||||
SerialDriverSerCxSys,
|
|
||||||
SerialDriverSerCx2Sys /* default fallback, see also CommDeviceIoControl() */
|
|
||||||
} SERIAL_DRIVER_ID;
|
|
||||||
|
|
||||||
struct winpr_comm
|
struct winpr_comm
|
||||||
{
|
{
|
||||||
WINPR_HANDLE_DEF();
|
WINPR_HANDLE_DEF();
|
||||||
@ -79,8 +67,6 @@ struct winpr_comm
|
|||||||
|
|
||||||
typedef struct winpr_comm WINPR_COMM;
|
typedef struct winpr_comm WINPR_COMM;
|
||||||
|
|
||||||
void _comm_setServerSerialDriver(HANDLE hComm, SERIAL_DRIVER_ID);
|
|
||||||
|
|
||||||
/* TMP: TODO: move all specific defines and types here? at least SERIAL_EV_* */
|
/* TMP: TODO: move all specific defines and types here? at least SERIAL_EV_* */
|
||||||
#define SERIAL_EV_FREERDP_WAITING 0x4000 /* bit unused by SERIAL_EV_* */
|
#define SERIAL_EV_FREERDP_WAITING 0x4000 /* bit unused by SERIAL_EV_* */
|
||||||
#define SERIAL_EV_FREERDP_STOP 0x8000 /* bit unused by SERIAL_EV_* */
|
#define SERIAL_EV_FREERDP_STOP 0x8000 /* bit unused by SERIAL_EV_* */
|
||||||
|
Loading…
Reference in New Issue
Block a user