본문 바로가기

카테고리 없음

Vc6 Serial Port Example

SuperCom - Serial Communication LibraryThe SuperCom Serial Port Communication Library is a programmer's library used to develop serial communication applications.Easily read and write data to the serial port. Send data through the serial port without delay.Using SuperCom you easily write serial communication applications and control serial ports, Modem, Barcode Scanner, Scales, PLC, POS, serial medical devices, serial printer etc.

Develop easily applications to accomplish serial data and file transfer incl. ZMODEMYMODEMYMODEM-GYMODEM/BATCHXMODEM-1KXMODEMXMODEM/CRCKERMITExtended XMODEMASCII-AS5113964RRK512LSV/2MODBUSSuperCom breaks the limits in fast and reliable data communication and file transfer. It includes nearly all known standard file transfer used in serial communications.

Special modules are available to support industrial serial data communications with PLC and automation controllers.With SuperCom the protocols mentioned above are not restricted to serial communication only but can be used with any connection type supported by the used SuperCom library e.g. ISDN, TCP/IP.With SuperCom the application can execute faster and smoother.No matter how the application is transmitting data, SuperCom will always perform data communication on multiple connections concurrently and in background.No matter if data monitoring, receiving complex data packets, running complex data transmission protocols, establishing connections or doing file transfer. It can run complex tasks optimized and transparently in background enabling the application to execute fast and smooth and perform other tasks too. Easy HandlingSuperCom is a universal data communication library. Using only a few functions you already get a complete serial communication program within a few lines.

The following short program clearly shows this for serial communications. Let's explain the above lines a bit:The function ComInit instructs SuperCom to assign the second data link (e.g.

The second serial port on Windows 'COM2', on Linux 'ttyS1'). ComSetState applies the communication parameters and flow control. Now the connection is ready to transfer data. The function RSTXPacket transmits the data packet Msg through the data link (e.g. Serial interface) and ComReset finaly closes all actions on the data link and releases the used data link and any used hardware and software resources used.More samples on setting a data connection with SuperCom can be found.The next small sample shows an elegant solution to a common problem: What serial ports are available in the system (installed and not used). SuperCom's serial communication library supports a multitude of different serial hardware used for serial communications.The variety of serial interfaces is diverse and SuperCom is flexible enough to control the different variations in a transparent way hidding the details.

In fact it's under continous tests with serial devices from major manufacturer (e.g. Axxon, Decision, Digi, Moxa, Quatech, etc.).In the following we functionally group the serial hardware actually on market as follows:.

Standard Serial Ports. Multiserial Boards. Virtual Serial Ports.

Intelligent Multiserial BoardsStandard Serial PortsSerial comm ports which do not support interrupt sharing are called Standard Comm Ports (e.g. Multiserial BoardsMultiserial boards are add-on boards for ISA, PCI, PCI-X or PCIe Bus. These boards used in serial communications and offer one or more serial ports. By design some boards allow two or more boards to run in a single PC.Controlling more than one serial communication link simultaneously is SuperCom's playground and it does it completely in background. PCMCIA (X=1/2/4)These are PCMCIA to RS-232 adapters, PCMCIA to RS-422 adapters or PCMCIA to RS-485 adapters used in serial communications.

Intelligent Multiserial BoardsThe intelligent boards are serial boards equipped with a CPU (mainly 80186 or RISC) and RAM. Intelligent boards can be equipped with 64KByte to 1MByte of dual-ported RAM mainly used for data storage and buffering.

This improves the system speed and reduces the overall load of the host CPU due to the missing interrupt requests. Virtual Serial PortsWith serial communication the serial port is often not physically present on the local computer but simulated by a driver. The real hardware (if any) is connected externaly e.g. On an Ethernet Network (e.g.

PortServer, Comm-Server, Terminal Server or Serial Server), serial ports redirected through the Windows Remote Desktop Protocol ( RDP), PCMCIA-to-Serial, USB-to-Serial, Ethernet-to-Serial, Bluetooth-to-Serial, Infrared-to-Serial or any other type of physically not present serial port. SuperCom locates these COMM ports even if non-standard names used (e.g. FASTCOM19).One or more multi serial boards can be installed in a PC (dependent on manufacturer) to support the amount of serial ports needed. USB-to-SerialThese are USB Serial Adapters (RS-232, RS-422, RS-485) attached to an USB port. SuperCom for Windows can report event with the port name on serial port insertion/removal.SuperCom also optimizes data throughput and latency for USB-to-Serial adapters as far as possible.

As a SuperCom customer you can also obtain the Data Transfer Optimization Guide (PDF). Ethernet-to-SerialThese are Ethernet to Serial Adapters (RS-232, RS-422, RS-485) connected to a TCP switch/hub.SuperCom also optimizes data throughput and latency for this kind of adapters as far as possible. As a SuperCom customer you can also obtain the Data Transfer Optimization Guide (PDF). Wireless Serial Adapter (RS-232, RS-422, RS-485)Are used to connect serial devices that are not linked by a physical cable connection. These can be Wireless USB-to-Serial adapters, Wireless Bluetooth to-Serial adapters, Wireless LAN-to-Serial adapter, etc.

SuperCom for Windows can report event with the port name on serial port insertion/removal.SuperCom also optimizes data throughput and latency for this kind of adapters as far as possible. As a SuperCom customer you can also obtain the Data Transfer Optimization Guide (PDF). FIFO Support (UART 0/0)The 16550 UART has the feature to temporarily store up to 16 incoming characters in a FIFO (First In First Out) buffer. This feature increases the performance of the system since the number of interrupts in the system is reduced. Furthermore the security of the data transmission is considerably improved, above all in a multitasking environment and high transmission speeds are possible.Modern UARTS like the 16950 are equipped with up to 128 bytes of FIFO buffer.SuperCom supports the FIFO UART. SuperCom also runs serial data communication in low level buffered mode to avoid buffer overrun and to allow the applcation to perform other tasks as well.

RS-485 MultidropBesides supporting RS-232 and RS-422 serial communication, SuperCom also support the RS-485 data communication.RS-485 connects two or more stations on a two wire half-duplex bus system (network). That is bi-directional, half-duplex, multi-drop serial data communication over a single pair of cable. Each station can only transmit or receive data at a time (half-duplex). The so called 'direction' is used to switch from transmit to receiving mode and vice versa.

A timed switch of the 'direction' is essential to avoid loss in data. SuperCom handles the RS-485 serial port transparently and offers a very low-latency switch of 'direction'. A four wire full-duplex connection may also be used.The testing samples showed that SuperCom can switch several times within 1 ms. The speed tests were performed using Desktop PCs with AMD Athlon 64 X2 2.5GHz and Windows XP SP3. Newer AMD or Intel CPUs are expected to perform 2-10 times faster.9-Bit serial data9-Bit serial communication (9-Bit framing) is mainly used to identify address byte within messages running on a multidrop network but also on standard RS-232 connections. Are usually not supported by the standard PC UART but simulated by the SuperCom software.

Very fast response timing (low latency) by the software is essential to accomplish reliable 9-bit data communication. SuperCom does provide a very realiable solution here to be used with high level languages.Many Samples (e.g. C/C, C#, Delphi, Pascal, VB net) also included that demonstrate this operating mode.For example, transmitting a data packet using 9-bit addressing e.g.: TXPacket9BitCond(Com, cData, nDataCount, SEC01);9-bit data communication is used today, among other things, to control small embedded controllers using specific protocols, such as the SAS protocol. Below a more detail description of the portable SuperCom API. Near all features are true for communications over serial lines, ISDN and TCP/IP. Please also consult the common feature list, the and the chart of to make sure the feature you want is supported by the selected SuperCom software.The SuperCom APISuperCom offers an easy to use, flexible and portable API.

The same API is used among different operating systems and hardware ( RS-232, RS-485, ISDN, TCP/IP). Under Windows it's also referred as the.The software developer uses one single API.Transmitting and receiving takes place in the background secured through buffered data communication with adjustable buffers for both directions. The application can safely perform other tasks while data transmission takes place.SuperCom is fast, even in a multitasking operating system - it often solves issues where others are using system drivers.SuperCom integrates the most modern communication technology like: event reporting, thread driven data transmission, high speed byte and paket functions, intelligent data filter, data trigger and data packet collectors. Furthermore it offers the highest security and speed with little burden on the computer, particularly important in a multitasking operating system. Modularity in Data CommunicationsSuperCom consists of several modules which can be used according to your needs.The core module contains the 'low level functions' operating on top of the hardware and the 'high level functions' offering a 'portable layer'. This 'portable layer' provides most wanted functions like: transmit and receive data (even time dependent), determine the status of a link, funtions that transmit and receive data packets (even time dependent), functions for calculating check sums and CRC, functions for setting up connections etc. ZMODEMYMODEMYMODEM-GYMODEM/BATCHXMODEM-1KXMODEMXMODEM/CRCKERMITExtended XMODEMASCII-AS5113964RRK512LSV/2MODBUSThe standard protocol module contain the so called, that are widely known and used.

These protocols enable fast and secure file transmission. Special mainly used in industrial data communication applications are also available (see also ).The Terminal emulations module offers ANSI, VT100, VT52, TTY. PortableThe part of your application which takes care the data communication with SuperCom can already be considered as completed when moving from Serial Communication to TCP/IP or ISDN and especially when moving between DOS, Linux, OS/2, Windows.

Event DrivenAn application using SuperCom can be event driven. Events are reported for: received or transmitted data, modem status, line errors, modem dialup status, file transmission status, plugging or unplugging serial PnP devices (serial comm port insertion/removal), TCP/IP network failures.The enhanced event reporting mechanism in SuperCom also enables you to receive events on any defined character (e.g.

STX, ACK, NAK, EOF).Type and amount of the events is also related to the used SuperCom software e.g. A SuperCom supporting only serial communications will not report TCP/IP network events. ConnectingEstablishing connections through a Modem, TAPI, TCP/IP or ISDN is taken care by the common connect functions. The SuperCom functions can establish a connection (dialup) or waiting on an incoming call (server) and execute (on request) completely in background.The SuperCom functions can trigger events during a connection attempt and provide the application with status information. So, even it executes in background the application stays in touch with the happening.DLL APIIn order to receive events the application has to provide an OnConnect.

function. The OnConnect function is optional but very handy in many situations. Using OnConnect the application can receive progress information, information about the time left to complete a call or even cancel the connection attempt before it completes. Visual Basic ' optional event functionPublic Function OnConnect(Com, Action, TimeLeft, Data) As LongIf Action = acCONNECTINFO Then'Received periodically, while in progressEnd IfIf Action = acCONNECTOK Then' Connected!End IfIf Action = acCONNECTFAILED Then' A connection attempt failedEnd IfIf (Action= acCONNECTUSERBREAK) Then' User interruptedEnd IfOnConnect = infContinueEnd Function::' init.Call ComInit(Com)' now connect.Res = RSConnectEx(Com, SEC60, DialStr, OnConnect). Establishing a connection can run completely in background.

Vc6 Serial Port Example

The application receives events about the progress.Comparing this sample made for a serial Modem with the one for or shows how effective it is to have a portable API!More samples on setting a data connection with SuperCom can be found.File Transfer ProtocolsSuperCom provides reliable and high speed file transfer protocols. These protocols are widely used and supported by many third party applications (e.g., YMODEM/BATCH, YMODEM, YMODEM-G, KERMIT, and ).With the SuperCom library any of the above protocol can run on any serial port, any established connection (i.e. Modem, TCP, ISDN) concurrently and in background. Queues of files to transfer are also possible to create and monitor (file-server etc.).One of the most powerful among these protocols is ZMODEM that includes important features like 'crash recovery', 32bit CRC, 'batch file transfer', File Options, ZMODEM/8k block option and the powerful ADONTEC extension ZMODEM/32k (ZMODEM/64k shipped on request). The SuperCom ZMODEM implementation also includes support for slow communication channels and high latency connections (e.g.

Satellite lines).The KERMIT protocol and the Extended XMODEM are also offering a lot of interesting options.Autodownloadis a file transfer protocol feature that enables automated receiving of file(s) transmitted from a remote host machine. SuperCom offers Autodownloading with the ZMODEM, KERMIT and protocol.A file transfer is very easy started by one function. The protocol then triggers events to inform about status and other usefull protocol information. Events are received by a so called OnFile function. The OnFile function is optional but very handy in many situation e.g. To receive progress information, to cancel a file transfer.

When SuperCom uses a protocol like ZMODEM or YMODEM/BATCH it can receive many files within on session. The OnFile will provide such information. 3964 Protocol, RK512 Protocol, AS511 Protoocl, LSV2 Protocol, MODBUS Protocol Custom Protocol DevelopmentSuperCom provides a big pool of functions to easy develop custom protocols.

Serial

Functions to transmit data packages event driven, time driven, functions to calculate checksums, CRC and many more. MS OfficeSuperCom supports MS-Office applications through direct function calls to the SuperCom or using the VBA (Visual Basic for Applications) calling interface.Office applications like Access, Excel, Word may also prefer to use the. Another way is to call functions from the SuperCom using the available VBA (Visual Basic for Applications) calling interface.Samples for Word and Excel are available. SuperCom DLL API - Features ListDLL APIFast gets even Faster! SuperCom was a fast data communication engine but version 9 is now even faster!

The new, shorter response times speed up small data packets protocols and communicating with embedded devices.A more detailed list of features and common properties of the SuperCom libraries can be foundA short list of DLL API functions can be foundA short summary of the ActiveX API can be foundBonus Software: sample applications (PortServer, COMM Server, Terminal Server or Serial Server) were developed with the and therein included with source code (for example C#, Visual Basic 6). VersatilitySuperCom is still the number one toolkit that supports different development environments providing extensive API support and samples. You're free to switch your compiler anytime and your are not bound to one and only.

Visual Studio Serial Port Example

This saves a huge amount of time and costs of development.License Terms Compiler, Operating SystemFabulous! And as always, thanks for the prompt and thorough support. You have a fan in California. From CaliforniaAmazing, CPU usage dropped from 100% to 15% and it runs faster! Excelent work guys, thanks!Paul., UK.

I wrote a piece of code to communicate with outside world through a RS232 Cable using Visual C WIN32 Console Application. Testing this code using a NULL Cable and a Laptop to send and receive data was successful. However, when I use my device whichas an electricity meter and suppose to receive data when I send 'N' character plus the proper address returning nothing!Using Tera-Term it is absolutely working in a real-time basis. Sending and receiving data is absolutely fine as it is expected!I went through the code and realized that my buffer cannot get filled. The buffer is totally blank! This tells me that I read nothing! So, my home-made terminal is acting differently when it sends the characters.

But it looks exactly the same as Tera Term!I am trying to find out what the problem is! Perhaps by checking the firmware of my meter!

In the mean time do you guys have any idea why my code is not working in a way that it was expected?Not to mention that I used MSDN WIN32 codes to write this piece of code given by the following link.https://msdn.microsoft.com/en-us/library/ff802693.aspx. Hello,for first I'll be check functionality of external device with functional SW like Hyperterminal or other free serial SW. I expect that your external device use RS-485 or RS-422?

Pls check this because it can be needed change wire system, 2 wire/4 wiresystem. This you must check on device documentation.

Next work is set same communication settings on both devices - PC and device. How to set correct communication settings on device (meter) you can check in device documentation.

Connect your PC/notebook withRS-232 serial port and adapter to external device. Start Hyperterminal and create connection. Start send some needed frames and check receiving of data. Can you post what type of protocol use that meter device? Maybe Modbus RTU?Regards.DurisI. Durisl,I realized that my device uses an interface chip: CY233 by the following datasheet.when you send 'N01' it goes and grab the character located in the address 01. Before, I though the firmware is asking for that character!Now, I am totally confused!

When I use Tera-Term and my hardware is an adaptor RS232 RS422 I am able to send and receive!My code had not dcb setting which controls the baudrate, parity and so on! That was a big Booboo in the code eh?!However, adding that, I realized that my write function is still unhappy!