MOXA Sync Board API Programmer s Manual

Similar documents
C101 ISA/PCI SuperSync Board

PCIe-400 USER S MANUAL

MEC-COM-M114. User s Manual

User Manual VScom PCI Cards VScom Industrial Card

CHAPTER 5 REGISTER DESCRIPTIONS

MEC-COM-M154. User s Manual

UPort 2000 Series User s Manual

User Manual USB-COM ECO

SpiNNaker Application Programming Interface (API)

MOXA VPort 2110/2140/2141 Video Server Quick Installation Guide

MGate TM EIP3000 DF1 to EtherNet/IP Gateway User s Manual

NPort Server Lite User s Manual

C218 Turbo User s Manual

Korenix JetCard Series Multiport Serial Card/Ethernet Switch Card User s Manual

CHAPTER 4 DATA COMMUNICATION MODES

SMG-1100/6100 User s Manual

LAP-B(PCI/C-PCI) GPF LAP-B Communications Driver Software for for Windows. Help for Windows.

USB-2COM-BB USER S MANUAL

VL-7312 VL-7314 VL-73CT12 VL-73CT14. Dual/Quad RS-232 Serial Card for the STD Bus

IO-Warrior Dynamic Library V1.5 for Windows

$U6RIW,QWHUQDWLRQDO. Modbus Driver for Windows 95/98/NT/2000/XP 8VHUV0DQXDO 0RGEXV,QWHUIDFH. 9HUVLRQ Page 1

Learn how to communicate

PCI Express 16-Port Serial I/O Cards

SIO-DLL. Serial I/O DLL. User Manual

SpinWarrior Dynamic Library V1.5 for Windows and Linux

Serial Interfacing. Pulse width of 1 bit

CLD SC58x CDC Library v.1.00 Users Guide Users Guide Revision For Use With Analog Devices ADSP-SC58x Series Processors. Closed Loop Design, LLC

MOXA C101 Synchronous Interface

Matrix-710. Linux-Ready Cortex-A5 Industry IoT Gateway. Hardware Guide. Version: Nov.

CLD BF70x CDC Library v.1.3 Users Guide Users Guide Revision 1.3. For Use With Analog Devices ADSP-BF70x Series Processors. Closed Loop Design, LLC

Serial Communication. Simplex Half-Duplex Duplex

EX & EX-45362IS 2S RS232/422/485 3-in-1 Serial PCIe Card

NetBiter Serial Server User Manual

ESC(LP)-100. Eight Channel Low Profile RS-232 Asynchronous Communications Adapter. for PCI bus. User's Manual

QSC(LP)-100. User's Manual

ELAN DIGITAL SYSTEMS LTD. SL332 PC- CARD USER S GUIDE

NCOM SERIAL DEVICE SERVER 1XX SERIES USER S MANUAL

MOXA C101 Synchronous Interface

SyncLink GT4 PC/104+ Serial Adapter

BLE232: Manual Copyright 2014 taskit GmbH

USB SERIAL OVER IP ADAPTER AnyplaceUSB-xCOM USER S MANUAL

Matrix-700 Linux-Ready Cortex-A5 Industry IoT Gateway Hardware Guide

CoreSDLC Driver User s Guide. Version 2.0

ThingsPro Software User s Manual

NCOM SERIAL DEVICE SERVER 4XX SERIES USER S MANUAL

TRC-190 User s Manual

Smartio C104H/HS User s Manual

Hierarchy of I/O Control Devices

Moxa Proactive Monitoring User s Manual

Application Note. IP Nano (IPn920F & IPn920T) & Centracs Compatibility. February Country Hills Landing NW Calgary, Alberta Canada T3K 5P3

NE-4100 Series Serial Command Mode User s Guide

MOXA TCC-120/120I User s Guide

ControlLogix Multi-Vendor Interface Module DH-485 API

UPort 1100 Series User s Manual

Configuration of Synchronous Protocols

MGate MB3000 Modbus Gateway User Manual

NE-4100-P Series User s Manual

DYNAMIC ENGINEERING 435 Park Dr., Ben Lomond, Calif Fax Est

EasySync Ltd. USB2-F-7x01 Programming Guide

Software Manual. Digi International Inc Bren Road Minnetonka, MN (800) (612)

MEC-COM-M134. User s Manual

IC232 PC- CARD USER S GUIDE

PCIe Card Selection Guide. PCIe-CAN Card. PCIe-COM Card. Taiwan Pulse Motion Co.,Ltd. Bus Interface PCI Express x 1 LPE-C122 PCE-C122D PCE-C122T

NPort Z2150 User s Manual

RX Family APPLICATION NOTE. Simple I 2 C Module Using Firmware Integration Technology. Introduction. Target Device.

Serial Interfacing. Asynchronous Frame

Korenix JetCard Series Multiport Serial Card/Ethernet Switch Card User s Manual

MOXA SoftDVR Lite IP Surveillance Software. User s Guide

USB TO RS-232/RS-422/RS-485 ADAPTER

USART. USART stands for Universal Synchronous Asynchronous Receiver Transmitter. Full-duplex NRZ asynchronous serial data transmission

ELAN DIGITAL SYSTEMS LTD. CF428 COMPACT FLASH CF+ CARD USER S GUIDE

SyncLink USB Serial Adapter

MGate MB3000 Modbus Gateway User s Manual

VSCAN J1939 Manual. Edition: January Tel: Fax: Web: Support: faq.visionsystems.

NS9750B-0. Use in conjunction with: Errata , Rev G. Release date: May Phone: Web:

SyncLink GT2E/GT4E Serial Adapter

UPort 1200/1400/1600 Series User s Manual

Enhanced Serial Communications Controller

MOXA SoftDVR Pro IP Surveillance Software. Getting Started Guide. First Edition, June 2004

C104P User s Manual Universal 4-port Serial Board

One of the unique features of the T4Ee is the huge variety of clock source options, clocks can be:

TCP Channel Serial Interface RS232 / RS422 cpci Module. User Manual. The Embedded I/O Company. Version 1.0. Issue 1.

Data sheet Wireless UART firmware version 4

DYNAMIC ENGINEERING. 150 DuBois, Suite C Santa Cruz, CA (831) Fax (831) Est.

Moxa TCC-100 Series User s Guide

DYNAMIC ENGINEERING 435 Park Dr., Ben Lomond, Calif Fax Est

DSC-100. User's Manual

Serial Interfaces Part 1. ECE 153B Sensor & Peripheral Interface Design Winter 2016

USB BF70x Audio 1.0 Library v.1.2 Users Guide Users Guide Revision 1.3. For Use With Analog Devices ADSP-BF70x Series Processors

MiniOS7 API Functions Reference Manual. (For C Language) Version 1.17, Jan 2015

ELAN DIGITAL SYSTEMS LTD. CF232 COMPACT FLASH CF+ CARD USER S GUIDE

Software Documentation

Motortronics VirtualSCADA VS2-MT Communication Gateway VS2-MT User Manual Revision

RS 232 Interface. RS 232 is the Serial interface on the PC. Three major wires for the Serial interface: Transmit Pin 2 Receive Pin 3

KC Web API Programmer Reference

Multi-4/LPCI. Overview. BUS Interface. Serial. Connector Panel: Hardware. Slew-Rate Limit Control. Software

MiniOS7 API Functions Reference Manual. (For C Language) Version 1.12, Jan 2009

For technical support and service, please visit our support website at:

NuCOM. PCI-7841/cPCI-7841/PM-7841 Dual-Port Isolated CAN Interface Card User s Guide

DCB1M - Transceiver for Powerline Communication

Transcription:

MOXA Sync Board API Programmer s Manual First Edition, Jan 2002 Moxa Technologies Co., Ltd. Tel: +866-2-8919-1230 Fax: +886-2-8919-1231 www.moxa.com service@moxa.com.tw

MOXA Sync Board API Programmer s Manual The software described in this manual is furnished under a license agreement and may be used only in accordance with the terms of that agreement. Copyright Notice Copyright 2001 Moxa Technologies Co., Ltd. All rights reserved. Reproduction without permission is prohibited. Trademarks MOXA is a registered trademark of Moxa Technologies Co., Ltd. All other trademarks or registered marks in this manual belong to their respective manufacturers. Disclaimer Information in this document is subject to change without notice and does not represent a commitment on the part of Moxa. Moxa provides this document as is, without warranty of any kind, either expressed or implied, including, but not limited to, its particular purpose. Moxa reserves the right to make improvements and/or changes to this manual, or to the products and/or the programs described in this manual, at any time. Information provided in this manual is intended to be accurate and reliable. However, Moxa Technologies assumes no responsibility for its use, or for any infringements on the rights of fourth parties that may result from its use. This product might include unintentional technical or typographical errors. Changes are periodically made to the information herein to correct such errors, and these changes are incorporated into new editions of the publication.

MOXA Internet Services Customer satisfaction is our number one concern. To ensure that customers receive the full benefit of our products, Moxa Internet Services has been set up to provide technical support, driver updates, product information, and user s manual updates. The following services are provided E-mail for technical support: service@moxa.com.tw FTP site for free driver updates:.. ftp://ftp.moxa.com or.. ftp://ftp.moxa.com.tw user ID: ftp password:. your_email_address World Wide Web (WWW) Site for product information:.. http://www.moxa.com or.. http://www.moxa.com.tw

Chapter 1 Chapter 2 Table of Contents API Programming Library Notes...1-1 Function List by Category...2-1 Port Control...2-2 Byte Sync Control...2-3 Data Input...2-3 Data Output...2-4 Status Inquiry...2-4 Event Service...2-5 Miscellaneous...2-5 Chapter 3 Detailed Function Reference...3-1 Function 1 syio_open...3-2 Function 2 syio_close...3-3 Function 3 syio_flush...3-4 Function 4 syio_dtr...3-5 Function 5 syio_rts...3-6 Function 6 syio_setdataencoding...3-7 Function 7 syio_ GetDataEncoding...3-8 Function 8 syio_setbaud...3-9 Function 9 syio_getbaud...3-10 Function 10 syio_setcrcmode... 3-11 Function 11 syio_getcrcmode...3-12 Function 12 syio_settxclockdir...3-13 Function 13 syio_gettxclockdir...3-14 Function 14 syio_txdisable...3-15 Function 15 syio_txenable...3-16 Function 16 syio_txstatus...3-17 Function 17 syio_setsyncchar...3-18 Function 18 syio_setsynclength...3-19 Function 19 syio_setidlecode...3-20 Function 20 syio_getopmode...3-21

Function 21 syio_getidlecode...3-22 Function 22 syio_getsyncchar...3-23 Function 23 syio_getsynclength...3-24 Function 24 syio_read...3-25 Function 25 syio_setreadtimeouts...3-26 Function 26 syio_getreadtimeouts...3-27 Function 27 syio_abortread...3-28 Function 28 syio_inframe...3-29 Function 29 syio_inqueue...3-30 Function 30 syio_infreeframe...3-31 Function 31 syio_infree...3-32 Function 32 syio_skipframe...3-33 Function 33 syio_getfirstframelen...3-34 Function 34 syio_write...3-35 Function 35 syio_setwritetimeouts...3-36 Function 36 syio_getwritetimeouts...3-37 Function 37 syio_abortwrite...3-38 Function 38 syio_outframe...3-39 Function 39 syio_outqueue...3-40 Function 40 syio_outfreeframe...3-41 Function 41 syio_outfree...3-42 Function 42 syio_linestatus...3-43 Function 43 syio_getboardid...3-44 Function 44 syio_frameirq...3-45 Function 45 syio_modemirq...3-47 Function 46 syio_txemptyirq...3-49 Function 47 syio_view...3-50

1 1 API Programming Library Notes MOXA Sync API supports,, and. If you use, include the file syncapi.bas in your project. If you use, include the file syncapi.pas. All of these languages require the file syncapi.dll, which is automatically copied to your PC when you install the C502/C101 drivers. The syncapi.lib library file is used with Microsoft. If you are using the Borland compiler, you will need to first use the utility implib.exe to create the Borland-compliant library file syncapib.lib. To do this, execute the command: implib -c syncapib.lib syncapi.dll MOXA Sync API supports block/non-block mode for reading/writing functions with your application. Note: DOS WatcomC Driver supports PCI bus, while DOS TSR driver only supports ISA bus. API Programmer s Manual 1-1

The following table gives the list of return codes you may encounter when calling the API library functions: Return Code Output Description SYIO_OK 0 function OK SYIO_BADPORT -1 no such port, or port not opened SYIO_OPENED -2 port opened SYIO_BADPARM -3 parameter error SYIO_WIN32FAIL SYIO_ABORT -5 abort writing SYIO_TIMEOUT -6 read or write timeout SYIO_BUFFERTOOSHORT -4-8 win32 function call failure; call the function GetLastError() to obtain the return code (this usually happens because of a driver installation failure; please check the physical installer resource allocation) buffer is too short (happens when the data frame is bigger then the length parameter used with the function syio_read ) API Programmer s Manual 1-1

2 2 Function List by Category In this chapter the functions are organized into seven different categories: Port Control Byte Sync Control Data Input Data Output Status Inquiry Event Service Miscellaneous API Programmer s Manual 2-1

Port Control Port Control functions are used to control the basic operation and configuration of the sync board s port(s), such as opening and closing a port. syio_open syio_close syio_dtr syio_rts syio_setdataencoding syio_getdataencoding syio_setbaud syio_getbaud syio_setcrcmode syio_getcrcmode syio_settxclockdir syio_gettxclockdir syio_txdisable syio_txenable siyo_txstsyio_flush atus open a port close an opened port toggle DTR pin on and off toggle RTS pin on and off set up data encoding get data encoding mode setting set baud rate get baud rate setting set CRC mode get CRC mode setting set Tx Clock direction get Tx Clock direction setting disable Tx transmission enable Tx transmission flush one or more buffers get Tx status 2-2 API Programmer s Manual

Function List by Category Byte Sync Control Byte Sync Control functions are used to provide low-level control of data transmitted and received by the sync board. syio_setsyncchar syio_setsynclength syio_setidlecode syio_getopmode syio_getidlecode syio_getsyncchar syio_getsynclength set byte sync character pattern set byte sync character pattern length set transmitter s idle state output pattern get the current synchronous mode get the idle pattern get byte sync character pattern get first byte sync character pattern length Data Input Data Input functions are used to control and manage settings related to receiving data. syio_read syio_setreadtimeouts syio_getreadtimeouts syio_abortread syio_inframe syio_inqueue syio_infreeframe syio_infree syio_skipframe siyo_getfirstframelen receive data from a remote device set syio_read timeout value get syio_read timeout setting value abort blocked syio_read function call get number of frames in the driver buffer get number of data bytes in the driver buffer get number of free frames in the driver buffer get number of free data bytes in the driver buffer skip first received frame in the driver buffer get length of first received frame API Programmer s Manual 2-3

Data Output Data Output functions are used to control and manage settings related to the transmission of data. syio_write syio_setwritetimeouts wyio_getwritetimeouts syio_abortwrite syio_outframe syio_outqueue syio_outfreeframe syio_outfree send data set write-timeout setting value get write-timeout setting value abort blocked syio_write function call get number of driver buffer frames to be sent get number of driver buffer data bytes to be sent get number of free driver buffer output frames get free driver buffer output data byte space Status Inquiry These two Status Inquiry functions can be used to obtain basic status information about your system s setup. syio_linestatus syio_getboardid get line status of DSR, DCD, and CTS identify underlying system 2-4 API Programmer s Manual

Function List by Category Event Service You may use these Event Service functions to manage three basic events associated with your sync board s operation. syio_frameirq syio_modemirq syio_txemptyirq set the event: number of received frames set the event: modem status change set the event: TxEmpty Miscellaneous syio_view preview data API Programmer s Manual 2-5

3 3 Detailed Function Reference This chapter includes a detailed list of the sync board API functions. Each entry explains how to call the function, discusses the function s argument list, and gives one or more programming examples.

Function 1 syio_open Port Control Open a port and set port configuration to the default values. Port default values are: Tx clock out, baud rate 38400, CRC CCITT_1, and data encoding NRZ. The driver default settings are set at driver load time. Note that once you close a port, the settings will remain the same until you power off. It is good programming practice to do an initial port setting before using the port, instead of relying on the default settings. int WINAPI syio_open(int port); Input : int port (port numbers 0 11) Output : refer to return code list (return code of 4 usually means the driver was not installed successfully; check event log (NT, 2000) for more information about hardware installation Declare Function syio_open Lib syncapi.dll (ByVal port As Long) As Long function syio_open(port: Longint): Longint; stdcall; function syio_open; external syncapi.dll ; int port = 2; ret = syio_open (port); if ( ret!= SYIO_OK ) { /* Open fail */ 3-2 API Programmer s Manual

Detailed Function Reference Function 2 syio_close Port Control Close an opened port. If there is no need to use a particular port, you can call this function to close the port, but it will not be closed until remaining data is sent. If there is no data to send within 3 seconds of calling the function, the input and output data on the driver s buffer will be flushed, and then the port will be closed. int WINAPI syio_close(int port); Input : int port (port numbers 0 11) Output : refer to return code list Declare Function syio_close Lib syncapi.dll (ByVal port As Long) As Long function syio_close(port: Longint): Longint; stdcall; function syio_close; external syncapi.dll ; int port = 2;.. Syio_Close( port ); API Programmer s Manual 3-3

Function 3 syio_flush Port Control Flush received or to-be-sent data in the driver s buffer. int WINAPI syio_flush(int port, int mode); Input: int port :port numbers 0 11 int mode :FLUSH_INPUT, FLUSH_OUTPUT or FLUSH_ALL Output : refer to return code list Declare Function syio_flush Lib syncapi.dll (ByVal port As Long, ByVal mode As Long) As Long function syio_flush(port, mode: Longint): Longint; stdcall; function syio_flush; external syncapi.dll ;.. syio_flush( port, FLUSH_INPUT ); /* flush onboard input buffer */.. syio_flush( port, FLUSH_OUTPUT ); /* flush onboard output buffer */.. syio_flush( port, FLUSH_ALL ); /* flush all buffers */ 3-4 API Programmer s Manual

Detailed Function Reference Function 4 syio_dtr Port Control Set DTR pin on or off. int WINAPI syio_dtr(int port, int mode); Input: int port :port numbers 0 11 int mode CONTROL_ON or CONTROL_OFF Output: refer to return code list Declare Function syio_dtr Lib syncapi.dll (ByVal port As Long, ByVal mode As Long) As Long function syio_dtr(port, mode: Longint): Longint; stdcall; function syio_dtr; external syncapi.dll ; ret = syio_dtr( port, CONTROL_ON ); /* Set DTR active */ If ( ret < 0 ) { /* fail */ API Programmer s Manual 3-5

Function 5 syio_rts Port Control Set RTS pin on or off. int WINAPI syio_rts(int port, int mode); Input: int port :port numbers 0 11 int mode CONTROL_ON or CONTROL_OFF Output: refer to return code list Declare Function syio_rts Lib syncapi.dll (ByVal port As Long, ByVal mode As Long) As Long function syio_rts(port, mode: Longint): Longint; stdcall; function syio_rts; external syncapi.dll ; ret = syio_rts( port, CONTROL_ON );/* Set RTS active */ If ( ret < 0 ) { /* fail */ 3-6 API Programmer s Manual

Detailed Function Reference Function 6 syio_setdataencoding Port Control Set up data encoding. The default is NRZ. Note that it is good programming practice to initialize the coding type yourself. int WINAPI syio_setdataencoding(int port, int mode); Input: int port :port numbers 0 11 int mode : NRZ, NRZI, FM0 or FM1 Output: refer to return code list Declare Function syio_setdataencoding Lib syncapi.dll (ByVal port As Long, ByVal mode As Long) As Long function syio_setdataencoding(port, mode: Longint): Longint; stdcall; function syio_setdataencoding; external syncapi.dll ; ret = syio_setdataencoding( port, NRZ ); If ( ret < 0 ) { /* fail */ API Programmer s Manual 3-7

Function 7 syio_ GetDataEncoding Port Control Get data encoding mode setting. int WINAPI syio_getdataencoding(int port); Input: int port : port numbers 0 11 Output >= 0 : data encoding mode NRZ, NRZI, FM0 or FM1 < 0 : refer to return code list Declare Function syio_getdataencoding Lib syncapi.dll (ByVal port As Long) As Long function syio_getdataencoding(port: Longint): Longint; stdcall; function syio_getdataencoding; external syncapi.dll ; codingtype = syio_getdataencoding ( port ); If ( codingtype < 0 ) { /* fail */ 3-8 API Programmer s Manual

Detailed Function Reference Function 8 syio_setbaud Port Control Set baud rate. Baud rate setting is invalid if Tx Clock is set to in. To activate the baud rate setting, you should set the Tx clock setting to out. int WINAPI syio_setbaud(int port, int speed); Input: int port :port numbers 0 11 int speed RS-232 supported up tp 128 Kbps ISA board support up to 4 Mbps Byte sync support up 64 Kbps C502/PCI V35 HDLC mode support up to 8 Mbps Output: refer to return code list Declare Function syio_setbaud Lib syncapi.dll (ByVal port As Long, ByVal speed As Long) As Long function syio_setbaud(port, speed: Longint): Longint; stdcall; function syio_setbaud; external syncapi.dll ; Ret = syio_setbaud( port, 64000 ) If ( ret!= SYIO_OK ) { /* fail */ API Programmer s Manual 3-9

Function 9 syio_getbaud Port Control Get baud rate setting. int WINAPI syio_getbaud(int port); Input: int port : port numbers 0 11 Output >= 0 : The baud rate of the port < 0 : refer to return code list Declare Function syio_getbaud Lib syncapi.dll (ByVal port As Long) As Long function syio_getbaud(port: Longint): Longint; stdcall; function syio_getbaud; external syncapi.dll ; baud = syio_getbaud( port ); If ( baud < 0 ) { /* fail */ 3-10 API Programmer s Manual

Detailed Function Reference Function 10 syio_setcrcmode Port Control Set CRC mode. CCITT can be initialized with all 0 s, all 1 s, or with no CRC. HDLC protocol can only use CCITT CRC. int WINAPI syio_setcrcmode(int port, int mode); Input: int port :port numbers 0 11 int mode :NONE,CCITT_0,CCITT_1,CRC16_0 or CRC16_1 Output: refer to return code list Declare Function syio_setcrcmode Lib syncapi.dll (ByVal port As Long, ByVal mode As Long) As Long function syio_setcrcmode(port, mode: Longint): Longint; stdcall; function syio_setcrcmode; external syncapi.dll ; ret = syio_setcrcmode( port, CCITT_1 ); If ( ret < 0 ) { /* fail */ API Programmer s Manual 3-11

Function 11 syio_getcrcmode Port Control Get CRC mode setting value. int WINAPI syio_getcrcmode(int port); Input: int port : port numbers 0 11 Output >= 0 Could be NONE, CCITT_0, CCITT_1, CRC16_0 or CRC16_1 < 0 : refer to return code list Declare Function syio_getcrcmode Lib syncapi.dll (ByVal port As Long) As Long function syio_getcrcmode(port: Longint): Longint; stdcall; function syio_getcrcmode; external syncapi.dll ; crcmode = syio_getcrcmode( port ); If ( ret < 0 ) { /* fail */ 3-12 API Programmer s Manual

Detailed Function Reference Function 12 syio_settxclockdir Port Control Set Tx clock direction to in or out. Note that Tx clock in uses different pins on the connector from Tx clock out. int WINAPI syio_settxclockdir(int port, int direction); Input: int port :port numbers 0 11 int direction :TX_CLOCK_IN or TX_LOCK_OUT For C101/ISA clock is setting in JP2, and config program. Output: refer to return code list Declare Function syio_settxclockdir Lib syncapi.dll (ByVal port As Long, ByVal direction As Long) As Long function syio_settxclockdir(port, direction: Longint): Longint; stdcall; function syio_settxclockdir; external syncapi.dll ; ret = syio_settxclockdir( port, TX_CLOCK_IN ); If ( ret < 0 ) { /* fail */ API Programmer s Manual 3-13

Function 13 syio_gettxclockdir Port Control Get Tx clock direction setting. int WINAPI syio_gettxclockdir(int port); Input: int port : port numbers 0 11 Output >= 0 TX_CLOCK_IN or TX_CLOCK_OUT < 0 : refer to return code list Declare Function syio_gettxclockdir Lib syncapi.dll (ByVa l port As Long) As Long function syio_gettxclockdir(port: Longint): Longint; stdcall; function syio_gettxclockdir; external syncapi.dll ; clockdir = syio_gettxclockdir( port ); If ( clockdir == TX_CLOCK_IN ) { /* the clock is in */ else if ( clockdir == TX_CLOCK_OUT ) { /* the clock is out */ else { /* fail */ 3-14 API Programmer s Manual

Detailed Function Reference Function 14 syio_txdisable Port Control Disable Tx transmission. (After user disables Tx, syio_write can still be called, but the data will queue in the output buffer ) int WINAPI syio_txdisable(int port); Input: int port :port numbers 0 11 Output: Refer to return code list Declare Function syio_txdisable Lib syncapi.dll (ByVal port As Long) As Long function syio_txdisable(port: Longint): Longint; stdcall; function syio_txdisable; external syncapi.dll ; ret = syio_txdisable( port ); If ( ret < 0 ) { /* fail */ API Programmer s Manual 3-15

Function 15 syio_txenable Port Control Enable transmission halted by syio_txdisable. int WINAPI syio_txenable(int port); Input: int port :port numbers 0 11 Output: refer to return code list Declare Function syio_txenable Lib syncapi.dll (ByVal port As Long) As Long function syio_txenable(port: Longint): Longint; stdcall; function syio_txenable; external syncapi.dll ; ret = syio_txenable( port ); If ( ret < 0 ) { /* fail */ 3-16 API Programmer s Manual

Detailed Function Reference Function 16 syio_txstatus Port Control Get Tx status, disable or enable. int WINAPI syio_txstatus(int port); Input: int port : port numbers 0 11 Output >= 0 : Tx status, 0 for disable, 1 for enable < 0 : refer to return code list Declare Function syio_txstatus Lib syncapi.dll (ByVal port As Long) As Long function syio_txstatus(port: Longint): Longint; stdcall; function syio_txstatus; external syncapi.dll ; stat = syio_txstatus( port ); If ( stat < 0 ) { /* fail */ API Programmer s Manual 3-17

Function 17 syio_setsyncchar Byte Sync Control Set synchronous character pattern for transmission and reception in byte synchronous mode. This function works only in byte sync mode (default is 0x1616). int WINAPI syio_setsyncchar(int port, USHORT syncchar); Input: Int port : port numbers 0 11 USHORT : sync char Output = 0 : ok < 0 : refer to return code list Declare Function syio_setsyncchar Lib "syncapi.dll" (ByVal port As Long, ByVal syncchar As Integer) As Long function syio_setsyncchar(port: Longint; syncchar:word): Longint; stdcall; function syio_setsyncchar; external 'syncapi.dll'; ret = syio_setsyncchar( port, 0x1616 ); If ( ret < 0 ) { /* fail */ 3-18 API Programmer s Manual

Detailed Function Reference Function 18 syio_setsynclength Byte Sync Control Set synchronous character pattern number for transmission and reception in byte synchronous mode. This function works only in sync mode (default is 1). int WINAPI syio_setsynclength(int port, int length); Input: Int port : port numbers 0 11 int : sync length Output = 0 : ok < 0 : refer to return code list Declare Function syio_setsynclength Lib "syncapi.dll" (ByVal port As Long, ByVal length As Long) As Long function syio_setsynclength(port, length: Longint): Longint; stdcall; function syio_setsynclength; external 'syncapi.dll'; ret = syio_setsynclength( port, 5 ); If ( ret < 0 ) { /* fail */ API Programmer s Manual 3-19

Function 19 syio_setidlecode Byte Sync Control Set idle pattern output by the transmitter when it is in idle state (default is 0xFF). int WINAPI syio_setidlecode(int port, UCHAR idlecode); Input: Int port : port numbers 0 11 UCHAR : idle code Output = 0 : ok < 0 : refer to return code list Declare Function syio_setidlecode Lib syncapi.dll (ByVal port As Long, ByVal idlecode as Byte) As Long function syio_setidlecode(port: Longint; idlecode:char): Longint; stdcall; function syio_getidlecode; external 'syncapi.dll'; ret = syio_setidlecode( port, 0xFF ); If ( ret < 0 ) { /* fail */ 3-20 API Programmer s Manual

Detailed Function Reference Function 20 syio_getopmode Byte Sync Control Get the synchronous mode. int WINAPI syio_getopmode(int port); Input: Int port : port numbers 0 11 Output >= 0 : HDLC_MODE byte sync mode BI_SYNC_8 byte sync with one byte sync char BI_SYNC_16 byte sync with two byte sync char < 0 : refer to return code list Declare Function syio_getopmode Lib "syncapi.dll" (ByVal port As Long) As Long function syio_getopmode(port: Longint): Longint; stdcall; function syio_getopmode; external 'syncapi.dll'; opmode = syio_getopmode( port ); If ( opmode < 0 ) { /* fail */ API Programmer s Manual 3-21

Function 21 syio_getidlecode Byte Sync Control Get the idle pattern when it is in idle state. int WINAPI syio_getidlecode(int port); Input: Int port : port numbers 0 11 Output >= 0 : ok < 0 : refer to return code list Declare Function syio_getidlecode Lib "syncapi.dll" (ByVal port As Long) As Long function syio_getidlecode(port: Longint): Longint; stdcall; function syio_getidlecode; external 'syncapi.dll'; idlecode = syio_getidlecode( port ); If ( idlecode < 0 ) { /* fail */ 3-22 API Programmer s Manual

Detailed Function Reference Function 22 syio_getsyncchar Byte Sync Control Get the synchronous character pattern in byte synchronous mode. int WINAPI syio_getsyncchar(int port); Input: Int port : port numbers 0 11 Output >= 0 : ok < 0 : refer to return code list Declare Function syio_getsyncchar Lib "syncapi.dll" (ByVal port As Long) As Long function syio_getsyncchar(port: Longint): Longint; stdcall; function syio_getsyncchar; external 'syncapi.dll'; syncchar = syio_getsyncchar( port ); If ( syncchar < 0 ) { /* fail */ API Programmer s Manual 3-23

Function 23 syio_getsynclength Byte Sync Control Get first synchronous character pattern number in byte synchronous model int WINAPI syio_getsynclength(int port); Input: Int port : port numbers 0 11 Output >= 0 : ok < 0 : refer to return code list Declare Function syio_getsynclength Lib "syncapi.dll" (ByVal port As Long) As Long function syio_getsynclength(port: Longint): Longint; stdcall; function syio_getsynclength; external 'syncapi.dll'; synclength = syio_getsynclength( port ); If ( synclength < 0 ) { /* fail */ 3-24 API Programmer s Manual

Detailed Function Reference Function 24 syio_read Data Input Receive data from a remote device. If you set the read-timeout to zero, the very first time it will return data from the buffer (even if no data is in the onboard buffer). If you set the read-timeout to a non-zero value, it will block the syio_read function call until data comes in, or a timeout occurs, or this read is aborted by another thread. Setting the read timeout to -1 will block data until something comes in, or an abort is issued by another thread (see syio_setreadtimeout for more information). int WINAPI syio_read(int port, char *buf, int len); Input: int port :port numbers 0 11 char *buf : to-receive data buffer pointer int len : to-receive data length Output >= 0 : receiving data length < 0 : refer to return code list Declare Function syio_read Lib syncapi.dll (ByVal port As Long, ByRef buf As Byte, ByVal len As Long) As Long function syio_read(port: Longint; buf: PChar; len: Longint): Longint; stdcall; function syio_read; external syncapi.dll ; Note: Return Code of 8 means the data length coming in is bigger than the length set by the user in the len parameter. int port = 2; char buf[10]; ret = syio_read (port, buf, LengthToRead ); if ( ret == 0) { /* No data in on board buffer */ else if ( ret == length ) { /* The frame size is length and is read by read function ( the length may be any number between 1.. LengthToRead*/ else { /* read out fail */ API Programmer s Manual 3-25

Function 25 syio_setreadtimeouts Data Input Set the syio_read timeout value. Please refer to syio_read function for more information. int WINAPI syio_setreadtimeouts(int port, DWORD timeouts); Input: int port :port numbers 0 11 DWORD timeouts 0 for nonblock mode -1 block forever until data come in >0 block desired ms or data come in Output: refer to return code list Declare Function syio_setreadtimeouts Lib syncapi.dll (ByVal port As Long, ByVal timeouts As Long) As Long function syio_setreadtimeouts(port, timeouts: Longint): Longint; stdcall; function syio_setreadtimeouts; external syncapi.dll ; ret = syio_setreadtimeouts( port, 20 );/* set read block 20 ms */ If ( ret < 0 ) { /* fail */ 3-26 API Programmer s Manual

Detailed Function Reference Function 26 syio_getreadtimeouts Data Input Get read-timeout setting. Please refer to the syio_read and syio_setreadtimeouts functions for more information. int WINAPI syio_getreadtimeouts(int port, DWORD *timeouts); Input: int port :port numbers 0 11 DWORD *timeouts : to get timeouts pointer. Output: refer to return code list Declare Function syio_getreadtimeouts Lib syncapi.dll (ByVal port As Long, ByRef timeouts As Long) As Long function syio_getredtimeouts(port: Longint; var timeouts: Longint): Longint; stdcall; function syio_getreadtimeouts; external syncapi.dll ; Note: When the write timeouts is too short for the system to send out data, syio_write will return -6, and part of the data may already be sent out to the line. ret = syio_getreadtimeouts( port, &readtimeout ); If ( ret < 0 ) { /* fail */ API Programmer s Manual 3-27

Function 27 syio_abortread Data Input Abort the blocked syio_read function call. int WINAPI syio_abortread(int port); Input: int port :port numbers 0 11 Output: refer to return code list Declare Function syio_abortread Lib syncapi.dll (ByVal port As Long) As Long function syio_abortread(port: Longint): Longint; stdcall; function syio_abortread; external syncapi.dll ; ret = syio_abortread( port );/* abort port read */ If ( ret < 0 ) { /* fail */ 3-28 API Programmer s Manual

Detailed Function Reference Function 28 syio_inframe Data Input Get the number of received frames in the driver s buffer. int WINAPI syio_inframe(int port); Input: int port : port numbers 0 11 Output >= 0 : received frames < 0 : refer to return code list Declare Function syio_inframe Lib syncapi.dll (ByVal port As Long) As Long function syio_inframe(port: Longint): Longint; stdcall; function syio_inframe; external syncapi.dll ; If (syio_inframe(port) > 0 ) { ret = syio_read( port, buf, SIZE_DESIRED ); If ( ret < 0 ) { /* fail */ API Programmer s Manual 3-29

Function 29 syio_inqueue Data Input Get the received data bytes in the driver s buffer. int WINAPI syio_inqueue(int port); Input: int port : port numbers 0 11 Output >= 0 : received bytes < 0 : refer to return code list Declare Function syio_inqueue Lib syncapi.dll (ByVal port As Long) As Long function syio_inqueue(port: Longint): Longint; stdcall; function syio_inqueue; external syncapi.dll ; inqueue = syio_inqueue( port ); If ( inqueue > 0 ) { /* inqueue is the data in inbuffer in byte number */ 3-30 API Programmer s Manual

Detailed Function Reference Function 30 syio_infreeframe Data Input Get the number of free input frames in the driver s buffer. int WINAPI syio_infreeframe(int port); Input: int port : port numbers 0 11 Output >= 0 : free input frames < 0 : refer to return code list Declare Function syio_infreeframe Lib syncapi.dll (ByVal port As Long) As Long function syio_infreeframe(port: Longint): Longint; stdcall; function syio_infreeframe; external syncapi.dll ; ret = syio_infreeframe( port ); If ( ret > 0 ) { /* ret means the frame still free in input buffer */ API Programmer s Manual 3-31

Function 31 syio_infree Data Input Get free data byte space in the driver s buffer. int WINAPI syio_infree(int port); Input: int port : port numbers 0 11 Output >= 0 : free input bytes < 0 : refer to return code list Declare Function syio_infree Lib syncapi.dll (ByVal port As Long) As Long function syio_infree(port: Longint): Longint; stdcall; function syio_infree; external syncapi.dll ; infree = syio_infree( port ); If ( ret > 0 ) { /* infree is the free space in input buffer in byte count */ 3-32 API Programmer s Manual

Detailed Function Reference Function 32 syio_skipframe Data Input Skip the first received frame from the driver s buffer. The skipped frame will be discarded and will not be read by the application. int WINAPI syio_skipframe(int port); Input: int port :port numbers 0 11 Output: refer to return code list Declare Function syio_skipframe Lib syncapi.dll (ByVal port As Long) function syio_skipframe(port: Longint): Longint; stdcall; function syio_skipframe; external syncapi.dll ; If (syio_getfirstframelen( port ) > LENGTH_MAX) { ret = syio_skipframe( port ); If ( ret < 0 ) { /* fail */ API Programmer s Manual 3-33

Function 33 syio_getfirstframelen Data Input Get first received frame length. int WINAPI syio_getfirstframelen(int port); Input: int port : port numbers 0 11 Output >= 0 : the first frame length < 0 : refer to return code list Declare Function syio_getfirstframelen Lib syncapi.dll (ByVal port As Long) As Long function syio_getfirstframelen(port: Longint): Longint; stdcall; function syio_getfirstframelen; external syncapi.dll ; firstframe = syio_getfirstframelen( port ); If ( firstframelen < 0 ) { /* fail */ 3-34 API Programmer s Manual

Detailed Function Reference Function 34 syio_write Data Output Send data. If you set write-timeout to zero, it will write the data to dual-port DRAM on the board and then return as soon as possible. If you set write-timeout to a specific value, it will block function calls to syio_write until the data write to FIFO is completed or times out. Setting timeout to 1 will block until another Thread aborts it, or the write is really complete (also see syio_setwritetimeouts for more information). int WINAPI syio_write(int port, char *buf, int len); Input: int port :port numbers 0 11 char *buf : to-send data buffer pointer Int len : to-send data length Output >= 0 : sent data length < 0 : refer to return code list Declare Function syio_write Lib syncapi.dll (ByVal port As Long, ByRef buf As Byte, ByVal len As Long) As Long function syio_write(port: Longint; buf: PChar; len: Longint): Longint; stdcall; function syio_write; external syncapi.dll ; Note: Block mode read write is not support in DOS int port = 2; char buf[10]; ret = syio_write (port, buf, 10 ); if ( ret == 0) { /* On board buffer full; wait some time and send again */ else if ( ret == 10 ) { /* data write to on board buffer in nonblock mode */ /* data is already write out to FIFO in block mode (the HD64570 have on chip FIFO 32 byte)*/ else { /* write out fail */ API Programmer s Manual 3-35

Function 35 syio_setwritetimeouts Data Output Set write-timeout setting. Please refer to the syio_write function for more information. int WINAPI syio_setwritetimeouts(int port, DWORD timeouts); Input: int port :port numbers 0 11 DWORD timeouts 0 for nonblock mode -1 block forever until data write out >0 block desired ms or data write out Output: refer to return code list Declare Function syio_setwritetimeouts Lib syncapi.dll (ByVal port As Long, ByVal timeouts As Long) As Long function syio_setwritetimeouts(port, timeouts: Longint): Longint; stdcall; function syio_setwritetimeouts; external syncapi.dll ; ret = syio_setwritetimeouts( port, 20 );/* set write block 20 ms */ If ( ret < 0 ) { /* fail */ 3-36 API Programmer s Manual

Detailed Function Reference Function 36 syio_getwritetimeouts Data Output Get write-timeout setting. Please refer to syio_write and syio_setwritetimeouts function for more details. int WINAPI syio_getwritetimeouts(int port, DWORD *timeouts); Input: int port :port numbers 0 11 DWORD *timeouts : to get timeouts pointer. Output: refer to return code list Declare Function syio_getwritetimeouts Lib syncapi.dll (ByVal port As Long, ByRef timeouts As Long) As Long function syio_getwritetimeouts(port: Longint; var timeouts: Longint): Longint; stdcall; function syio_getwritetimeouts; external syncapi.dll ; ret = syio_getwritetimeouts( port, &writetimeout ); If ( ret < 0 ) { /* fail */ API Programmer s Manual 3-37

Function 37 syio_abortwrite Data Output Abort the blocked syio_write function call. int WINAPI syio_abortwrite(int port); Input: int port :port numbers 0 11 Output: refer to return code list Declare Function syio_abortwrite Lib syncapi.dll (ByVal port As Long) As Long function syio_abortwrite(port: Longint): Longint; stdcall; function syio_abortwrite; external syncapi.dll ; ret = syio_abortwrite( port );/* abort port write */ If ( ret < 0 ) { /* fail */ 3-38 API Programmer s Manual

Detailed Function Reference Function 38 syio_outframe Data Output Get the number of to-be-sent frames in the driver s buffer. int WINAPI syio_outframe(int port); Input: int port : port numbers 0 11 Output >= 0 : to-send frames < 0 : refer to return code list Declare Function syio_outframe Lib syncapi.dll (ByVal port As Long) As Long function syio_outframe(port: Longint): Longint; stdcall; function syio_outframe; external syncapi.dll ; ret = syio_outframe( port ); If ( ret > 0 ) { /* there are data in outpur buffer still */ API Programmer s Manual 3-39

Function 39 syio_outqueue Data Output Get to-be-sent data bytes in the driver s buffer. int WINAPI syio_outqueue(int port); Input: int port : port numbers 0 11 Output >= 0 : to-be-sent bytes < 0 : refer to return code list Declare Function syio_outqueue Lib syncapi.dll (ByVal port As Long) As Long function syio_outqueue(port: Longint): Longint; stdcall; function syio_outqueue; external syncapi.dll ; outqueue = syio_outqueue( port ); If ( ret > 0 ) { /* outqueue is the data in output buffer in byte count */ 3-40 API Programmer s Manual

Detailed Function Reference Function 40 syio_outfreeframe Data Output Get the number of free output frames in the driver s buffer. int WINAPI syio_outfreeframe(int port); Input: int port : port numbers 0 11 Output >= 0 : free output frames < 0 : refer to return code list Declare Function syio_outfreeframe Lib syncapi.dll (ByVal port As Long) As Long function syio_outfreeframe(port: Longint): Longint; stdcall; function syio_outfreeframe; external syncapi.dll ; ret = syio_outfreeframe( port ); If ( ret > 0 ) { /* ret means the free frame in output buffer */ API Programmer s Manual 3-41

Function 41 syio_outfree Data Output Get free output data byte space in the driver s buffer. int WINAPI syio_outfree(int port); Input: int port : port numbers 0 11 Output >= 0 : output free bytes < 0 : refer to return code list Declare Function syio_outfree Lib syncapi.dll (ByVal port As Long) As Long function syio_outfree(port: Longint): Longint; stdcall; function syio_outfree; external syncapi.dll ; outfree = syio_outfree( port ); If ( ret > 0 ) { /* outfree is the free space in output buffer in byte count */ int port = 2; char buf[10]; ret = syio_view (port, buf, LengthToView ); if ( ret == 0) { /* No data in onboard input buffer */ else if ( ret == length ) { /* The frame size is length and user can decide to read this data by read function or just call syio_flush to abort this data */ ( the length may be any number between 1.. LengthToView*/ else { /* View fail */ 3-42 API Programmer s Manual

Detailed Function Reference Function 42 syio_linestatus Status Inquiry Get the line state of DSR, DCD, and CTS. int WINAPI syio_linestatus(int port); Input: Int port : port numbers 0 11 Output >= 0 Can be DCD_ON, DSR_ON,CTS_ON or any conbination of them < 0 : refer to return code list Declare Function syio_linestatus Lib syncapi.dll (ByVal port As Long) As Long function syio_linestatus(port: Longint): Longint; stdcall; function syio_linestatus; external syncapi.dll ; linestat = syio_getlinestat( port ); If ( linestat DCD_ON ) { /* line DCD is active */ else if ( linestat CTS_ON ) { /* line CTS is active */ else if ( linestat DSR_ON ) { /* line DSR is active */ API Programmer s Manual 3-43

Function 43 syio_getboardid Status Inquiry User can identify their underlying system by calling this function. int WINAPI syio_getboardid(int port); Input: int port : port numbers 0 11 Output >= 0 Could be C101_ISA, C101_PCI, C502_ISA,C502_PCI < 0 : refer to return code list Declare Function syio_getboardid Lib syncapi.dll (ByVal port As Long) As Long function syio_getboardid(port: Longint): Longint; stdcall; function syio_getboardid; external syncapi.dll ; boardid = syio_getboardid( port ); If ( boardid < 0 ) { /* fail */ 3-44 API Programmer s Manual

Detailed Function Reference Function 44 syio_frameirq Event Service Set the event number of received frames. You can specify a function to be called when a frame event occurs. If the function is set as NULL, the frame event will be cleared. int WINAPI syio_frameirq(int port, VOID (CALLBACK *func)(int port), int framecnt); Input: int port :port numbers 0 11 VOID (CALLBACK *func)(int port) : the function to be called when this event occurs int framecnt :Number of received frames to call the function. It must be greater than zero. Output: refer to return code list Declare Function syio_frameirq Lib syncapi.dll (ByVal port As Long, ByVal func As Long, ByVal framecnt As Long) As Long Type IrqProc1 = procedure(port: Longint); stdcall; function syio_frameirq(port: Longint; func: IrqProc1; framecnt: Longint): Longint; stdcall; function syio_frameirq; external syncapi.dll ; API Programmer s Manual 3-45

/* user can receive data in FrameFunc */ void CALLBACK FrameFunc(int port); /* user must first register a call back function, when the inframe satisfy FRAME_CNT the friver will call this function */ ret = syio_frameirq(port, FrameFunc, FRAME_CNT); if ( ret < 0 ) { /* fail */ void CALLBACK FrameFunc(int port) { /* do something about the incoming data */ 3-46 API Programmer s Manual

Detailed Function Reference Function 45 syio_modemirq Event Service Set the event modem status change. You can specify a function to be called when modem CTS, DCD, DSR on/off status changes. If the function is set to NULL, the modem event will be cleared. int WINAPI syio_modemirq(int port, VOID (CALLBACK *func)(int port, int status), int mode); Input: int port :port numbers 0 11 VOID (CALLBACK *func)(int port, int status) : the function to be called when this event happens int mode :Types of modem status change At last one modem status must be set. Output: refer to return code list Declare Function syio_modemirq Lib syncapi.dll (ByVal port As Long, ByVal func As Long, ByVal mode As Long) As Long type IrqProc2 = procedure(port, status: Longint); stdcall; function syio_modemirq(port: Longint; func: IrqProc2; mode: Longint): Longint; stdcall; function syio_modemirq; external syncapi.dll ; API Programmer s Manual 3-47

/* user can do something in ModemFunc */ void CALLBACK ModemFunc(int port, int status); /* user must first register a call back function, when the linestate changes the driver will call this function */ ret = syio_modemirq(port, ModemFunc, CTSCHANGE_INT DCDCHANGE_INT); if ( ret < 0 ) { /* fail */ void CALLBACK ModemFunc(int port, int status) { /* status may be DCDCHANGE_INT, DSRCHANGE_INT CTSCHANGE_INT or any of their combination you register in ModemIrq function*/ /* do something about the modem change */ 3-48 API Programmer s Manual

Detailed Function Reference Function 46 syio_txemptyirq Event Service Set the event Tx Empty. You can specify a function to be called when the Tx Empty event occurs. If the function is set to NULL, the Tx Empty event will be cleared. int WINAPI syio_txemptyirq(int port, VOID (CALLBACK *func)(int port); Input: int port :port numbers 0 11 VOID (CALLBACK *func)(int port) : the function to be called when this event occurs Output: refer to return code list Declare Function syio_txemptyirq Lib syncapi.dll (ByVal port As Long, ByVal func As Long) As Long type IrqProc1 = procedure(port: Longint); stdcall; function syio_txemptyirq(port: Longint; func: IrqProc1): Longint; stdcall; function syio_txemptyirq; external syncapi.dll ; /* user can do something in TxEmptyFunc */ void CALLBACK TxEmptyFunc(int port); /* user must first register a call back function, when the transmit buffer is empty the driver will call this function*/ ret = syio_txemptyirq(port, TxEmptyFunc); if ( ret < 0 ) { /* fail */ void CALLBACK TxEmptyFunc(int port) { /* do something about the transmit empty */ API Programmer s Manual 3-49

Function 47 syio_view Miscellaneous Preview data. It works the same as syio_read, but data stays in the driver after being read. It has no timeout value. int WINAPI syio_view(int port, char*buf, int len); Input: int port :port numbers 0 11 char *buf : to-view data buffer pointer int len : to-view data length Output >= 0 : viewing data length < 0 : refer to return code list Declare Function syio_view Lib syncapi.dll (ByVal port As Long, ByRef buf As Byte, ByVal len As Long) As Long function syio_view(port: Longint; buf: PChar; len: Longint): Longint; stdcall; function syio_view; external syncapi.dll ; 3-50 API Programmer s Manual