pcl4w.usr

来自「C语言通讯程序库windows版  」· USR 代码 · 共 1,605 行 · 第 1/5 页

USR
1,605
字号
              compatible modem, set the AT_COMMAND_SET constant to 1.  If you are using  a
              programmable  modem  which is not Hayes compatible, then you must modify the
              initialization string for your particular modem.

              If your application does not run but TERM runs correctly, then you have most
              likely  made  a  programming  mistake  in  your  application.   MarshallSoft
              Computing  cannot  debug  your  application,  especially over the telephone!
              However, consider each of the following when searching for an error in  your
              application.

              1.  Have you included the file PCL4W.H in your application ?

              2.  Is your receive buffer large enough ? If you are using 1K data blocks in
              YMODEM,  then  your  receive  buffer should be at least 1K (2K if baud rates
              above 19200 are to be used).

              3.  Have you selected too high a baud rate? Windows can multitask many tasks
              at once. You may have to lower your baud rate (or get 16550 UARTS).

              4.  If you are running two COM ports simultaneously, are you using separate
              receive and transmits buffers ? (you should).

              5.  Did SioReset return a zero value ?  If not, then you must call  SioReset
              again. See TERM.C for an example.

              6.   Did  you  send the proper initialization string to your modem ? Did you
              set DTR and RTS ? (you should).

              7.  Do you have more than one COM1 port?  For example, if you  have  a  COM1
              port  on  your  motherboard, you cannot add another COM1 port or modem board
              that uses COM1 without first disabling the COM1 on the motherboard.

              8.   Is  your  IRQ set correctly? If you can transmit data but can't receive
              using the PCL4W library with transmitter interrupts disabled (PCL4W2),  then
              this usually means that interrupts are not working.

              Give us a call if you have trouble getting SIMPLE or TERM to work correctly.



















             PCL4W Users Manual                                                Page 15
              6.0 Serial Communications

              6.1 Communications Basics


              The  heart  of  serial  communications  is  the UART (Universal Asynchronous
              Receiver Transmitter).  The IBM  PC/XT/AT  and  compatibles  use  the  8250,
              16450, or the 16550 UART.  The purpose of the UART is:

              (1) To convert bytes from the CPU (Central Processing Unit), into  a  serial
              format  by  adding  the  necessary start, stop, and parity bits to each byte
              before transmission, and to then transmit each bit at the correct baud rate.

              (2) To convert the incoming stream (at a specified baud rate) of serial bits
              into bytes by removing the start, stop, and parity bits  before  being  made
              available to the CPU.

              The  UART  is part of the serial interface circuitry which allows the CPU to
              send and receive signals over the RS232 lines. This  can  be  diagrammed  as
              follows:



                                    Serial Interface
                                 *********************
                                 *                   *
              *******  Data Bus  *     ********      *    RS232 Signals
              * CPU **************     * UART *      ******************
              *******            *     ********      *
                                 *                   *
                                 *********************



              The  8250/16450/16550  UART  is  capable  of  operating in one of two modes,
              "polled" and "interrupt driven".  The serial communications functions in the
              BIOS uses the polled method.  In this approach, the CPU is  typically  in  a
              loop  asking  the  UART  over  and over again if it has a byte ready. If its
              does, the polling code returns the byte.  But, if the  next  byte  comes  in
              before the polling code is executing again, then that byte is lost.

              In the interrupt driven approach (used by PCL4W), when a byte is received by
              the  UART,  an  "Interrupt  Service  Routine" (ISR) is executed immediately,
              suspending temporarily whatever else is executing. The ISR  then  moves  the
              byte to a buffer so that your application program can later read it.

              If transmitter interrupts are enabled, then  bytes  are  queued  up  waiting
              transmission.   When  a  byte  is  moved  from  the UART transmitter holding
              register to the UART transmitter shift register, an interrupt  is  generated
              and  the  next  byte is taken from the library transmitter buffer by the ISR
              and written to the UART holding register.

              Up to 16 bytes can be taken from the transmitter buffer while processing one
              transmitter  interrupt  if an 16550 UART is used. The 16550 UART is strongly
              recommended for computers doing serial communications under Windows.

              Refer to the sections entitled "RS232 Signals" and "National  INS8250  UART"
              for further information on these topics.









             PCL4W Users Manual                                                Page 16
              6.2 Standard Port Addresses


              There  are  a  few  things to know about how serial communications ports are
              used by IBM PC/XT/AT and compatible computers.  The  standard  IBM  PC/XT/AT
              configuration values are as follows:

                    Port     Reg Base   IRQ Line   Vector
                    COM1        3F8H         4        12
                    COM2        2F8H         3        11
                    COM3        3E8H         4        12
                    COM4        2E8H         3        11

              (Refer to your DigiBoard manual for DigiBoard addresses).

              PCL4W  assumes the above values.  If necessary, the UART base address can be
              changed by SioUART, and IRQ lines can be re-assigned  by  SioIRQ.   Remember
              that  each  port to be used concurrently must have a unique IRQ line.  Refer
              to the PCL4W Reference Manual for specific details.

              When installing new  communications  cards,  the  following  guidelines  are
              recommended:

              (1)  Be  sure to read the documentation for the hardware you are installing.
              Pay special attention to UART base addresses and IRQ lines, particularly  if
              trying to set up a non-standard configuration.

              (2)  If  you  have  a  choice in base addresses and IRQ lines, always choose
              standard values as defined above.

              (3) The first port should be COM1, the second COM2, etc.

              (4)  Use SioUART to zero all unused ports (for example, call SioUART(COM4,0)
              if there is no COM4 port installed).

              (5) Be carefull not to configure two ports for the  same  address.  This  is
              easier to do than you may believe.

              (6)  Choose  an  external  modem over an internal one.  It is much easier to
              debug problems with an external modem than an internal one.

              (7) Select hardware flow control (RTS/CTS) if flow control is  required  and
              hardware flow control is not the default.

              (8)  Always  test your port as soon as it is installed. Try several programs
              that use the communications ports.





















             PCL4W Users Manual                                                Page 17
              6.3 Running 3 or 4 Ports Concurrently


              PCL4W supports up to 4 serial ports running concurrently (more if you have a
              DigiBoard).  One free interrupt for each port is required. Refer to the next
              section if you have a DigiBoard.

              Interrupts IRQ4 and IRQ3 are dedicated to  the  communications  ports  in  a
              standard  IBM  PC/XT/AT configuration.  IRQ4 is shared between COM1 and COM3
              while IRQ3 is shared between COM2 and COM4.  This means that you can run two
              ports simultaneously provided that they don't share an interrupt.

              Suppose that you wish to run 3 ports simultaneously. To begin, you must have
              3 serial UARTs installed on your computer.  Assume,  for  purposes  of  this
              discussion,  that  COM1  is installed on your motherboard, and that you have
              purchased a new 2 port serial communications board.

              You should be able to configure the first serial board port as  COM2,  which
              uses IRQ3.  Refer to the manual that came with your serial board.

              In  order  to  run the third serial port concurrently with the first two, an
              unused interrupt must be found.  If your serial card can use only  IRQ3  and
              IRQ4,  then there is no way to run a third line since IRQ4 and IRQ3 are used
              for COM1 and COM2.

              However, many serial cards can use other IRQs, typically IRQ2 through  IRQ7.
              Since  IRQ5  is  normally  used  for  a  second  printer  port, it is a good
              candidate for COM3. To use IRQ5 for the third serial port,  first  set  your
              serial card to use IRQ5 for COM3 (refer to your serial card manual) and then
              add the following line to your applications code before calling SioReset:

                   SioIRQ(COM3,IRQ5);

              Don't  forget  to  disable  any device that might use IRQ5, such as a second
              printer port or a music card.   Unfortunately,  there  is  no  easy  way  to
              determine  that  you have no conflicts until you actually attempt to use the
              IRQ. If there are conflicts, your system will probably  hang  and  you  will
              have to reboot.

              To  run  a  fourth  serial  port,  another  free IRQ must be found.  On some
              systems, IRQ7 can be used. You must first disable IRQ7 on your parallel port
              card first (your printer doesn't need an IRQ). To use IRQ7  for  the  fourth
              serial port, first set your serial card to use IRQ7 for COM4 and then add:

                   SioIRQ(COM4,IRQ7);

              To  summarize,  your  serial  card must be able to generate the correct IRQ,
              which is not already being used. Refer to the entry for the SioIRQ  function
              in the PCL4W Reference Manual.


















             PCL4W Users Manual                                                Page 18
              6.4 Using the DigiBoard


              The Personal Communications Library supports the DigiBoard  PC/4  and  PC/8,
              not  the Intelligent Digiboards such as the PC/Xe and PC/Xi. In order to use
              the DigiBoard, you must configure PCL4W using the SioPorts(), SioUART(), and
              SioIRQ() functions.

              Your PCs ports must be partitioned into "standard" PC  ports  and  DigiBoard
              ports.  Remember that standard PC ports cannot share IRQs like the DigiBoard
              can.  If  you  are  using IRQ4 and IRQ3 for standard PC ports COM1 and COM2,
              then you cannot use either for DigiBoard ports (try IRQ5 or IRQ7).

              Suppose that COM1 through COM2 are standard PC ports (using IRQ4  and  IRQ3)
              and  you  have  installed  a  PC/8  DigiBoard  that you wish to use for COM3
              through COM10 using interrupt line IRQ5.  You choose to use the  recommended
              DigiBoard UART addresses at 0x100, 0x108, 0x110, 0x118, 0x120, 0x128, 0x130,
              and  0x138.   Add  the  following  configuration statements before doing any
              other serial processing:

              SioPorts(10,COM3,0x140); /* COM3  is  first  DigiBoard  port  */

              Address = 0x100; /* first DigiBoard UART address */

              for(Port=COM3;Port<=COM10;Port++) /* look at each port */
                 {SioUART(Port,Address);        /* set the UART  address  */
                  Address  +=  8;               /* compute  next  address */
                  SioIRQ(Port,IRQ5);            /* set the DigiBoard IRQ */
                 }

              The DigiBoard uses 0x140 for the status address for odd interrupts and 0x141
              for even interrupts.  Thus 0x140 is used for the status address  since  IRQ5
              is used for the interrupt in the example above.

              Don't  forget  that  your DigiBoard hardware must be configured to match the
              IRQ and UART values that you specify in the library. Refer to your DigiBoard
              manuals for more information.

              The PCL4W library comes configured for 4 PC ports and no DigiBoard ports  --
              SioPorts(4,4).   Refer  to  the  PCL4W  Reference  Manual  for more detailed
              information on SioPorts(), SioUART(), and SioIRQ().

              If you are interested in the DigiBoard, they may be contacted at 6400 Flying
              Cloud  Drive,  Eden  Prairie,  MN  55344.   Telephone  612-943-9020  or  FAX
              612-943-5398.















⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?