/[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 686 by stargo, Thu Apr 29 19:41:49 2004 UTC revision 759 by stargo, Wed Aug 25 15:42:42 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  #ifndef CRTSCTS
84  #define CRTSCTS 0  #define CRTSCTS 0
85  #endif  #endif
# Line 374  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 406  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 436  serial_create(uint32 device_id, uint32 a Line 445  serial_create(uint32 device_id, uint32 a
445    
446          tcsetattr(serial_fd, TCSANOW, ptermios);          tcsetattr(serial_fd, TCSANOW, ptermios);
447  */  */
448            pser_inf->ptermios->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
449            pser_inf->ptermios->c_oflag &= ~OPOST;
450            pser_inf->ptermios->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
451            pser_inf->ptermios->c_cflag &= ~(CSIZE|PARENB);
452            pser_inf->ptermios->c_cflag |= CS8;
453            tcsetattr(serial_fd, TCSANOW, pser_inf->ptermios);
454    
455          *handle = serial_fd;          *handle = serial_fd;
456    
# Line 516  serial_device_control(HANDLE handle, uin Line 531  serial_device_control(HANDLE handle, uin
531  #if 0  #if 0
532          int flush_mask, purge_mask;          int flush_mask, purge_mask;
533  #endif  #endif
534          uint32 result;          uint32 result, modemstate;
535          uint8 immediate;          uint8 immediate;
536          SERIAL_DEVICE *pser_inf;          SERIAL_DEVICE *pser_inf;
537          struct termios *ptermios;          struct termios *ptermios;
# Line 608  serial_device_control(HANDLE handle, uin Line 623  serial_device_control(HANDLE handle, uin
623                          set_termios(pser_inf, handle);                          set_termios(pser_inf, handle);
624                          break;                          break;
625                  case SERIAL_GET_MODEMSTATUS:                  case SERIAL_GET_MODEMSTATUS:
626                          out_uint32_le(out, 0);  /* Errors */                          modemstate = 0;
627    #ifdef TIOCMGET
628                            ioctl(handle, TIOCMGET, &result);
629                            if (result & TIOCM_CTS)
630                                    modemstate |= SERIAL_MS_CTS;
631                            if (result & TIOCM_DSR)
632                                    modemstate |= SERIAL_MS_DSR;
633                            if (result & TIOCM_RNG)
634                                    modemstate |= SERIAL_MS_RNG;
635                            if (result & TIOCM_CAR)
636                                    modemstate |= SERIAL_MS_CAR;
637    #endif
638                            out_uint32_le(out, modemstate);
639                          break;                          break;
640                  case SERIAL_GET_COMMSTATUS:                  case SERIAL_GET_COMMSTATUS:
641                          out_uint32_le(out, 0);  /* Errors */                          out_uint32_le(out, 0);  /* Errors */

Legend:
Removed from v.686  
changed lines
  Added in v.759

  ViewVC Help
Powered by ViewVC 1.1.26