home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / ISC366.ZIP / SERIAL / XONOFF.CPP < prev    next >
Text File  |  1993-09-01  |  2KB  |  55 lines

  1. ///////////////////////////////////////////////////////////////////////////
  2. //                                                                       //
  3. //            File: XOnOff.cpp                                           //
  4. //            started on: 23/2/92                                        //
  5. //                                                                       //
  6. ///////////////////////////////////////////////////////////////////////////
  7. //                                                                       //
  8. //  This class submits to XON and XOFF requests and so is compatible     //
  9. //  with some modems. Useful for software flow control, also...          //
  10. //                                                                       //
  11. ///////////////////////////////////////////////////////////////////////////
  12. //                                                                       //
  13. //                    by Ofer Laor (AKA LeucroTTA)                       //
  14. //                                                                       //
  15. ///////////////////////////////////////////////////////////////////////////
  16.  
  17. #include "xonoff.h"; // XONOFF.
  18.  
  19. // this class is SERIAL_PORT compatible - but on transmit will submit to
  20. // XONs and XOFFs.
  21.  
  22.  
  23. // update flow_enabled.
  24. //
  25. void XONOFF::flow_check(void)
  26. {
  27. //    flow_enabled= TRUE;
  28. }
  29.  
  30. XONOFF::XONOFF()
  31. {
  32.     flow_enabled= TRUE;
  33. }
  34.  
  35. // returns whether current char should be discarded.
  36. BOOLEAN XONOFF::flow_set(BYTE in_byte)
  37. {
  38.     if (in_byte== XON) {
  39.        if (!flow_enabled) {
  40.           flow_enabled= TRUE;
  41.           do_send();
  42.           return TRUE;
  43.        }
  44.  
  45.        flow_enabled= TRUE;
  46.     }
  47.     else if (in_byte== XOFF) {
  48.          flow_enabled= FALSE;
  49.          return TRUE;
  50.     }
  51.  
  52.     return FALSE;
  53. }
  54.  
  55.