Home
User Manual - Electrocomponents
Contents
1. Stop interrupts SerialRemovePort PortNo Remove the port from the operations Blue Chip Technology Ltd 127 157 Chapter 3 Using The Serial DLL Page 8 An Example Using Visual Basic The Project MAKE file should include the file BCTSIO TXT which has a declaration for each of the BCTSIO functions Dim PortNo as Integer The current port number Dim Result as Integer The result result SerialStop Ensure interrupts are stopped PortNo SerialInstallPort amp H3F8 1000 4 9600 0 8 1 Install Port if PortNo lt 0 then report error here and exit If error report it result SerialStart Start Interrupts if result lt O then report error here and exit If error report it result SerialPutBuffer PortNo 1234567890 10 Transmit the message 1234567890 if result lt O then report error here and exit If error report it Do result SerialGetByte PortNo Read and display any received characters if result chr 27 then Exit Do print_character result until an Escape character is detected Loop result SerialStop Stop interrupts result SerialRemovePort PortNo Remove the port from the operations Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 9 FUNCTION REFERENCE This section contains an alphabetic reference to the functions contained in BCTSIO Function Quick Reference Remove an installed port Blue Chip Technology Ltd 127
2. Ltd 127 157 Chapter 5 SIOTEST Page 41 1 SerialWriteModemControl The following window is displayed WriteModem 2 Port Ho Modem Control Register 0 o CI DTR O RTS out AR54227485 Transmitter Enable L 0UT2 Interrupt Enable Loop Back Enable The controls on the Modem Control Window are as follows PortNo The currently selected PortNo Modem Control Register The result of calling SerialReadModemControl DTR Check Box Set Reset the DTR Line RTS Check Box Set Reset the RTS Line OUT1 Check Box Set Reset the OUT1 Line OUT2 Check Box Set Reset the OUT2 Line Loopback Enable Check Box Set Reset the Loopback feature Exit Button Return to Test Functions window The Modem Control Window allows full interactive control of the Modem Control Register Each click in the check boxes will invert the state of that line which will be output to the Modem Control Register The current setting of the Modem Control Register will be read back and displayed in the Modem Control Register field Blue Chip Technology Ltd 127 157 Chapter 5 SIOTEST Page 42 2 SerialReadModemControl Read the contents of the Modem Control Register The return value 1s shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box 3 SetinterruptAddress The following window is displayed Set Interrupt Address Setinterruptaddress This windows allows the address of the Interrupt Status Regist
3. the BCTSIO version which is 0x100 or amp H100 100H for this version of BCTSIO Description Return the current version of BCTSIO in the form xxyy hex where xx is the major version number and yy is the minor version number For example 0100 hex refers to version 1 00 Example result SerialVersion Return the version of BCTSIO SerialWriteModemControl Definition C int SerialWriteModemControl int PortNo int Mdata Visual Basic SerialWriteModemControl ByVal PortNo As Integer ByVal Mdata As Integer as Integer Parameters PortNo The port number returned from SerialInstallPort when installing the port Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 28 Mdata The data to output to the Modem Control lines formatted as follows Bit 0 Complement of the DTR output 1 Complement of the RTS output 2 Complement of the OUT1 output 3 Complement of the OUT2 output Interrupt Enable 4 Loopback enable bit Return value 0 Success 2 PortNo is invalid Description Program the contents of the Modem Control Register to the specified value The DTR and OUT outputs are used in serial cards to enable and disable the transmit line driver It performs no function with the RS232 based cards The OUT2 output enables the interrupt output from the port if this bit is set to a 1 If this bit is set to O all further interrupts from this port will stop The loopback enable bit is usually set to 0 If set t
4. transmit any characters that have been typed into the send buffer The result of the call to SerialPutBuffer is placed in the SerialPutBuffer Result text box Blue Chip Technology Ltd 127 157 Chapter 5 SIOTEST Page 37 G SerialPutByte The following window is displayed Put Characters PortNo Result Returned from SerialPutbyte Enter characters to send PO The controls on the PutBuffer window are as follows PortNo The currently selected PortNo Characters to Send Any characters typed in here will be sent SerialPutByte Result The result of calling SerialPutByte Exit Button Return to Test Functions window When a character 1s placed in the character send buffer it will be immediately transmitted out of the port shown in the PortNo field by calling SerialPutByte The result of calling SerialPutByte will be placed into the result text box H SerialReadModemStatus Read the state of the modem control lines inputs which are reflected in the modem status register SerialRemoveAllPorts Remove all the previously installed ports from operating under BCTSIO The return value is shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box Blue Chip Technology Ltd 127 157 Chapter 5 SIOTEST Page 38 J SerialRemovePort Remove the previously installed port Portno from operating under BCTSIO The return value is shown in the Result Code Text Box The Error Message if any is shown i
5. user defined e All receive channels are fully buffered up to 30Kbytes per port e Support any of the standard baud rates bits per character and number of stop bits e User specified hardware interrupt channels Any port may be assigned to any interrupt e RS422 RS485 Support for cards that enable the Transmitter using one of the UART control lines e Graphical User interface allowing all the functions including the transmission and monitoring of serial data to be exercised without the need for any programming Complete Source Code supplied Blue Chip Technology Ltd 127 157 Chapter 1 Introduction Page 2 Typical Applications e Use with the Blue Chip Technology Range of serial cards including the MSC8 eight port card Advanced programming applications Systems Integration using serial data links Introduction to Serial programming under Windows Data Acquisition The Functions The following functions are provided by BCTSIO Install and configure a communications port Remove an installed port Remove all installed ports Get a character from the specified port Get a buffer from the specified port Send a byte to the specified port Start the port hardware interrupts Stop the port hardware interrupts Send a buffer to a specified port Return the number of characters in the receive buffer Return the free space in the receive buffer Check to see if the port transmitter is ready for another character Clear the receive buf
6. 157 Chapter 4 Function Reference Page 10 Detailed Function Reference This section describes each of the BCTSIO functions in turn SerialCheckPortNo Definition C int SerialCheckPortNo int Visual Basic SerialCheckPortNo ByVal PortNo as Integer as Integer Parameters PortNo The number returned from calling SerialInstallPort to install a port Return Value 1 If PortNo is valid 1 otherwise Description SerialCheckPortNo is called to check to see if a PortNo is valid and has been installed using SerialInstallPort Example result SerialCheckPortNo 3 In the example result 1 if PortNo 3 is valid i e a previous call to SerialInstallPort returned 3 Otherwise result 1 SerialGetBuffer Definition C int SerialGetBuffer int PortNo LPSTR Buffer unsigned int Buflen Visual Basic SerialGetBuffer By Val PortNo as Integer Buffer as String Parameters PortNo The Port number as returned from SerialInstallPort Buffer The address of the buffer to place the data in Buflen The maximum number of characters to copy to the buffer 0 means copy all of the available characters from the buffer ensure that there is enough space to receive them Return Value The number of characters transferred or 2 if the PortNo was invalid Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 11 Description Copy up to the specified number of characters from the receiver buffer to the specified buffer If less then the specif
7. C int SerialRxFree int PortNo Visual Basic SerialRxFree ByVal PortNo as Integer as Integer Parameters PortNo The port number returned from SerialInstallPort when installing the port Return value n gt 0 Amount of free space remaining in receive buffer 2 PortNo is invalid Description Return the amount of free space remaining in the receive buffer This is equal to the maximum length of the receive buffer minus the number of characters in the receive buffer Example result SerialRxFree 8 Return the number of free bytes left in the receive buffer for port 8 SerialRxIntCount Definition C long SerialRxIntCount void Visual Basic SerialRxIntCount as Long Parameters Return value The number of characters received in total since the last call to SerialStart Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 21 Description This function returns the number of receiver interrupts which is equal to the number of characters received for all ports in total since the last call to SerialStart Example result SerialRxIntCountd Return the number of received characters since the last call to SerialStart SerialSendBreak Definition C int SerialSendBreak int PortNo Visual Basic SerialSendBreak By Val PortNo As Integer As Integer Parameters PortNo The port number returned from SerialInstallPort when installing the port Return value O Break sent successfully 2 PortNo is invalid Descript
8. ESSED FILE NAME 0 Write modem control register form EZ ECT AU VBRUN300 DL_ Visual Basic DLL to go with Set up and VBRUN300 DLL SIOTEST DDEML DL _ DLL to go with the set up program DDEML DLL SETUP LST List of files that makeup the set up utility A SETUP1 EX_ Executable part of the set up utility MN Blue Chip Technology Ltd 127 157 Chapter 8 Notes About Specific Cards Page 49 NOTES ABOUT SPECIFIC CARDS FEATURE ae MCS 4 6 8 SPIO ae SIO2 P No of serial channels 4 6 8 RS232 RS422 RS485 20 mA Loop RS485 Transmitter DTR or DTR or DTR or DTR or Enable OUTI OUTI OUT OUTI No of ports sharing a 1 Up to 8 t 1 1 single interrupt Using plug in personality modules Using the Common Interrupt Mode Blue Chip Technology Ltd 127 157
9. OM14 la8H 15 COMI5 1b0H 16 COM16 1b8H See section on Sharing IRQ 3 and IRQ4 Buflen Length of buffer that receives input characters The longer the buffer the less often the program needs to check the number of characters in the buffer Minimum 16 bytes Maximum 32000 bytes IrqNo The Hardware interrupt request line that the serial port is connected to for receive character interrupts Minimum 0 Maximum 15 Baud The baud rate that the characters are transmitted and received at Permitted values are 50 75 110 300 600 1200 2400 4800 9600 19200 38400 57600 115200 Parity The parity settings for the transmitted and received characters Permitted values are No Parity O or N Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 13 Odd Parity 1or O Even Parity 2 or E BitsPerChar The number of data bits per transmit and receive character Permitted values are 5 6 7 or 8 StopBits The number of stop bits per transmit and receive character Permitted values are 1 or 2 PortNo gt 0 Channel No port installed successfully 3 Too many port installed max 64 4 The port at the specified address has already been installed 5 Not enough memory to allocate receive buffer 6 Interrupts running stop with SerialStop first 10 Invalid baud rate specified 11 Invalid parity specified 12 Invalid number of stop bits specified 13 Invalid number of bits character specified Description Before a
10. SIO DLL Serial I O DLL User Manual Serial DLL Software User Manual Document Part N 127 157 Document Reference DLL SER DLL 127_157 doc Document Issue Level 1 2 Manual covers software version 1 All rights reserved No part of this publication may be reproduced stored in any retrieval system or transmitted in any form or by any means electronic mechanical photocopied recorded or otherwise without the prior permission in writing from the publisher For permission in the UK contact Blue Chip Technology Information offered in this manual is correct at the time of printing Blue Chip Technology accepts no responsibility for any inaccuracies This information is subject to change without notice All trademarks and registered names acknowledged Blue Chip Technology Ltd Chowley Oak Tattenhall Chester Cheshire CH3 9EX Telephone 01829 772000 Facsimile 01829 772001 Amendment History Issue Issue Author Amendment Details Level Date 11 9 94 Document Reference was BCTSIO10 doc 22 1 96 Revised front sheet Reformatted to A5 5 6 96 New address added 02 7 97 Contents INTRODUCTION ou sensual sce sede aaa a aa aeaa 1 FEATURES OF THE SERIAL DLL FOR WINDOWS cccccccececccecececescccecececucess 1 TYPICAL APPLICATIONS ic 2 THE FUNCITONS sanan 2 THE PACKAGE in 2 A OR AC RUC OE et ARES eel ce TRE NMEE ro Sa PN ACN RT Oe 3 REQUIREMENTS E 3 INSTALLATION a 4 SOFTWARE INSTALLATION
11. SUMMARY OF THE DISTRIBUTION DISK occcccccocccccccccoccccnccoccoccccnocnos 47 NOTES ABOUT SPECIFIC CARDS 2 cccccccccccccccccccccccccccccccccccccees 49 Blue Chip Technology Ltd 127 157 Chapter 1 Introduction Page 1 INTRODUCTION The Blue Chip Technology Serial DLL BCTSIO for Windows is designed for programmers who wish to add interrupt driven serial communications to their Windows programs for IBM PC XT ATs and 100 compatibles BCTSIO is particularly suited for systems requiring more serial ports than normally supported by Windows In addition to BCTSIO a fully comprehensive test program is supplied complete with source code BCTSIO is Windows DLL Dynamic Link Library containing a suite of interrupt driven RS232 device drivers By making calls to BCTSIO the users program can configure up to 64 serial ports and transfer data through any of them BCTSIO receives any characters from the serial port into character input queue the size can be set by the user from 16 to 32000 bytes 1 queue per port This means that the user program may ignore any characters received at the serial port for a while without losing any characters Features Of The Serial DLL For Windows e Simple to use Windows based interrupt driven RS232 communications e Programming language independent Visual Basic C Pascal Assembler etc e Supports up to 64 serial ports e Support serial ports at any I O address The address may be
12. Val State As Integer As Integer Parameters PortNo The port number returned from SerialInstallPort when installing the port State 0 Set RS232 RTS line to 12v 1 Set RS232 RTS line to 12v Description This function allows the RTS line to be either set or reset This line may also be used to enable or disable the transmitter enable on cards supporting this feature Example SerialSetRTS 8 0 Set the RS232 RTS line to 12v Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 24 SerialSetOut1 Definition C int SerialSetOutl int PortNo int State Visual Basic SerialSetOutl By Val PortNo As Integer ByVal State As Integer As Integer Parameters PortNo The port number returned from SerialInstallPort when installing the port State 0 Set OUTI to a Logic 1 1 Set OUTI to a Logic O Description This function allows the OUTI line to be either set or reset This line may also be used to enable or disable the transmitter enable on cards supporting this feature Example Seria LSeroue 1570 Disable the transmitter on RS422 485 port 15 SerialStart Definition C int SerialStart void Visual Basic SerialStart as Integer Parameters Return value O Successfully started interrupts 8 Interrupts already started 16 Interrupt Status Register Address not set for an IRQ where more than one port has been allocated Description Start the interrupts running After this call the specified hardware i
13. a m alo E EL j E k m From this screen all of the BCTSIO functions may be exercised interactively The Exercise Functions screen contains the following controls Buttons A Z 1 2 3 amp 4 Result Code Text Box Error message Text Box Installed Ports List Box Current PortNo Text Box Port Monitor Input Button Exit Button Blue Chip Technology Ltd Exercise each of the BCTSIO functions Shows the value returned after calling any function Show the error message represented by the value in the Result Code Text Box List of the all of the ports installed with SerialInstallPort The PortNo selected from the Installed Ports List Box which will be used as the PortNo parameter for the BCTSIO functions Allows the monitoring of any characters received on the currently selected PortNo Any characters typed are transmitted Return to the Main SIOTEST menu 127 157 Chapter 5 SIOTEST Page 34 SIOTEST Functions Before any of the other SIOTEST functions may be used successfully at least 1 port must be installed by using SerialInstallPort and the BCTSIO interrupt system must be started by using SerialStart Note SIOTEST does not enforce the order in which functions are exercised even if this is invalid so that the operation of all functions may observed if required A SerialCheckPortNo SerialCheckPortNo is called to check to see if the PortNo shown in the Current PortNo text box is valid and ha
14. bed above these addresses should be avoided Subject to already being occupied by existing hardware the following addresses may be tried without disabling the Windows comm drivers 280 288 290 298 240 2A8 2B0 2B8 1A0 1A8 1B0 and 1B8 Blue Chip Technology Ltd 127 157 Chapter 3 Using The Serial DLL Page 7 USING THE SERIAL DLL BCTSIO is a Windows DLL Dynamic Link Library providing 21 functions to support serial communications especially for the support of multiple serial port cards BCTSIO functions may be called by any Windows based application that can make DLL calls including C Visual Basic Pascal Excel etc An Example Using C include bctsio h Include the BCTSIO definitions int PortNo The current port number int result The result SerialStopQ Ensure interrupts are stopped PortNo SerialInstallPort 0x3F8 1000 4 9600L 0 8 1 Install Port if PortNo lt 0 report error here and exit Tf error report it result SerialStart Start Interrupts if result lt 0 report error here and exit If error report it result SerialPutBuffer PortNo 1234567890 10 Transmit the message 1234567890 if result lt 0 report error here and exit Tf error report it while result SerialGetB yte PortNo 0x 1b Read and display received characters print_character result until Escape character detected SerialStop
15. ber of the Interrupt Status Register as set in the SetInterruptAddress function MSC4 6 8 card only Return value 2 If PortNo is invalid Status Interrupt Status see description below Description This function is used to read the interrupt status from the MSC4 6 8 card The bits are encoded as follows Y Channel 1 Channel 2 Channel 3 Channel 4 Channel 5 Channel 6 Channel 7 Channel 8 NYA NB UN ODO Bits 8 to 15 are not used A bit set indicates that a channel has a pending interrupt A bit cleared indicates no interrupt pending on that channel For further details refer to the MSC 4 6 8 data sheets Example Sstatus SerialReadInterruptStatus 5 Read the status of the Interrupt Status Register monitoring interrupts on IRQ 5 Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 18 SerialRemoveAllPorts Definition C int SerialRemoveAllPorts void Visual Basic SerialRemoveAllPorts as Integer Parameters Return value 0 All ports remove from interrupts successfully 6 Interrupts running call SerialStop first Description Remove all the previously installed ports from operating under the Serial DLL Example result SerialRemoveAl1lPorts SerialRemovePort Definition C int SerialRemovePort int PortNo Visual Basic SerialRemovePort ByVal PortNo as Integer Parameters PortNo The port number returned from SerialInstallPort when installing the port Return value 0 All ports remove from inte
16. e Asynchronous Communications Adapter using the INS8250 UART or equivalent and that pin OUT2 is used to enable the interrupt output BCTSIO is designed to operate with Windows version 3 1 in enhanced mode To share an interrupt between multiple ports the hardware must have been specifically design to do so e g the Blue Chip Technology MSC8 card Blue Chip Technology Ltd 127 157 Chapter 2 Installation Page 4 INSTALLATION Software Installation To install BCTSIO follow the procedure below e Run Windows e Place the BCTSIO installation floppy diskette in drive A or drive B e Run SETUP EXE on the installation disk by selecting File Run from the Program Manager menu e Select the directory to install BCTSIO in the default is CABCTSIO e This directory will contain the BCTSIO and the SIOTEST source files e A Windows group SIOTEST will be created containing an ICON for SIOTEST e Double clicking on the SIOTEST icon will run the BCTSIO test program SIOTEST Hardware Installation There are a few important points to consider when installing multiple port serial cards under Windows Hardware Interrupts You should only use hardware interrupts IRQO IRQ15 if they are not already being used by your computer hardware or Windows Blue Chip Technology Ltd 127 157 Chapter 2 Installation Page 5 These are typically used as follows your system may be different IRQO Timer IRQ1 Keyboard IRQ2 2nd interrupt controller IRQ3 Seria
17. eielon e E e 4 HARDWARE INSTALLATION aro o 4 Hardware In CVIUIDES A A AA esses isaac uetieaties 4 SHOVING TIC SCH TROTE A AA EA AE 5 USING THE SERIAL DEL iia 7 ANEXAMPLE USING ota bn 7 AN EXAMPLE USING VISUAL BASIC Ra 8 FUNCETTON REEERENCE lt aaa da ia 9 FUNCTION QUICK REFERENCE cccccescccsscccsscccscccsscccsscccsssccsseecssecssecssecsasecenees 9 DETAILED FUNCTION REFERENCE unica ii ida 10 Serial Check POr NO A di 10 NA AAA A A 10 A sebosie nated AA E A EA A A Il Salas ta PO dd oka Il Serial Fori OU Aso 14 SALF UIT O A tE 14 A AA A A E A 15 SentalRedd MO denS TUS A ASIA 16 SOLTAR CAAINICTTUPULSLALUS AAA ARA AAA AAA a 17 SENA LREMOPCAUROTES elui Nn riae ES A aaa 18 NOTO IREMOVELO isa iia 18 SEARS A a iras 19 Serial RAC OE Ai 19 STIR RO O A AS A AA A dad 20 Aa AAA tata attic lnc eae E aaa ech E 21 STIS CUOTA AA AAA AAA a 21 SELIGISECLINICTTUPIA CONESS a acct tusbaoeg divas OEE E CACC eS 22 VAS A TS 23 SENASA ONCE sinire E a e E e a 24 Blue Chip Technology Ltd 127 157 Contents TAO a A A A O AORE TEE 24 SCV SHO in o 25 NAAA E A 26 Serial GE NP A T E E A E 26 Ser a VES Oa A A AA e E O 27 SerialWriteModemControl 00 ccccccccacceccuccucceccscuscuccscescescuscecescescuccecescescuscucens 27 SerlalReadModem Cono e bi wed do eo 29 RETURN VALUES ANDERRORCODES ad o do De 30 SOTES Ei oido 31 RUNNING SITES Ta as aaa 31 SIOTES Ti RUINCTION SCS 34 SYSTEM REQUIREMENTS lt a 44 PERFORMANCE CONSIDERA TON Si ida 44
18. er to be set and assigned to a particular IRQ number This is only necessary when more than one port uses the same interrupt line which is only supported on the MSC 4 6 8 range of communications adapters 4 ReadinterruptStatus The following window is displayed Read Interrupt Status Channels O O O O O L 1234 56 Readinterrupt tatus If an Interrupt Status Register has been assigned to a particular IRQ then the interrupt status may be displayed by selecting the corresponding IRQ Blue Chip Technology Ltd 127 157 Chapter 5 SIOTEST Page 43 number The value returned is shown as a number and if valid gt 0 the interrupt status for each channel is shown Blue Chip Technology Ltd 127 157 Chapter 6 System Requirements Page 44 SYSTEM REQUIREMENTS Hardware BCTSIO requires that the hardware is compatible with the following Blue Chip Technology communication adapters e MSC8 2 4 6 and 8 channel versions SIO2 SPIO SIO2P SIO4d Any IBM PC compatible Asynchronous Communications Adapter using the INS8250 UART or equivalent and that pin OUT2 is used to enable the interrupt output e IBM PC AT 386 and 100 compatibles that are running Microsoft Windows 3 1 To share an interrupt between multiple ports the hardware must have been specifically design to do so e g the Blue Chip Technology MSCS8 card Software e BCTSIO is designed to operate under Windows version 3 1 in enhanced mode Performance Consideration
19. fer Result The result of the call to SerialInstallPort SerialInstallPort button Call SerialInstallPort Exit button Return to the functions menu Enter the details into the fields the default is set for COM1 Then press the SerialInstallPort button the result will be displayed in the Result field If successful the PortNo will be placed into the result field and the port details will be added to the Port List on the functions screen E SerialPortCount SerialPortCount is called to see how many ports are currently installed in BCTSIO If this value is not equal to the number of ports shown in the Ports Installed List Box it is possible that another task has installed some ports in BCTSIO The return value is shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box Blue Chip Technology Ltd 127 157 Chapter 5 SIOTEST Page 36 F SerialPutBuffer The following window is displayed PutButfer PortNo Result returned from SerialPutBuffer send Buffer Enter the Characters to Send Send The Buffer The controls on the PutBuffer window are as follows PortNo Text Box The currently selected PortNo Characters to Send Buffer Any Characters to be sent are placed in here SerialPutBuffer Result Text Box The result of calling SerialPutBuffer PutBuffer Button Call SerialPutBuffer Exit Button Return to Test Functions window When the PutBuffer button is pressed SerialPutBuffer is called to
20. fer of any characters Read the state of the port s modem lines Set the state of the ports modem lines Transmit a break to the specified port Return the current Serial DLL version number Check to see if the current port id is valid Return the total number of characters received Set Reset DTR RS422 RS485 transmitter enable Set Reset RTS RS422 RS485 transmitter enable Set Reset OUTI RS422 RS485 transmitter enable Check the Transmitter status The Package Blue Chip Technology Ltd 127 157 Chapter 1 Introduction Page 3 The BCTSIO package consists of the following items BCTSIO DLL The Serial VO Dynamic Link Library SIOTEST EXE Serial I O DLL Interactive User Interface including complete source code SETUP EXE Fully interactive Set up Utility BCTSIO H Header file for C programs using the Serial DLL SIOTEST SIOTEST has a Graphical User Interface which allows the user to exercise all the functions of the Serial DLL and monitor the data transfer on all of the serial ports without the need for any programming The complete source code for SIOTEST is supplied in Visual Basic which provides a complete set of examples showing the usage of each BCTSIO function This may also provide a starting point for your own project Requirements BCTSIO requires that the hardware is compatible with the following Blue Chip Technology communication adapters e MSC8 2 4 6 and 8 channel versions SIO2 SPIO SIO2P SIO4d Any IBM PC compatibl
21. ied number of characters were in the receive buffer then only the number of characters available are copied Example len SerialGetBuffer 4 buffer 100 Copy up to 100 characters from the receive buffer on port 4 SerialGetByte Definition C int SerialGetByte int PortNo Visual Basic SerialGetByte PortNo as Integer as Integer Parameters PortNo The port number returned from SerialInstallPort when installing the port Result The code of the next character in the receive buffer or 1 if no characters are available Description Call SerialGetByte in order to get the next character from the receive buffer Example byte SerialGetByte 0 Get the next byte from port 0 if byte 1 then none were available SeriallnstallPort Definition C int SerialInstallPort unsigned int PortAddress int Buflen int IrqNo long Baud int Parity int bitsPerChar int StopBits Visual Basic SerialInstallPort PortAddress as Integer Buflen as Integer IrqNo as Integer Baud as Long Parity as Integer BitsPerChar as Integer StopBits as Integer as Integer Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 12 Parameters PortAddress Serial Port Address if greater than 15 or 1 16 Specifies a particular COM port No Port Address l COMI 3f8H F 2 COM2 2f8H F 3 COM3 3E8H 4 COM4 2e8H 5 COM5 280H 6 COM6 288H 7 COM7 290H 8 COM8 298H 9 COM9 2a0H 10 COM10 2a8H 11 COM11 2b0H 12 COM12 2b8H 13 COM13 la0H 14 C
22. in the Serial DLL Example result SerialPortCount Returns the number of ports that are currently installed in the Serial DLL SerialPutBuffer Definition C int SerialPutBuffer int PortNo LPSTR Buffer unsigned int Buflen Visual Basic SerialPutBuffer ByVal PortNo as Integer Buffer as string ByVal Buflen as Integer as Integer Parameters PortNo The port number returned from SerialInstallPort when installing the port Buffer The buffer containing the characters to send Buflen The number of characters to transmit from the buffer Return Value O The buffer was successfully transmitted 2 Invalid PortNo Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 15 Description Buflen characters from Buffer are transmitted to port PortNo Note If the port transmitter 1s not ready SerialPutBuffer will wait until 1t is before sending the next character Example result SerialPutBuffer 1 Hello 5 Transmit the message Hello to port 1 SerialPutByte Definition C int SerialPutB yte int PortNo int Byte Visual Basic SerialPutByte PortNo as Integer Byte as Integer as Integer Parameters PortNo The Port number as returned from the called to SerialInstallPort Byte The 8 bit value to send to the specified port Result 0 If successfully transmitted 22 If PortNo invalid Description The specified byte is transmitted out of the specified port if that port is not already busy transmitting another byte If it is bu
23. ion This function transmits a break to the specified port Normally the transmit data line is sending a marking signal indicating no data is present A break is a spacing signal which lasts for longer than a valid character pattern Example result SerialSendBreak 4 Transmits a break on port 4 SerialSetDTR Definition C int SerialSetDTR int PortNo int State Visual Basic SerialSetDTR ByVal PortNo As Integer ByVal State As Integer As Integer Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 22 Parameters PortNo The port number returned from SerialInstallPort when installing the port State O Set RS232 DTR line to 12v 1 Set RS232 DTR line to 12v Description This function allows the DTR line to be either set or reset This line may also be used to enable or disable the transmitter enable on cards supporting this feature Example SertalSetDIR 3 1 Set the RS232 DTR line to 12v SerialSetinterruptAddress Definition C int SerialSetInterruptAddress int IrqNo int Address Visual Basic SerialSetInterruptAddress ByVal IrqNo As Integer ByVal Address As Integer As Integer Parameters Address The address that the Interrupt Status Register is set to on the MCS 4 6 8 card when configured for Common Interrupt Mode IrqNo The hardware interrupt request line that the Interrupt Status Register is assigned to Minimum 0 Maximum 15 Description This function will only operate in conjunctio
24. ion should be called to initiate data transfer The return value is shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box Blue Chip Technology Ltd 127 157 Chapter 5 SIOTEST Page 40 W SerialStop Stop the BCTSIO interrupts running After this call all the BCTSIO hardware interrupts IRQ are disabled Any characters received on any of the ports will be ignored and no more transmission will take place Interrupts may be started at any time by calling SerialStart This function should be called before the user program terminates otherwise characters will continue to be received into the internal buffers unless of course this 1s specifically required The return value is shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box X SerialTxReady Check that the transmitter for the specified port is ready to receive another character The return value is shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box Y SerialTxEmpty Check to see 1f the transmitter is completely empty of all characters The return value 1s shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box Z SerialVersion Return the version of BCTSIO The return value is shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box Blue Chip Technology
25. kly as possible Disk access 1s slow Ensure that there is enough room in the receive buffers to receive any incoming characters when a disk access is in progress If possible stop serial data transfer during this time using some form of flow control 127 157 Chapter 6 System Requirements Page 46 User program Screen Access In general screen access 1s slow separate the receive data routines from any screen access routines Blue Chip Technology Ltd 127 157 Chapter 7 Distribution Disk Page 47 SUMMARY OF THE DISTRIBUTION DISK The BCTSIO package is supplied on one 342 1 44 Mbyte HD IBM PC AT compatible double sided high density diskette The following files are supplied BCTSIO DLL The Serial DLL for Windows library Placed in the windows system directory Source code for SIOTEST Visual Basic BCTSIO TXT Serial DLL declarations GETBUFFE FRM Get Buffer Form INSTPORT FRM Install Port form MAINMENU FRM Main Menu MONINPS FRM Monitor up to 8 Inputs form MONINPUT FRM Monitor a single input PUTBUFFE FRM Puta buffer form PUTCHARS FRM Put a character form TESTFNS FRM Test each functions menu WRITEMOD FRM Write modem control register form SIOTEST EXE Executable version of SIOTEST BCTSIO H C Header file for the Serial DLL VBRUN300 DLL Visual Basic Runtime library READ ME Last minute documentation update if present Blue Chip Technology Ltd 127 157 Chapter 7 Distribution Disk Page 48 DISK FILE DESCRIPTION UNCOMPR
26. l channel 2 COM2 IRQ4 Serial channel 1 COM1 IROS Second Parallel Printer often not used IRQ6 Floppy Disk IRQ7 First Parallel Printer often not used IRQS Real time clock IRQ9 Redirected to IRQ2 IRQ10 Reserved IRQ11 Reserved IRQ12 Reserved IRQ13 Maths Unit IRQ14 Fixed disk controller IRQ15 Reserved Sharing IRQ 3 and IRQ4 Windows 3 1 provides a communications driver to support serial ports COM1 on IRQ4 and COM2 on IRQ3 This driver only allows COM to use IRQ4 and COM2 to use IRQ3 any attempt to support more than one serial port on either IRQ will be blocked by Windows the Serial DLL will support COM1 on IRQ3 and COM2 on IRQ4 with no additional considerations However if more than one port is to be installed on either IRQ3 or IRQ4 the Windows communications drivers must be disabled To disable the windows serial communications driver make the following modifications to the SYSTEM INI file in your windows directory where you see the entry comm drv comm drv place a semicolon before it 1 e comm drv comm drv This will remove the current Windows communications drivers After removing the Windows communications drivers there would appear to be no limit on how many serial ports may be configured to use it Blue Chip Technology Ltd 127 157 Chapter 2 Installation Page 6 In addition Windows also appears to monitor ports at COM3 03E8 and COM4 02E8 and therefore unless the comm driver is disabled as descri
27. lue Chip Technology Ltd 127 157 Chapter 5 SIOTEST Page 39 Send 0 to the DTR line on the port shown in the Port Select Box The return value is shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box R SerialSetRTS 1 Send 1 to the RTS line on the port shown in the Port Select Box The return value is shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box S SerialSetRTS 0 Send O to the RTS line on the port shown in the Port Select Box The return value is shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box T SerialSetOut1 1 Send 1 to the OUTI line on the port shown in the Port Select Box The return value is shown in the Result Code Text Box The Error Message 1f any is shown in the Error Message Text Box U SerialSetOut1 0 Send 0 to the OUTI line on the port shown in the Port Select Box The return value is shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box V SerialStart Start the BCTSIO interrupts running After this call the specified hardware interrupts IRQ 1s enabled Any characters received on any of the ports installed with SerialInstallPort will be placed into the receive buffers for that port Any characters sent to an installed port will be transmitted Interrupts may be stopped at any time by calling SerialStop This funct
28. n the Error Message Text Box K SerialRxClear Delete all of the characters from the receive buffer for the specified port The return value is shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box L SerialRxCount Return the number of characters ready to be read from the receive buffer for the specified port The return value is shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box M SerialRxFree SerialRxFree is called to see how many free bytes are available in the receive buffer The return value is shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box N SerialRxintCount Return the number of receiver interrupts which is equal to the number of characters received for all ports in total since the last call to SerialStart The return value is shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box O SerialSendBreak Transmit a break to the specified port Normally the transmit data line is sending a marking signal indicating no data 1s present A break is a spacing signal which lasts for longer than a valid character pattern P SerialSetDTR 1 Send 1 to the DTR line on the port shown in the Port Select Box The return value is shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box Q SerialSetDTR 0 B
29. n with the MSC 4 6 8 range of cards Normally it is not possible for more than one serial port to share the same interrupt line However the MSC 4 6 8 range of cards allow up to 8 ports to share one interrupt line In order to do this an Interrupt Status Register is used in order to identify which port generated the interrupt This function is used to specify the address of the Interrupt Status Register and the corresponding hardware Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 23 interrupt number All ports specified as using the same IrqNo as the Interrupt Status Register will be assumed to be sharing interrupts using the Common Interrupt Mode The order that the serial ports have been declared 1s important The first port to have been allocated to the specified IRQ will be assumed to be channel 1 on the MSC card the second port to channel 2 etc Example SeriallnterruptAddress 0x1FO0 5 portio SeraalinsballPort 0xste 1000 57 9600 2 porthol Seriralinstall Port 0x2tf8 1 000 07 960042 portnoZ SerralinslallPort 0x3ec 1000 5 9600 2 portnos Serralinstall Port Ox2ec 1000 5 9600 2 Set the address of the Interrupt Status Register on the MSC 4 6 8 card to Ox1FO serving interrupts using IRQ 5 portno0 will be assigned to channel 1 portnol will be assigned to channel 2 etc SerialSetRTS Definition C int SerialSetRTS int PortNo int State Visual Basic SerialSetRTS ByVal PortNo As Integer By
30. nd to aid in the testing of the serial port hardware SIOTEST allows the user to exercise all the functions of BCTSIO and monitor the data transfer on all of the serial ports without the need for any programming The complete source code for SIOTEST is supplied which provides a complete set of examples showing the usage of each BCTSIO function This may also provide a starting point for your own project Running SIOTEST To run SIOTEST either double click on the SIOTEST icon or type use the FILE RUN BROWSE menu from the Windows Program Manager to locate SIOTEST EXE and enter return to execute The window on the following page will be displayed SIOTEST Blue Chip Technology Ltd 127 157 Chapter 5 SIOTEST Page 32 Select Exercise Functions to test the BCTSIO functions or Exit to return to Windows Blue Chip Technology Ltd 127 157 Chapter 5 SIOTEST Page 33 On selecting the Exercise Functions option the following window will be displayed Exercise Functions Installed Ports Q SetDTR O SetATS 1 SetRTS 0 i GetBulfer GetByte a InstallPort PortCount PutB uffer ReadHodem5 tatus RemoveAllPorts RemovePort WrtehModemControl ReadHodemControl Current Porto Ho Result Code SetinterruptAddress Read nterruptStatus Error Message Honitor An Input 3 4 Monitor up To 8 Ports aa les ra e llos E e IE 1 a on en m z aaja rm a E mr Sil
31. nterrupts IRQ is enabled Any characters received on any of the ports installed with SerialInstallPort will be placed into the receive buffers for Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 25 that port Any characters sent to an installed port will be transmitted Interrupts may be stopped at any time by calling SerialStop This function should be called to initiate data transfer Example result SerialStart Start BCTSIO interrupts running SerialStop Definition C int SerialStop void Visual Basic SerialStop as Integer Parameters Return value O Successfully started interrupts 9 Interrupts not started Description Stop the Serial DLL interrupts running After this call all the Serial DLL hardware interrupts IRQ are disabled Any characters received on any of the ports will be ignored and no more transmission will take place Interrupts may be started at any time by calling SerialStart This function should be called before the user program terminates otherwise characters will continue to be received into the internal buffers unless of course this 1s specifically required Example result SerialStop void Stop BCTSTO interrupts running Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 26 SerialTxReady Definition C int SerialTxReady int PortNo Visual Basic SerialTxReady ByVal PortNo As Integer As Integer Parameters PortNo The port number returned fr
32. o 1 the port internally loops back the data and modem lines For further details refer to the data sheets on the serial card you are using and the manufacturers data sheets for the 8250 or equivalent UART C The current settings of the modem control register may be read by calling the SerialReadModemControl function Example result SerialWriteModemControl 2 8 Write 8 to the Modem Control Register for PortNo 2 Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 29 SerialReadModemControl Definition C int SerialReadModemControl int PortNo Visual Basic SerialReadModemControl ByVal PortNo As Integer as Integer Parameters PortNo The port number returned from SerialInstallPort when installing the port Return value gt 0 The contents of the Modem Control Register 2 PortNo is invalid Description Read the contents of the Modem Control Register See the description for SerialWriteModemControl Example result SerialReadModemControl 2 Read the contents of the Modem Control Register on port 2 Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 30 Return Values and Error Codes The following values can be returned from the functions Po es 3 III nerpisurnng a Reaver a Reta Blue Chip Technology Ltd 127 157 Chapter 5 SIOTEST Page 31 SIOTEST SIOTEST is a menu driven program written in Visual Basic V3 00 designed to demonstrate the use of BCTSIO a
33. om SerialInstallPort when installing the port Return value O The transmitter is not ready for another character 1 The transmitter 1s ready for another character 2 PortNo is invalid Description Check to see if the transmitter for the specified port is ready to transmit another character If the transmitter is not busy then another character may be sent immediately Example result SerialTxReady 7 Check to see if the transmitter on port 7 is ready to transmit another character SerialTxEmpty Definition C int SerialTxEmpty int PortNo Visual Basic Serial TxEmpty ByVal PortNo As Integer As Integer Parameters PortNo The port number returned from SerialInstallPort when installing the port Return value 1 The transmitter is completely empty of any characters O The transmitter still has characters to transmit 2 PortNo is invalid Description Check to see if the transmitter for the specified port is completely empty of characters 1 e all characters have been sent This function is designed Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 27 to be used in RS485 half duplex systems where the transmitter is to be turned off after the last character has been sent Example result SerialTxEmpty 7 Check to see 1f the transmitter on port 7 1s empty of all characters SerialVersion Definition C int SerialVersion void Visual Basic SerialVersion as Integer Parameters Return value Return
34. port can be used for communications 1t must be initialised and allocated to a hardware interrupt IRQ line SerialInstallPort is used to initialise the port allocate the port to a particular IRQ and allocate a receive buffer The return value from the called returns either an error code or a port number or handle which identifies the particular port This port number is used with many of the other functions to identify the port A port may be removed from the communications system by a call to the function SerialRemovePort The communications routines must be inactive when SerialInstallPort is called so it either must not have been started with SerialStart or SerialStop must be called first Example result SerialStop POLrl no SerralinstallPorr Ox3sio 1000 4 9600 2777 13 result SerialStart Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 14 In the example The interrupt and communications system 1s stopped The serial port at address 3F8 hex COM1 IRQ 4 is set to 9600 baud with Even Parity 7 bits per character and 1 stop bit The receive buffer length is set to 1000 bytes long The interrupt system and communications system is started up SerialPortCount Definition C int SerialPortCount void Visual Basic SerialPortCount As Integer Parameters Return Value The number of ports that are currently installed in the DLL Description Returns the number of ports that are currently installed
35. rrupts successfully 2 PortNo 1s invalid 6 Interrupts running call SerialStop first Description Remove the previously installed port Portno from operating under BCTSIO Example result SerialRemovePort 6 Remove the previously installed port 6 from BCTSIO operations Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 19 SerialRxClear Definition C int SerialRxClear int PortNo Visual Basic SerialRxClear By Val PortNo as Integer as Integer Parameters PortNo The port number returned from SerialInstallPort when installing the port Return value O Receive buffer cleared successfully 2 PortNo is invalid Description Delete all of the characters from the receive buffer for the specified port Example result SerialRxClear 13 Remove all the characters from the receive buffer for port 13 SerialRxCount Definition C int SerialRxCount int PortNo Visual Basic SerialRxCount ByVal PortNo as Integer as Integer Parameters PortNo The port number returned from SerialInstallPort when installing the port Return value n gt 0 Number of characters in receive buffer 2 PortNo is invalid Description Return the number of characters ready to be read from the receive buffer for the specified port Example result SerialRxCount 2 Return the number of characters in the receive buffer for port 2 Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 20 SerialRxFree Definition
36. s The performance of any Windows program including BCTSIO for Windows is heavily dependent upon the following factors PC Make and Model Some systems are better than others 32 bit buses are faster than 16 bit buses CPU Pentiums are faster than 486s etc CPU Clock speed The faster the better Amount of Memory The more the better At least 4Mb Size and Speed of Hard Disk Drive The faster and bigger the better Blue Chip Technology Ltd 127 157 Chapter 6 Size and type of Swap File Other running Programs System Requirements Page 45 Permanent Swap files are better than temporary ones Use the size that Windows recommends The more programs running the slower the performance of any individual program The following items will also affect the performance of the Serial DLL for Windows Number of Serial ports supported Serial baud rates Sharing Hardware Interrupts Serial Port Uart Type Receive Buffer Size User program Receive buffers User program Disk Access Blue Chip Technology Ltd The less ports the higher the performance The faster the baud rates the lower the performance If possible assign each serial port to an individual hardware interrupt IRQ Some of the newer UARTs types have build in FIFOs which will increase performance Check your hardware manual In general increasing the buffer size will improve the performance Remove the characters from the receive buffers as quic
37. s been installed using SerialInstallPort The return value is shown in the Result Code Text Box The Error Message 1f any is shown in the Error Message Text Box B SerialGetBuffer The following window is displayed Calbia Porta Di Aecurnwd Guta Hegel catered hon Serbia tule The controls on the GetBuffer window as follows PortNo Text Box The currently selected PortNo Received Buffer Any bytes read are placed into here SerialPutBuffer Result Text Box The result of calling SerialGetBuffer GetBuffer Button Call SerialGetBuffer Exit Button Return to Test Functions window when the GetBufferButton is pressed SerialGetBuffer is called any characters returned are copied into the Received Buffer The result of the call to SerialGetBuffer is placed in the SerialGetBuffer Result text box Blue Chip Technology Ltd 127 157 Chapter 5 SIOTEST Page 35 C SerialGetByte Read the next byte from the currently selected port The return value is shown in the Result Code Text Box The Error Message if any is shown in the Error Message Text Box D SeriallnstallPort A window is displayed The controls on the Install Port window are as follows PortNo Address The base address for the port in hexadecimal E g COM1 would be 03F8 Irq The hardware interrupt number 0 15 Baud Rate The Baud rate 110 115000 Stop Bits The number of stop bits 1 or 2 Parity The Parity O None 1 Odd 2 Even Buflen The length of the receive buf
38. sy it will wait until the previous byte has been transmitted before sending the byte Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 16 Example result SerialPutByte 1l A In the example the letter A is transmitted out of port number 1 SerialReadModemStatus Definition C int SerialReadModemStatus int PortNo Visual Basic SerialReadModem PortNo as Integer as Integer Parameters PortNo The Port number as returned from the called to SerialInstallPort Return value 2 If PortNo is invalid Status Modem Status see description below Description This function 1s used to read the state of the modem control lines inputs which are reflected in the modem status register The bits are encoded as follows Bit O Delta CTS 1 Delta DSR 2 Trailing edge of RI 3 Delta DCD 4 Complement of CTS input 5 Complement of DSR input 6 Complement of RI input 7 Complement of DCD input Bits 8 to 15 are not used For further details refer to the data sheets on the serial card you are using and the manufacturers data sheets for the 8250 or equivalent VART I C Example status SerialReadModemStatus 1 Blue Chip Technology Ltd 127 157 Chapter 4 Function Reference Page 17 Read the status of the modem control lines on port 1 SerialReadIinterruptStatus Definition C int SerialReadInterruptStatus int IrqNo Visual Basic SerialReadInterruptStatus IrqNo integer as Integer Parameters IrqNo The IRQ num
Download Pdf Manuals
Related Search
Related Contents
Proyecto piloto para la creación de una base de datos de 取扱説明書 - パナソニック KM3050-4050-5050 service manual KeepOut F85 May 2012 - Crawford Broadcasting Company TLS Soundmaker sarja - Suomen koulupalvelu Oy (K,C)A - Nordyne Sleep Apnea Therapy User Manual Copyright © All rights reserved.
Failed to retrieve file