91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

實現了一個基于Windows操作系統的Modbus/TCP服務器,采用C語言編寫,可以方便初學者使用

資源截圖

代碼片段和文件信息

/*
?*?FreeModbus?Libary:?Win32?Demo?Application
?*?Copyright?(C)?2006?Christian?Walter?
?*
?*?This?library?is?free?software;?you?can?redistribute?it?and/or
?*?modify?it?under?the?terms?of?the?GNU?Lesser?General?Public
?*?License?as?published?by?the?Free?Software?Foundation;?either
?*?version?2.1?of?the?License?or?(at?your?option)?any?later?version.
?*
?*?This?library?is?distributed?in?the?hope?that?it?will?be?useful
?*?but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
?*?MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.??See?the?GNU
?*?Lesser?General?Public?License?for?more?details.
?*
?*?You?should?have?received?a?copy?of?the?GNU?Lesser?General?Public
?*?License?along?with?this?library;?if?not?write?to?the?Free?Software
?*?Foundation?Inc.?51?Franklin?St?Fifth?Floor?Boston?MA??02110-1301??USA
?*
?*?File:?$Id:?demo.cppv?1.2?2006/06/26?19:24:07?wolti?Exp?$
?*/

#include?“stdafx.h“
#pragma?comment(lib“Ws2_32.lib“)
/*?-----------------------?Modbus?includes?----------------------------------*/
#include?“mb.h“

/*?-----------------------?Defines?------------------------------------------*/
#define?PROG????????????_T(“freemodbus“)

#define?REG_INPUT_START?1000??
//輸入寄存器的起始地址
#define?REG_INPUT_NREGS?4
//輸入寄存器的數量
#define?REG_HOLDING_START?2000
//保持寄存器的起始地址
#define?REG_HOLDING_NREGS?130
//保持寄存器的數量

/*?-----------------------?Static?variables?---------------------------------*/
static?USHORT???usRegInputStart?=?REG_INPUT_START;
static?USHORT???usRegInputBuf[REG_INPUT_NREGS];
static?USHORT???usRegHoldingStart?=?REG_HOLDING_START;
static?USHORT???usRegHoldingBuf[REG_HOLDING_NREGS];

static?HANDLE???hPollThread;
static?CRITICAL_SECTION?hPollLock;
static?enum?ThreadState
{
????STOPPED
????RUNNING
????SHUTDOWN
}?ePollThreadState;

/*?-----------------------?Static?functions?---------------------------------*/
static?BOOL?????bCreatePollingThread(?void?);
static?enum?ThreadState?eGetPollingThreadState(?void?);
static?void?????eSetPollingThreadState(?enum?ThreadState?eNewState?);
static?DWORD?WINAPI?dwPollingThread(?LPVOID?lpParameter?);

/*?-----------------------?Start?implementation?-----------------------------*/
int
_tmain(?int?argc?_TCHAR?*?argv[]?)
{
????int?????????????iExitCode;
????TCHAR???????????cCh;
????BOOL????????????bDoExit;

????if(?eMBTCPInit(?MB_TCP_PORT_USE_DEFAULT?)?!=?MB_ENOERR?)
????{
????????_ftprintf(?stderr?_T(?“%s:?can‘t?initialize?modbus?stack!\r\n“?)?PROG?);
????????iExitCode?=?EXIT_FAILURE;
????}
????else
????{
????????/*?Create?synchronization?primitives?and?set?the?current?state
?????????*?of?the?thread?to?STOPPED.
?????????*/
????????InitializeCriticalSection(?&hPollLock?);
????????eSetPollingThreadState(?STOPPED?);

????????/*?CLI?interface.?*/
????????_tprintf(?_T(?“Type?‘q‘?for?quit?or?‘h‘?for?help!\r\n“?)?);
????????bDoExit?=?FALSE;
????????do
????????{
????????????_tprintf(?_T(?“>?“?)?);
?????????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????19528??2006-03-14?14:41??ModbusWIN\Debug\demo.obj

?????文件??????17661??2006-03-14?14:41??ModbusWIN\Debug\mb.obj

?????文件??????12633??2006-03-14?14:41??ModbusWIN\Debug\mbfunccoils.obj

?????文件???????1232??2006-03-14?14:41??ModbusWIN\Debug\mbfuncdiag.obj

?????文件??????10440??2006-03-14?14:41??ModbusWIN\Debug\mbfuncdisc.obj

?????文件??????13792??2006-03-14?14:41??ModbusWIN\Debug\mbfuncholding.obj

?????文件??????10339??2006-03-14?14:41??ModbusWIN\Debug\mbfuncinput.obj

?????文件??????11055??2006-03-14?14:41??ModbusWIN\Debug\mbfuncother.obj

?????文件??????12479??2006-03-14?14:41??ModbusWIN\Debug\mbtcp.obj

?????文件??????12260??2006-03-14?14:41??ModbusWIN\Debug\mbutils.obj

?????文件??????11167??2006-03-14?14:41??ModbusWIN\Debug\portevent.obj

?????文件??????18313??2006-03-14?14:41??ModbusWIN\Debug\portother.obj

?????文件??????27070??2006-03-14?14:41??ModbusWIN\Debug\porttcp.obj

?????文件?????107520??2006-03-14?14:41??ModbusWIN\Debug\vc60.idb

?????文件??????69632??2006-03-14?14:41??ModbusWIN\Debug\vc60.pdb

?????文件?????196676??2006-03-14?14:41??ModbusWIN\Debug\WIN32TCPModbus.exe

?????文件?????347512??2006-03-14?14:41??ModbusWIN\Debug\WIN32TCPModbus.ilk

?????文件?????157316??2006-03-14?14:41??ModbusWIN\Debug\WIN32TCPModbus.pch

?????文件?????656384??2006-03-14?14:41??ModbusWIN\Debug\WIN32TCPModbus.pdb

?????文件???????8895??2011-04-11?11:47??ModbusWIN\demo.cpp

?????文件??????10775??2006-03-09?13:55??ModbusWIN\mb.c

?????文件??????18361??2006-03-09?13:55??ModbusWIN\mb.h

?????文件???????5047??2006-12-08?06:10??ModbusWIN\mbconfig.h

?????文件???????3788??2006-12-08?06:10??ModbusWIN\mbframe.h

?????文件???????3232??2011-04-11?10:55??ModbusWIN\mbfunc.h

?????文件???????9907??2011-03-31?17:56??ModbusWIN\mbfunccoils.c

?????文件???????1662??2006-12-08?06:10??ModbusWIN\mbfuncdiag.c

?????文件???????4614??2007-02-19?07:48??ModbusWIN\mbfuncdisc.c

?????文件??????12255??2011-03-31?17:56??ModbusWIN\mbfuncholding.c

?????文件???????4838??2007-09-12?18:15??ModbusWIN\mbfuncinput.c

............此處省略22個文件信息

評論

共有 條評論