/[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 795 by stargo, Wed Nov 3 13:56:52 2004 UTC revision 801 by astrand, Tue Nov 23 13:29:12 2004 UTC
# Line 3  Line 3 
3  #include <termios.h>  #include <termios.h>
4  #include <strings.h>  #include <strings.h>
5  #include <sys/ioctl.h>  #include <sys/ioctl.h>
6    
7    #ifdef HAVE_SYS_MODEM_H
8    #include <sys/modem.h>
9    #endif
10    #ifdef HAVE_SYS_FILIO_H
11    #include <sys/filio.h>
12    #endif
13    #ifdef HAVE_SYS_STRTIO_H
14    #include <sys/strtio.h>
15    #endif
16    
17  #include "rdesktop.h"  #include "rdesktop.h"
18    
19  #ifdef WITH_DEBUG_SERIAL  #ifdef WITH_DEBUG_SERIAL
# Line 111  Line 122 
122  /* FIONREAD should really do the same thing as TIOCINQ, where it is  /* FIONREAD should really do the same thing as TIOCINQ, where it is
123   * not available */   * not available */
124  #ifndef TIOCINQ  #ifndef TIOCINQ
 #include <sys/filio.h>  
125  #define TIOCINQ FIONREAD  #define TIOCINQ FIONREAD
126  #endif  #endif
127    
# Line 385  set_termios(SERIAL_DEVICE * pser_inf, NT Line 395  set_termios(SERIAL_DEVICE * pser_inf, NT
395                          break;                          break;
396          }          }
397    
398  #if 0  #ifdef CBAUD
399            ptermios->c_cflag &= ~CBAUD;
400            ptermios->c_cflag |= speed;
401    #else
402          /* on systems with separate ispeed and ospeed, we can remember the speed          /* on systems with separate ispeed and ospeed, we can remember the speed
403             in ispeed while changing DTR with ospeed */             in ispeed while changing DTR with ospeed */
404          cfsetispeed(pser_inf->ptermios, speed);          cfsetispeed(pser_inf->ptermios, speed);
405          cfsetospeed(pser_inf->ptermios, pser_inf->dtr ? speed : 0);          cfsetospeed(pser_inf->ptermios, pser_inf->dtr ? speed : 0);
406  #endif  #endif
407    
         ptermios->c_cflag &= ~CBAUD;  
         ptermios->c_cflag |= speed;  
   
408          ptermios->c_cflag &= ~(CSTOPB | PARENB | PARODD | CSIZE | CRTSCTS);          ptermios->c_cflag &= ~(CSTOPB | PARENB | PARODD | CSIZE | CRTSCTS);
409          switch (pser_inf->stop_bits)          switch (pser_inf->stop_bits)
410          {          {
# Line 690  serial_device_control(NTHANDLE handle, u Line 700  serial_device_control(NTHANDLE handle, u
700                  case SERIAL_SET_BAUD_RATE:                  case SERIAL_SET_BAUD_RATE:
701                          in_uint32_le(in, pser_inf->baud_rate);                          in_uint32_le(in, pser_inf->baud_rate);
702                          set_termios(pser_inf, handle);                          set_termios(pser_inf, handle);
703                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_BAUD_RATE %d\n", pser_inf->baud_rate));                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_BAUD_RATE %d\n",
704                                          pser_inf->baud_rate));
705                          break;                          break;
706                  case SERIAL_GET_BAUD_RATE:                  case SERIAL_GET_BAUD_RATE:
707                          out_uint32_le(out, pser_inf->baud_rate);                          out_uint32_le(out, pser_inf->baud_rate);
708                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_GET_BAUD_RATE %d\n", pser_inf->baud_rate));                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_GET_BAUD_RATE %d\n",
709                                          pser_inf->baud_rate));
710                          break;                          break;
711                  case SERIAL_SET_QUEUE_SIZE:                  case SERIAL_SET_QUEUE_SIZE:
712                          in_uint32_le(in, pser_inf->queue_in_size);                          in_uint32_le(in, pser_inf->queue_in_size);
713                          in_uint32_le(in, pser_inf->queue_out_size);                          in_uint32_le(in, pser_inf->queue_out_size);
714                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_QUEUE_SIZE in %d out %d\n",                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_QUEUE_SIZE in %d out %d\n",
715                              pser_inf->queue_in_size, pser_inf->queue_out_size));                                        pser_inf->queue_in_size, pser_inf->queue_out_size));
716                          break;                          break;
717                  case SERIAL_SET_LINE_CONTROL:                  case SERIAL_SET_LINE_CONTROL:
718                          in_uint8(in, pser_inf->stop_bits);                          in_uint8(in, pser_inf->stop_bits);
719                          in_uint8(in, pser_inf->parity);                          in_uint8(in, pser_inf->parity);
720                          in_uint8(in, pser_inf->word_length);                          in_uint8(in, pser_inf->word_length);
721                          set_termios(pser_inf, handle);                          set_termios(pser_inf, handle);
722                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_LINE_CONTROL stop %d parity %d word %d\n",                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_LINE_CONTROL stop %d parity %d word %d\n", pser_inf->stop_bits, pser_inf->parity, pser_inf->word_length));
                             pser_inf->stop_bits, pser_inf->parity, pser_inf->word_length));  
723                          break;                          break;
724                  case SERIAL_GET_LINE_CONTROL:                  case SERIAL_GET_LINE_CONTROL:
725                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_GET_LINE_CONTROL\n"));                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_GET_LINE_CONTROL\n"));
# Line 751  serial_device_control(NTHANDLE handle, u Line 762  serial_device_control(NTHANDLE handle, u
762                          in_uint32_le(in, pser_inf->onlimit);                          in_uint32_le(in, pser_inf->onlimit);
763                          in_uint32_le(in, pser_inf->offlimit);                          in_uint32_le(in, pser_inf->offlimit);
764                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_HANDFLOW %x %x %x %x\n",                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_HANDFLOW %x %x %x %x\n",
765                              pser_inf->control, pser_inf->xonoff, pser_inf->onlimit,                                        pser_inf->control, pser_inf->xonoff, pser_inf->onlimit,
766                              pser_inf->onlimit));                                        pser_inf->onlimit));
767                          set_termios(pser_inf, handle);                          set_termios(pser_inf, handle);
768                          break;                          break;
769                  case SERIAL_SET_TIMEOUTS:                  case SERIAL_SET_TIMEOUTS:
# Line 762  serial_device_control(NTHANDLE handle, u Line 773  serial_device_control(NTHANDLE handle, u
773                          in_uint32(in, pser_inf->write_total_timeout_multiplier);                          in_uint32(in, pser_inf->write_total_timeout_multiplier);
774                          in_uint32(in, pser_inf->write_total_timeout_constant);                          in_uint32(in, pser_inf->write_total_timeout_constant);
775                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_TIMEOUTS read timeout %d %d %d\n",                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_TIMEOUTS read timeout %d %d %d\n",
776                              pser_inf->read_interval_timeout,                                        pser_inf->read_interval_timeout,
777                              pser_inf->read_total_timeout_multiplier,                                        pser_inf->read_total_timeout_multiplier,
778                              pser_inf->read_total_timeout_constant));                                        pser_inf->read_total_timeout_constant));
779                          break;                          break;
780                  case SERIAL_GET_TIMEOUTS:                  case SERIAL_GET_TIMEOUTS:
781                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_GET_TIMEOUTS read timeout %d %d %d\n",                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_GET_TIMEOUTS read timeout %d %d %d\n",
782                              pser_inf->read_interval_timeout,                                        pser_inf->read_interval_timeout,
783                              pser_inf->read_total_timeout_multiplier,                                        pser_inf->read_total_timeout_multiplier,
784                              pser_inf->read_total_timeout_constant));                                        pser_inf->read_total_timeout_constant));
785    
786                          out_uint32(out, pser_inf->read_interval_timeout);                          out_uint32(out, pser_inf->read_interval_timeout);
787                          out_uint32(out, pser_inf->read_total_timeout_multiplier);                          out_uint32(out, pser_inf->read_total_timeout_multiplier);
# Line 779  serial_device_control(NTHANDLE handle, u Line 790  serial_device_control(NTHANDLE handle, u
790                          out_uint32(out, pser_inf->write_total_timeout_constant);                          out_uint32(out, pser_inf->write_total_timeout_constant);
791                          break;                          break;
792                  case SERIAL_GET_WAIT_MASK:                  case SERIAL_GET_WAIT_MASK:
793                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_GET_WAIT_MASK %X\n", pser_inf->wait_mask);                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_GET_WAIT_MASK %X\n",
794                          out_uint32(out, pser_inf->wait_mask));                                        pser_inf->wait_mask); out_uint32(out, pser_inf->wait_mask));
795                          break;                          break;
796                  case SERIAL_SET_WAIT_MASK:                  case SERIAL_SET_WAIT_MASK:
797                          in_uint32(in, pser_inf->wait_mask);                          in_uint32(in, pser_inf->wait_mask);
798                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_WAIT_MASK %X\n", pser_inf->wait_mask));                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_WAIT_MASK %X\n",
799                                          pser_inf->wait_mask));
800                          break;                          break;
801                  case SERIAL_SET_DTR:                  case SERIAL_SET_DTR:
802                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_DTR\n"));                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_DTR\n"));
# Line 842  serial_device_control(NTHANDLE handle, u Line 854  serial_device_control(NTHANDLE handle, u
854                          ioctl(handle, TIOCINQ, &result);                          ioctl(handle, TIOCINQ, &result);
855                          out_uint32_le(out, result);     /* Amount in in queue */                          out_uint32_le(out, result);     /* Amount in in queue */
856                          if (result)                          if (result)
857                                  DEBUG_SERIAL(("serial_ioctl -> SERIAL_GET_COMMSTATUS in queue %d\n", result));                                  DEBUG_SERIAL(("serial_ioctl -> SERIAL_GET_COMMSTATUS in queue %d\n",
858                                                  result));
859    
860                          result = 0;                          result = 0;
861                          ioctl(handle, TIOCOUTQ, &result);                          ioctl(handle, TIOCOUTQ, &result);
# Line 869  serial_device_control(NTHANDLE handle, u Line 882  serial_device_control(NTHANDLE handle, u
882                                  rdpdr_abort_io(handle, 3, STATUS_CANCELLED);                                  rdpdr_abort_io(handle, 3, STATUS_CANCELLED);
883                          break;                          break;
884                  case SERIAL_WAIT_ON_MASK:                  case SERIAL_WAIT_ON_MASK:
885                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_WAIT_ON_MASK %X\n", pser_inf->wait_mask));                          DEBUG_SERIAL(("serial_ioctl -> SERIAL_WAIT_ON_MASK %X\n",
886                                          pser_inf->wait_mask));
887                          pser_inf->event_pending = 1;                          pser_inf->event_pending = 1;
888                          if (serial_get_event(handle, &result))                          if (serial_get_event(handle, &result))
889                          {                          {
# Line 975  serial_get_event(NTHANDLE handle, uint32 Line 989  serial_get_event(NTHANDLE handle, uint32
989                  pser_inf->event_dsr = bytes & TIOCM_DSR;                  pser_inf->event_dsr = bytes & TIOCM_DSR;
990                  if (pser_inf->wait_mask & SERIAL_EV_DSR)                  if (pser_inf->wait_mask & SERIAL_EV_DSR)
991                  {                  {
992                          DEBUG_SERIAL(("event -> SERIAL_EV_DSR %s\n", (bytes & TIOCM_DSR) ? "ON" : "OFF"));                          DEBUG_SERIAL(("event -> SERIAL_EV_DSR %s\n",
993                                          (bytes & TIOCM_DSR) ? "ON" : "OFF"));
994                          *result |= SERIAL_EV_DSR;                          *result |= SERIAL_EV_DSR;
995                          ret = True;                          ret = True;
996                  }                  }
# Line 986  serial_get_event(NTHANDLE handle, uint32 Line 1001  serial_get_event(NTHANDLE handle, uint32
1001                  pser_inf->event_cts = bytes & TIOCM_CTS;                  pser_inf->event_cts = bytes & TIOCM_CTS;
1002                  if (pser_inf->wait_mask & SERIAL_EV_CTS)                  if (pser_inf->wait_mask & SERIAL_EV_CTS)
1003                  {                  {
1004                          DEBUG_SERIAL((" EVENT-> SERIAL_EV_CTS %s\n", (bytes & TIOCM_CTS) ? "ON" : "OFF"));                          DEBUG_SERIAL((" EVENT-> SERIAL_EV_CTS %s\n",
1005                                          (bytes & TIOCM_CTS) ? "ON" : "OFF"));
1006                          *result |= SERIAL_EV_CTS;                          *result |= SERIAL_EV_CTS;
1007                          ret = True;                          ret = True;
1008                  }                  }

Legend:
Removed from v.795  
changed lines
  Added in v.801

  ViewVC Help
Powered by ViewVC 1.1.26