73 |
#define SERIAL_EV_EVENT1 0x0800 // Provider specific event 1 |
#define SERIAL_EV_EVENT1 0x0800 // Provider specific event 1 |
74 |
#define SERIAL_EV_EVENT2 0x1000 // Provider specific event 2 |
#define SERIAL_EV_EVENT2 0x1000 // Provider specific event 2 |
75 |
|
|
76 |
|
#ifndef CRTSCTS |
77 |
|
#define CRTSCTS 0 |
78 |
|
#endif |
79 |
|
|
80 |
|
|
81 |
extern RDPDR_DEVICE g_rdpdr_device[]; |
extern RDPDR_DEVICE g_rdpdr_device[]; |
82 |
|
|
83 |
SERIAL_DEVICE * |
static SERIAL_DEVICE * |
84 |
get_serial_info(HANDLE handle) |
get_serial_info(HANDLE handle) |
85 |
{ |
{ |
86 |
int index; |
int index; |
93 |
return NULL; |
return NULL; |
94 |
} |
} |
95 |
|
|
96 |
BOOL |
static BOOL |
97 |
get_termios(SERIAL_DEVICE * pser_inf, HANDLE serial_fd) |
get_termios(SERIAL_DEVICE * pser_inf, HANDLE serial_fd) |
98 |
{ |
{ |
99 |
speed_t speed; |
speed_t speed; |
374 |
// Init data structures for device |
// Init data structures for device |
375 |
pser_inf = (SERIAL_DEVICE *) xmalloc(sizeof(SERIAL_DEVICE)); |
pser_inf = (SERIAL_DEVICE *) xmalloc(sizeof(SERIAL_DEVICE)); |
376 |
pser_inf->ptermios = (struct termios *) xmalloc(sizeof(struct termios)); |
pser_inf->ptermios = (struct termios *) xmalloc(sizeof(struct termios)); |
377 |
|
memset(pser_inf->ptermios, 0, sizeof(struct termios)); |
378 |
pser_inf->pold_termios = (struct termios *) xmalloc(sizeof(struct termios)); |
pser_inf->pold_termios = (struct termios *) xmalloc(sizeof(struct termios)); |
379 |
|
memset(pser_inf->pold_termios, 0, sizeof(struct termios)); |
380 |
|
|
381 |
pos2 = next_arg(optarg, '='); |
pos2 = next_arg(optarg, '='); |
382 |
strcpy(g_rdpdr_device[*id].name, optarg); |
strcpy(g_rdpdr_device[*id].name, optarg); |
398 |
return count; |
return count; |
399 |
} |
} |
400 |
|
|
401 |
NTSTATUS |
static NTSTATUS |
402 |
serial_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition, |
serial_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition, |
403 |
uint32 flags_and_attributes, char *filename, HANDLE * handle) |
uint32 flags_and_attributes, char *filename, HANDLE * handle) |
404 |
{ |
{ |
408 |
|
|
409 |
pser_inf = (SERIAL_DEVICE *) g_rdpdr_device[device_id].pdevice_data; |
pser_inf = (SERIAL_DEVICE *) g_rdpdr_device[device_id].pdevice_data; |
410 |
ptermios = pser_inf->ptermios; |
ptermios = pser_inf->ptermios; |
411 |
serial_fd = open(g_rdpdr_device[device_id].local_path, O_RDWR | O_NOCTTY); |
serial_fd = open(g_rdpdr_device[device_id].local_path, O_RDWR | O_NOCTTY | O_NONBLOCK); |
412 |
|
|
413 |
if (serial_fd == -1) |
if (serial_fd == -1) |
414 |
{ |
{ |
439 |
tcsetattr(serial_fd, TCSANOW, ptermios); |
tcsetattr(serial_fd, TCSANOW, ptermios); |
440 |
*/ |
*/ |
441 |
|
|
442 |
|
cfmakeraw(pser_inf->ptermios); |
443 |
*handle = serial_fd; |
*handle = serial_fd; |
444 |
|
|
445 |
/* all read and writes should be non blocking */ |
/* all read and writes should be non blocking */ |
459 |
return STATUS_SUCCESS; |
return STATUS_SUCCESS; |
460 |
} |
} |
461 |
|
|
462 |
NTSTATUS |
static NTSTATUS |
463 |
serial_read(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) |
serial_read(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) |
464 |
{ |
{ |
465 |
long timeout; |
long timeout; |
506 |
return STATUS_SUCCESS; |
return STATUS_SUCCESS; |
507 |
} |
} |
508 |
|
|
509 |
NTSTATUS |
static NTSTATUS |
510 |
serial_write(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) |
serial_write(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) |
511 |
{ |
{ |
512 |
*result = write(handle, data, length); |
*result = write(handle, data, length); |
516 |
static NTSTATUS |
static NTSTATUS |
517 |
serial_device_control(HANDLE handle, uint32 request, STREAM in, STREAM out) |
serial_device_control(HANDLE handle, uint32 request, STREAM in, STREAM out) |
518 |
{ |
{ |
519 |
|
#if 0 |
520 |
int flush_mask, purge_mask; |
int flush_mask, purge_mask; |
521 |
|
#endif |
522 |
uint32 result; |
uint32 result; |
523 |
uint8 immediate; |
uint8 immediate; |
524 |
SERIAL_DEVICE *pser_inf; |
SERIAL_DEVICE *pser_inf; |