/[rdesktop]/sourceforge.net/trunk/rdesktop/serial.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/serial.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 669 by astrand, Sun Apr 18 19:16:51 2004 UTC revision 757 by stargo, Wed Aug 25 00:43:48 2004 UTC
# Line 2  Line 2 
2  #include <fcntl.h>  #include <fcntl.h>
3  #include <termios.h>  #include <termios.h>
4  #include <strings.h>  #include <strings.h>
5    #include <sys/ioctl.h>
6  #include "rdesktop.h"  #include "rdesktop.h"
7    
8  #define FILE_DEVICE_SERIAL_PORT         0x1b  #define FILE_DEVICE_SERIAL_PORT         0x1b
# Line 73  Line 74 
74  #define SERIAL_EV_EVENT1           0x0800       // Provider specific event 1  #define SERIAL_EV_EVENT1           0x0800       // Provider specific event 1
75  #define SERIAL_EV_EVENT2           0x1000       // Provider specific event 2  #define SERIAL_EV_EVENT2           0x1000       // Provider specific event 2
76    
77    /* Modem Status */
78    #define SERIAL_MS_CTS 0x10
79    #define SERIAL_MS_DSR 0x20
80    #define SERIAL_MS_RNG 0x40
81    #define SERIAL_MS_CAR 0x80
82    
83    #ifndef CRTSCTS
84    #define CRTSCTS 0
85    #endif
86    
87    
88  extern RDPDR_DEVICE g_rdpdr_device[];  extern RDPDR_DEVICE g_rdpdr_device[];
89    
# Line 370  serial_enum_devices(uint32 * id, char *o Line 381  serial_enum_devices(uint32 * id, char *o
381                  // Init data structures for device                  // Init data structures for device
382                  pser_inf = (SERIAL_DEVICE *) xmalloc(sizeof(SERIAL_DEVICE));                  pser_inf = (SERIAL_DEVICE *) xmalloc(sizeof(SERIAL_DEVICE));
383                  pser_inf->ptermios = (struct termios *) xmalloc(sizeof(struct termios));                  pser_inf->ptermios = (struct termios *) xmalloc(sizeof(struct termios));
384                    memset(pser_inf->ptermios, 0, sizeof(struct termios));
385                  pser_inf->pold_termios = (struct termios *) xmalloc(sizeof(struct termios));                  pser_inf->pold_termios = (struct termios *) xmalloc(sizeof(struct termios));
386                    memset(pser_inf->pold_termios, 0, sizeof(struct termios));
387    
388                  pos2 = next_arg(optarg, '=');                  pos2 = next_arg(optarg, '=');
389                  strcpy(g_rdpdr_device[*id].name, optarg);                  strcpy(g_rdpdr_device[*id].name, optarg);
# Line 402  serial_create(uint32 device_id, uint32 a Line 415  serial_create(uint32 device_id, uint32 a
415    
416          pser_inf = (SERIAL_DEVICE *) g_rdpdr_device[device_id].pdevice_data;          pser_inf = (SERIAL_DEVICE *) g_rdpdr_device[device_id].pdevice_data;
417          ptermios = pser_inf->ptermios;          ptermios = pser_inf->ptermios;
418          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);
419    
420          if (serial_fd == -1)          if (serial_fd == -1)
421          {          {
# Line 433  serial_create(uint32 device_id, uint32 a Line 446  serial_create(uint32 device_id, uint32 a
446          tcsetattr(serial_fd, TCSANOW, ptermios);          tcsetattr(serial_fd, TCSANOW, ptermios);
447  */  */
448    
449            cfmakeraw(pser_inf->ptermios);
450          *handle = serial_fd;          *handle = serial_fd;
451    
452          /* all read and writes should be non blocking */          /* all read and writes should be non blocking */
# Line 512  serial_device_control(HANDLE handle, uin Line 526  serial_device_control(HANDLE handle, uin
526  #if 0  #if 0
527          int flush_mask, purge_mask;          int flush_mask, purge_mask;
528  #endif  #endif
529          uint32 result;          uint32 result, modemstate;
530          uint8 immediate;          uint8 immediate;
531          SERIAL_DEVICE *pser_inf;          SERIAL_DEVICE *pser_inf;
532          struct termios *ptermios;          struct termios *ptermios;
# Line 604  serial_device_control(HANDLE handle, uin Line 618  serial_device_control(HANDLE handle, uin
618                          set_termios(pser_inf, handle);                          set_termios(pser_inf, handle);
619                          break;                          break;
620                  case SERIAL_GET_MODEMSTATUS:                  case SERIAL_GET_MODEMSTATUS:
621                          out_uint32_le(out, 0);  /* Errors */                          modemstate = 0;
622    #ifdef TIOCMGET
623                            ioctl(handle, TIOCMGET, &result);
624                            if (result & TIOCM_CTS)
625                                    modemstate |= SERIAL_MS_CTS;
626                            if (result & TIOCM_DSR)
627                                    modemstate |= SERIAL_MS_DSR;
628                            if (result & TIOCM_RNG)
629                                    modemstate |= SERIAL_MS_RNG;
630                            if (result & TIOCM_CAR)
631                                    modemstate |= SERIAL_MS_CAR;
632    #endif
633                            out_uint32_le(out, modemstate);
634                          break;                          break;
635                  case SERIAL_GET_COMMSTATUS:                  case SERIAL_GET_COMMSTATUS:
636                          out_uint32_le(out, 0);  /* Errors */                          out_uint32_le(out, 0);  /* Errors */

Legend:
Removed from v.669  
changed lines
  Added in v.757

  ViewVC Help
Powered by ViewVC 1.1.26