Для связи по COM-порту давно используем библиотеку от
http://www.marshallsoft.com.
Зачем изобретать велосипед? Все уже давно написано за нас.
Как использовать библиотеку.
В Visual C
__________
в заголовке:
#include "wsc.h"
#pragma comment(lib,"wsc32.lib")
файлы wsc.h, wsc32.dll, wsc32.lib должны быть в каталоге с проектом
все
теперь можно использовать функции непосредственно в теле программы:
There are 32 functions in the WSC library.
SioBaud Sets the baud rate of the selected port.
SioBrkSig Asserts, cancels, or detects BREAK signal.
SioCTS Reads the Clear to Send (CTS) modem status bit.
SioDCD Reads the Data Carrier Detect (DCD) modem status.
SioDebug Set and/or reads debug data.
SioDone Terminates further serial processing.
SioDSR Reads the Data Set Ready (DSR) modem status bit.
SioDTR Set, clear, or read the Data Terminal Ready (DTR).
SioEvent Wait for specified event.
SioFlow Enables / disables hardware flow control.
SioGetc Reads the next character from the serial line.
SioGets Receives a string of characters.
SioInfo Returns information such as library version.
SioKeycode Passes the "key code" value to the DLL.
SioMessage Post message when event occurs.
SioParms Sets parity, stop bits, and word length.
SioPutc Transmit a character over a serial line.
SioPuts Transmits a string of characters.
SioRead Reads any UART register.
SioReset Initialize a serial port for processing.
SioRI Reads the Ring Indicator (RI) modem status bit.
SioRTS Sets, clears, or reads the Request to Send (RTS)
SioRxClear Clears the receive buffer.
SioRxQue Returns the number of characters in the RX queue.
SioStatus Returns the serial port line status.
SioTimer Returns the system times in milliseconds.
SioTxClear Clears the transmit buffer.
SioTxQue Returns the number of characters in the TX queue.
SioUnGetc "Ungets" (puts back) a specified character.
SioWinError Returns Win32 error message as text.
SioGetReg Gets registration string
SioSetInteger Sets port specific integer parameters.
в WinCC
_______
1. Скопируем файл wsc32.dll в папку \Siemens\WinCC\bin
2. Скопируем файл wsc.h в папку с проектом \library
3. В скриптах нужна шапка:
#pragma code ("wsc32.dll")
#include "wsc.h"
#pragma code()
4. клиент вебнавигатора
\siemens\wincc\webnavigator\common\scripting\wsc.h
Остальное разжевано в документации от производителя.
Если покупать dll жаба душит, то вот непоследняя вылеченная версия:
http://depositfiles.com/files/5k9lumzj7