Version 1.0.2

Table of content

License Agreement

What is Serial ToolKit ?

  Overview of features

  System requirements

    Operating System

  Getting Help - Technical Support

Installing Serial ToolKit

  Demo Version

Using Serial ToolKit

  Initialization

    STK_Init

  Getting informations about available serial ports

    STK_CountPorts

    STK_GetIndPort

  Opening and closing serial ports

    STK_Open

    STK_Close

  Configuring serial ports

    STK_Reset

    STK_HShake

    STK_SetBuf

  Getting informations about an opened serial port

    STK_Status

    STK_GetBuf

  Sending and receiving data

    STK_Send

    STK_Receive

Version history

License Agreement

Serial ToolKit for 4D
Developer Software License and Limited Warranty

PLEASE READ THIS LICENSE CAREFULLY BEFORE USING THE SOFTWARE. BY USING THE SOFTWARE AND ENTERING THE LICENSE NUMBER, YOU (LICENSEE) AGREE TO BECOME BOUND BY THE TERMS OF THIS AGREEMENT, WHICH INCLUDES THE SOFTWARE LICENSE AND WARRANTY DISCLAIMER (collectively referred to herein as the "Agreement"). THIS AGREEMENT CONSTITUTES THE COMPLETE AGREEMENT BETWEEN YOU AND THE AUTHOR. IF YOU DO NOT AGREE TO THE TERMS OF THIS AGREEMENT, DO NOT USE THE SOFTWARE AND PROMPTLY RETURN IT FOR A FULL REFUND.

1.Definitions.
COMPILED: A set of high level language instructions as been transformed into a set of processor level instructions which.
APPLICATION: Software developed by the LICENSEE intended to be used in a Compiled form with the Program and which should never allow use of the Program outside the scope of the Application.
DEVELOPMENT LICENSE: Annual renewable license granted to the LICENSEE to allow him to use the SOFTWARE in his developments. This license includes a limited DEPLOYMENT LICENSE.
DEPLOYMENT LICENSE: License required for each deployment (installation and use) of COMPILED APPLICATIONS by the LICENSEE.

2.Ownership of Software.
The enclosed manual and computer programs ("THE SOFTWARE") were developed and are copyrighted by Christian Quest, the author of Serial ToolKit for 4D ("THE AUTHOR") and are licensed, not sold, to you by THE AUTHOR for use under the following terms, and THE AUTHOR reserves any rights not expressly granted to you. You own the disk(s) on which any software is recorded, but THE AUTHOR retains ownership of all copies of THE SOFTWARE itself. Neither the manual nor THE SOFTWARE may be copied in whole or in part except as explicitly stated below.

3.Intellectual Property.
THE SOFTWARE and its manual is intellectual property of THE AUTHOR and/or its suppliers protected as such by French copyright law, international treaty provisions, and applicable laws of the country in which it is being used.
Trademarks, logos and trade-names quoted in this Agreement, on or in THE SOFTWARE are the property of their respective owners.
Any reproduction of THE SOFTWARE is only granted on the absolute condition that it contains all the legal specifications of THE SOFTWARE property.

4.License granted.
4.1 Software License. THE AUTHOR hereby grants to the LICENSEE, a non-exclusive, non-transferable license (the "License") to use and distribute THE SOFTWARE, for the purpose of distributing LICENSEE's own computer software (the "Licensee's Software") and to copy and distribute the SOFTWARE which are automatically embedded into Licensee's Software, either on a commercial or non-commercial basis, as defined here, subject to the terms and conditions set forth herein. THE AUTHOR, as Licensor, grants to you, the LICENSEE, a non-exclusive, non-transferable right to use this SOFTWARE, subject to the terms of the license as described below:

LICENSEE may:

LICENSEE may not:

LICENSEE must:

4.2. Initial Term. The term of the DEVELOPER LICENSE shall commence upon payment of the first annual developer license fee for the period of one (1) year, unless terminated sooner pursuant to the provisions of this Agreement.

4.3. Renewal Terms. After the initial or renewal terms, THE LICENSEE must renew his license if he is still using THE SOFTWARE in his developments (Licensee's Software) or continue to deploy Licensee's Software that uses THE SOFTWARE. THE LICENSEE shall pay his license renewal thru one of the authorized distributor of the SOFTWARE.
If THE LICENSEE does not renew his license, THE LICENSEE must not use THE SOFTWARE anymore in his developments or continue to deploy Licensee's Software that uses THE SOFTWARE.
The license fee for each such renewal term shall be raised no more than twenty-five (25%) percent from the previous year's licensing fee.

5.Termination.
This license is effective until terminated. This license will terminate immediately without notice from THE AUTHOR if you fail to comply with any of its provisions. Upon termination you must destroy the SOFTWARE and all copies thereof, and you may terminate this license at any time by doing so.

6.Update Policy.
THE AUTHOR may create, from time to time, produce updated versions of the SOFTWARE. At its option, THE AUTHOR will make such updates available to the Licensee. Updated versions will constitute one an only product with the SOFTWARE subject of this agreement. All updates (minor or major) will be free of charge during Initial Term and Renewel Terms.

7.Warranty Disclaimer.
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED , INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHOR DOES NOT WARRANT, GUARANTEE, OR MAKE ANY REPRESENTATIONS REGARDING THE USE, OR THE RESULTS OF THE USE, OF THE SOFTWARE OR WRITTEN MATERIALS IN THE TERMS OF CORRECTNESS, ACCURACY, RELIABILITY, CURRENTNESS OR OTHERWISE. THE ENTIRE RISK AS TO THE RESULTS AND PERFORMANCE OF THE SOFTWARE IS ASSUMED BY YOU. IF THE SOFTWARE OR WRITTEN MATERIALS ARE DEFECTIVE YOU, AND NOT THE AUTHOR OR IT'S DEALERS,
DISTRIBUTORS, AGENTS, OR EMPLOYEES, ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. However, if the software has been sold to you on disk(s), THE AUTHOR warrants to the original Licensee that the disk(s) on which the Software is recorded is free from defects in materials and workmanship under normal use and service for a period of thirty (30) days from the date of delivery as evidenced by a copy of the receipt.
THIS IS THE ONLY WARRANT OF ANY KIND, EITHER EXPRESS OR IMPLIED, THAT IS MADE BY THE AUTHOR ON THIS SOFTWARE PRODUCT. NO ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY THE AUTHOR, IT'S DEALERS, DISTRIBUTORS, AGENTS, OR EMPLOYEES SHALL CREATE A WARRANTY OR IN ANY WAY INCREASE THE SCOPE OF THIS WARRANTY, AND YOU MAY NOT RELY ON SUCH INFORMATION OR ADVICE. THIS WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS. YOU MAY HAVE OTHER RIGHTS, WHICH VARY FROM STATE TO STATE.

8.Miscellaneous Provisions.
LICENSEE shall not directly or indirectly transfer the SOFTWARE to any country to which such transfer would be prohibited by any applicable export control laws.
No change or modification to this Agreement will be valid unless it is in writing and is signed by a duly authorized representative of each party.
If any provision of this Agreement is held to be unenforceable, the remainder of this Agreement shall continue in full force and effect.
The waiver by THE AUTHOR of one breach or default hereunder shall not constitute the waiver of any subsequent breach or default.
This is the entire agreement between THE AUTHOR and LICENSEE relating to the contents of the SOFTWARE and supersedes any other communications with respect to the SOFTWARE.
The relationship between THE AUTHOR and the LICENSEE is that of LICENSOR/LICENSEE. In all matters regarding to the present Agreement, the LICENSEE shall act as an independent contractor.

9.Licensee's status.
The terms and conditions of the present license regarding THE AUTHOR's liability cannot exclude any other legal warranty arising from a legislation of the user's country and takes precedence over the contravening provision.
Equally, some countries forbid the limitation and exclusion of liabilities mentioned above for the consecutive or incidental damages, consequently the present limitation of liability might not be applicable in this case.

10.Non-Disclosure.
The LICENSEE undertakes to respect the confidentiality of information and document which are prensented as such by THE AUTHOR, particularly the present Agreement and the results of any benchmark tests, without prior written consent of THE AUTHOR.

11.Governing Law.
This agreement shall be governed by the french laws.

YOU ACKNOWLEDGE TO HAVE READ, UNDERSTOOD AND AGREED TO BE BOUND BY THE TERMS AND CONDITIONS OF THE CONTRACT INDICATED ABOVE.
Should you have any questions, please contact THE AUTHOR or the nearest distributor.

* Notice to United States Government end users:
Use, duplication or disclosure by the US Government is subject to restrictions stated in paragraph (c) (1) (ii) of the Rights in Technical Data and Computer Software clause at 252.227-7013.

Serial ToolKit for 4D and the Serial ToolKit Logo are trademarks of Christian Quest

Serial ToolKit ©1999-2001 Christian Quest - All rights reserved


What is Serial ToolKit™ ?

Serial ToolKit™ (STK) it is a 4D plug-in which gives a better serial port support inside 4th Dimension programming language.

STK contains a dozen of commands allowing to get information regarding available serial ports, open, close, configure a port, send and receive data, etc.

This page gives informations about the features, system requirement, tech support, download sites, licensing, pricing and ordering of Serial ToolKit.

The current version of Serial ToolKit is available for the MacOS and Windows version of 4th Dimension.

 


Overview of features

With Serial ToolKit you can:

For more details, have a look at Serial ToolKit's Manual


 

System requirements

Operating System

The current version of Serial ToolKit only works on Macintosh computer running System 7.5 and above or Windows 95/98/NT/2000. 

 


Getting help : Technical Support & Mailing-List

All technical support regarding Serial ToolKit is done by email: serial-toolkit-support@cquest.org

A dedicated mailing list is also available.

To subscribe to the Serial ToolKit Mailing List, please send a message to STK-subscribe@cquest.org

To unsubscribe to the Serial ToolKit Mailing List, please send a message to STK-unsubscribe@cquest.org

To post a message on the list, please send your message to STK-List@cquest.org


Installing Serial ToolKit

Just copy the "SerialToolKit.4DX" icon into the MAC4DX and/or WIN4DX folder of the 4th Dimension Database in which you want to use Serial ToolKit.

There's nothing more to do !

Demo version

The Demo version of Serial ToolKit will run for a 30 minute period. After that evaluation or demonstration period, Serial ToolKit will not run anymore. you'll have to quit your 4D database then relaunch it to be able to use it for an additionnal evaluation/demonstration period.

 


Using Serial ToolKit

The following section of this document will review each Serial ToolKit command, the parameters you can pass to it, the optional flags values and the error it may return.

Error codes

A liste of error codes returned by MacOS when using the serial ports can be found here:

http://developer.apple.com/techpubs/mac/Devices/Devices-326.html#HEADING326-48

and

http://developer.apple.com/techpubs/mac/Devices/Devices-52.html#HEADING52-107

All positive errors returned by Serial ToolKit indicate that no error occured. Negative values indicate that some error occured.

 

Initialization

STK_Init

Syntax: err := STK_Init(serialTxt;serialNum)

Initializes STK with its license number.

<- err (longint)

-> serialTxt (Alpha) : Alphanumeric part of STK's license number

-> serialNum (Longint) : Numeric part of STK's license number


Getting informations about available serial ports

The available serial ports on a Mac or a PC can change dynamically (like with hot-pluggable USB/Serial adapters or PCMCIA card). It is recommended to save only the name of the serial port selected by the user. You shoult not depend on the order in which the serial ports are appearing as this order can change at any time (including without rebooting the Mac or PC).

That's why STK_CountPorts and STK_GetIndPort should be use extensively to get the current list of serial ports with their name. Selecting a serial port should only be done thru its name.

Under MacOS, STK_CountPorts and STK_GetIndPort can also be used in conjonction with 4D's built-in SET CHANNEL routine. For example, the 2nd port returned by STK_GetIndPort can be used with SET CHANNEL(102) or SET CHANNEL(202), etc...

 

STK_CountPorts

Syntax: err := STK_CountPorts(nbPorts)

Returns the number of available serial ports

<- err (longint)

<- nbports (longint)


STK_GetIndPort

Syntax: err = STK_GetIndPort(portIndex; portName; inputDriverName; outputDriverName)

Returns portname, inputdrivername and outputdriver of the nth available serial port (from 1 to STK_CountPorts).

<- err (longint)

-> portindex (longint)

<- portname (string)

<- inputDriverName (string)

<- outputDriverName (string)


Opening and closing serial ports

Note: The serial ports open by STK cannot be used with 4D's builtin commands (like RECEIVE PACKET).

 

STK_Open

Syntax: err = STK_Open(portindex; refNum)

Opens the specified serial port (portIndex takes values from 1 to STK_CountPorts)

refNum is the reference number of the opened serial driver which will be needed in subsequent calls.

<- err (longint), returns -1 if the port is already open by STK.

-> portindex (longint)

<- refnum (longint)


STK_Close

Syntax: err = STK_Close(refNum)

Closes the specified driver (previously opened with STK_Open).

<- err (longint)

-> refnum (longint) (as previously returned by STK_Open)


Configuring serial ports

STK_Reset

Syntax: err := STK_Reset(refNum; config)

Configure the given serial driver baudrate, number of bits, stops, parity. Config is calculated the same way as usual.

<- err (longint)

-> refnum (longint) (as previously returned by STK_Open)

-> config (longint)

Config is calculated by adding the following constants:

Baud rate:

Stop bits:

Parity:

Number of data bits:

Example:

$err := STK_Reset(refnum; baud9600 + stop10 + noParity + data8 ) ` for 4Dv6.0 and above

$err := STK_Reset(refnum; 10 + 16384 + 0 + 3072 ) ` for 4D version prior to 6.0


STK_HShake

Syntax: err := STK_HShake(refNum; handShakeType; xOnChar; xOffChar)

Modifies the serial driver handshaking mode for the given serial port.

<- err (longint)

-> refnum (longint) (as previously returned by STK_Open )

-> handShakeType (longint) (0 = no handskahe, 1 = Xon/Xoff, 2 = CTS, 3 = DTR, 4 = CTS/DTR)

-> xOnChar (integer) - ASCII code of the XON char

-> xOffChar (integer) - ASCII code of the XOFF char

See : http://developer.apple.com/techpubs/mac/Devices/Devices-320.html for more details about STK_HShake


STK_SetBuf

Syntax: err = STK_SetBuf(refNum; inputBufferSize; outputBufferSize)

Allocates a new buffer of buffsize bytes for the opened serial port.

Under windows, it is possible to allocate a different input and output buffer size, under MacOS, the same size (the larger one) will be used for both.

<- err (longint)

-> refnum (longint) (as previously returned by STK_Open )

-> inputBufferSize (longint)

-> outputBufferSize (longint)


Getting informations about an opened serial port

STK_Status

Syntax: err := STK_Status(refNum, cummErrs, xOffSent, rdPend, wrPend, ctsHold, xOffHold, dsrHold, modemStatus)

Returns status information regarding the given serial driver.

<- err (longint)

-> refnum (longint) (as previously returned by STK_Open )

<- cummErrs (longint)

<- xOffSent (longint)

<- rdPend (longint)

<- wrPend (longint)

<- ctsHold (longint)

<- xOffHold (longint)

<- dsrHold (longint)

<- modemStatus (longint)

See : http://developer.apple.com/techpubs/mac/Devices/Devices-324.html for more details about STK_Status


STK_GetBuf

Syntax: err := STK_GetBuf(refNum; bytesAvailable)

Returns the number of bytes available in the input buffer.

<- err (longint)

-> refnum (longint) (as previously returned by STK_Open )

<- bytesAvailable (longint)


Sending and receiving data

STK_Send

Syntax: err := STK_Send(refNum; dataToSend)

Send some data on an output serial driver

<- err (longint)

-> refnum (longint) (as previously returned by STK_Open )

-> dataToSend (text)


STK_Receive

Syntax: err := STK_Receive(refNum; dataStorage; maxLen)

Receives some data on the given input serial driver. dataStorage (C_TEXT) will hold the received data, maxLen (C_LONGINT) will indicate the maximum number of bytes to be read. If maxLen is 0, STK_Receive will receive the available number of bytes as returned by STK_GetBuf. If maxLen is greater than the available amount of data, STK_Receive will return the available amount of data.

<- err (longint)

-> refnum (longint) (as previously returned by STK_Open )

<- datastorage (text)

-> maxlen (longint)

 


Version history

v1.0
First final version of Serial ToolKit
 
v1.0.1 (Dec-2000)
Bug fix in the Windows version which was not detecting correctly if STK was used in a compiled database. This was causing STK to verify the license subscription end in Windows compiled apps when it shouldn't.
 
v1.0.2 (Feb-2001)
Bug fix in STK_CountPorts and STK_GetIndPort in the MacOS version which were not counting and reporting the list of available serial ports correctly in some cases (for example when serial ports were removed without rebooting the Mac).
Bug fix in the Windows version on handling output flow control in some cases.
 
v1.0.3 (Apr-2001)
Bug fix in STK_GetBuf in the MacOS version which was not returning a valid value (usually 0).


Serial ToolKit ©1999-2001 Christian Quest - All rights reserved

Written by Christian Quest - 15-Feb-2001