home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12486 < prev    next >
Encoding:
Text File  |  1992-08-17  |  3.2 KB  |  104 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!mips!darwin.sura.net!jvnc.net!news.edu.tw!news!debbie!cp79111
  3. From: cp79111@csie.nctu.edu.tw (Kuo-Ping Hsu)
  4. Subject: help!!!
  5. Message-ID: <1992Aug18.063338.21333@debbie.cc.nctu.edu.tw>
  6. Sender: usenet@debbie.cc.nctu.edu.tw (News Sender)
  7. Organization: Computer Science & Information Engin., Chiao-Tung U, Taiwan, ROC
  8. X-Newsreader: Tin 1.1 PL3
  9. Date: Tue, 18 Aug 1992 06:33:38 GMT
  10. Lines: 92
  11.  
  12. hello,everybody :
  13.         I want to write a program about RS232 communication routine, 
  14.     but some trouble happened. Could you help me?
  15.         I use Borland C++ 3.0 compiler and write a following program. There is
  16.     a class called 'comm' with a syntax error in the constructor.
  17.     I want to write a new IRQ interrupt service routine to replace old one.
  18.     So, I must set new vector to point new ISR. I use Borland's
  19.     run-time function 'void setvect(int int_no,void interrupt (*isr)())'.
  20.     The second parameter must be a address that point to new IRQ. In my
  21.     program, there is a statement like this :
  22.  
  23.          setvect(com_irq,&comm::NewIRQ);
  24.                          ^^^^^^^^^^^^^
  25.     But the compiler reports a following error :
  26.  
  27.          Error : Connot convert 'void (far interrupt comm::*)()'
  28.                  to 'void (interrupt far *)(...)'
  29.     If I write :
  30.  
  31.          setvect(com_irq,NewIRQ);
  32.                          ^^^^^^
  33.     then, there is a new fault
  34.  
  35.          Error : Member function must be called or its address taken.
  36.  
  37.     How can I solve this problem? If you know. Please reply me via E-mail.
  38.     Thank you very much in advance.
  39. -----------------------------------------------------------------
  40. /VVVVVV\   
  41. |    ^ |   E-Mail : cp79111@csie.nctu.edu.tw
  42. |    O |   National Chiou Tung University
  43. |@      )  Taiwan R.O.C.
  44. \   `--/
  45.   |  |
  46. ========                                       Kuo-Ping Hsu
  47. ----------------------------------------------------------------------------
  48.  
  49. ===== File : RS232.HPP ======================
  50.  
  51.         :
  52.         :
  53. class comm {
  54.     private:
  55.         :
  56.         :
  57.       void interrupt NewIRQ();          // new IRQ interrupt service routine
  58.       void interrupt (*OldIRQ)(...);    // save old IRQ
  59.     public:
  60.       comm(int port_no,int baud,char parity,char length,char stop_bit);
  61.         :
  62.         :
  63.       char recv();          // receive data from comm port
  64.       ~comm();              // destructor
  65. };
  66.  
  67. ===== File : RS232.CPP =======================
  68.  
  69. #include "rs232.hpp"
  70.  
  71. // Initial RS232 & set IRQ ISR
  72. comm :: comm(int port_no,int baud,char parity=0,char length=8,char stop_bit=0)
  73. {
  74.          :
  75.          :
  76.          :
  77.  
  78.     // Set 8259 peripheral interrupt controller
  79.     OldIRQ = getvect(com_irq[port]);    // get old IRQ ISR
  80.     setvect(com_irq[port],&comm::NewIRQ);      // set new IRQ ISR
  81.          :                ^^^|^^^^^^^^^
  82.          :                   V
  83.                    Error : Connot convert 'void (far interrupt comm::*)()'
  84.                            to 'void (interrupt far *)(...)'
  85. }
  86.  
  87. // New IQR interrupt service routine
  88. void interrupt comm :: NewIRQ()
  89. {
  90.          :
  91.          :
  92. }
  93.          :
  94.          :
  95.          :
  96. main()
  97. {
  98.     comm rs232(1,BAUD_115200);          // Initial RS232
  99.     rs232.send('A');
  100.     return 0;
  101. }
  102.  
  103.  
  104.