APIModbus/TCPDLLVersion1.
2.
0.
JiiGeneralWAGO-I/O-SYSTEM759APIModbus/TCPDLLCopyright2003byWAGOKontakttechnikGmbHAllrightsreserved.
WAGOKontakttechnikGmbHHansastrae27D-32423MindenPhone:+49(0)571/887–0Fax:+49(0)571/887–169E-Mail:info@wago.
comWeb:http://www.
wago.
comTechnicalSupportPhone:+49(0)571/887–555Fax:+49(0)571/887–8555E-Mail:support@wago.
com'SúA¨CL¨'mB§136-0071@""s]"T1-5-7"úècND^[SWp""‰@I/OO[vTEL,03-5627-2059@FAX,03-5627-2055±g—pê鉖A\tgEFA¨n[hEFA–Aê""I¤W–ìBTableofContentsiiiWAGO-I/O-SYSTEM759APIModbus/TCPDLL–1d—v–11.
1–@"I11.
1.
1'ì11.
1.
2g—p'i11.
1.
3—p"r11.
2L21.
3tH"g\L31.
4"\L31.
5—L41.
6—ê42Modbus/TCPDLL52.
1T—v52.
2C"Xg[62.
362.
3.
1MBTInit.
72.
3.
2MBTExit.
82.
3.
3MBTConnect92.
3.
4MBTDisconnect.
112.
3.
5MBTReadRegisters122.
3.
6MBTReadCoils.
142.
3.
7MBTReadExceptionStatus162.
3.
8MBTReadCompleted.
182.
3.
9MBTWriteRegisters.
192.
3.
10MBTWriteCoils.
212.
3.
11MBTWriteCompleted.
232.
3.
12MBTSwapWord.
242.
3.
13MBTSwapDWord.
252.
3.
14MODBUSTCP_TABLE_xxx.
262.
4vO‰—áiVB,Cj272.
4.
1VBA.
272.
4.
1.
1272.
4.
1.
2'è"DLL"é272.
4.
1.
3"éCx"gvV[W282.
4.
2C.
302.
4.
2.
1302.
4.
2.
2C"^[tFCX302.
4.
2.
3vO‰33340ivTableofContentsWAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM7591APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL1d—v–iC"Xg[¨X^[gAbvv'sAA"à—eB1.
1–@"I'1.
1.
1'ììB–LG·ég—pBA–|–óA"dq"Iè'iCs¤ASR"^NgeNjbNihCcj"'K—v·BA"–'Q"…—·B1.
1.
2g—p'iiAPLCvO‰~"O'i—L·éZpA"dC@íê–ZpA"K—pKin'mdC@íê–Zpw"±óKBs"KQAeSi¨'i'QASR"^NgeNjbNihCcjCB1.
1.
3—p"rg—pêéR"|[l"ge—p"r‰Aê—pn[hEFA¨\tgEFAR"tBO[V"BXAKLqsBn[hEFA\tgEFAOXAR"|[l"gKig—pêASR"^NgeNjbNihCcj"C"OèB‰VKn[hEFA\tgEFAR"tBO[V"·é—vASWp""‰B2WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL1.
2LPKKBxi_[WKB'‰~"ìmAEKBESD(ElectrostaticDischarge)"dCi_[Wx·BNote''u‰"Ig—p¨\tgEFA"K‰èq"g·BAAf[^V[gAC"^[lbgz[y[WQBWAGO-I/O-SYSTEM7593APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL1.
3tH"g\LItalict@C–ypX–'B—á:C:\programs\WAGO-IO-CHECKItalicj…[ACe''B—á:Save\j…[ACes¤êobNX‰bV…B—á:File\NewEND{^"‰B—á:ENTERL[‰B—á:CouriervO‰R[hCouriertH"gB—á:END_VAR1.
4"\LR[h—á"lDecimal100'í\LHexadecimal0x64Cê\LBinary'100''0110.
0100'V"ONH[e[V"¤1/2oCghbgé4WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL1.
5—L"i–"à—e759-312APIModbus/TCPDLL1.
6—êAIAiO"ü—AOAiOo—DIfW^"ü—DOfW^o—I/O"üo—WAGO-I/O-SYSTEM7595APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2Modbus/TCPDLL2.
1T—v±DLLModbus/TCPProtocolsBModbus/TCPDLLOS'‰BWindowsNT4.
0(fromversionSP5),Windows2000,Windows95(withWindowsSocket2.
0Update),Windows98.
TCP/IP'Ms¤*WindowsVXeWindowsSocket2.
0g—p·B±DLLV"NiXi"újAV"NiXi""új'ls·B"`'—vgRTCPUDP'I'BvO‰~"OêCVisualBASIC·BVisualBASICDLLV"NiXi"újR[s·BCDLLV"NiXi"újAA"V"NiXi""újR[—s·B±DLLModbus/TCPprotocolV1.
0.
FC1,FC2,FC3,FC4,FC7,FC15,FC16'‰BModbus/TCPe[u'lBReadWriteOutputRegisterFC3FC16InputRegisterFC4OutputCoilFC1FC15InputCoilFC2ExceptionStatusFC7±DLLPModbus/TCPfoCXRlNV""R}"hBI/OfRlNV"I[v"·éC"^[o^CB6WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL±DLLMicrosoftVisualC++6.
0J"-J"BDLL'SW…[C‰"^C"I"N·éAXL[R"|[l"c·B2.
2C"Xg[DLLt@C–MBT.
DLL·BWindowssystem32tH_Rs[Bà'tH_RsWindowsK"oB2.
3"MBT‰Cu‰'SlHRESULTtH[}bg'‰·BAPI\Pbglà±tH[}bgBMBT‰Cu‰lHRESULT_FROM_WIN32··B~A–{}j…Aq*éHRESULT_FROM_WIN32"HRfrom"Lq·BModbus/TCP.
DLL"BMBTInitMBTExitMBTConnectMBTDisconnectMBTReadRegistersMBTReadCoilsMBTReadExeptionStatusMBTReadCompletedMBTWriteRegistersMBTWriteCoilsMBTWriteCompletedMBTSwapWordMBTSwapDWordMODBUSTCP_TABLE_xxxWAGO-I/O-SYSTEM7597APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
3.
1MBTInitWAGO-I/O-PRO32ElementsofDynamicLinkLibraryí"ModbusTCP‰Cu‰‰ú"–:MBTInit^Cv:FunctionDLL–:ModbusTCP.
DLL"K—p:Modbus/TCP-Protocolé:C:LONGMBTInit(void);VB:PublicDeclareFunctionMBTInitLib"MBT"()AsLongp‰[^:R"g:––è'l:HEX'l:R"g:S_OK0MBT‰Cu‰‰ú‰÷BMBT_THREAD_CREATION_ERROR0xEF010000MBT‰Cu‰[NXbhìBHRfromWSASYSNOTREADY0x8007276Blbg[NTuVXelbg[NBHRfromWSAVERNOTSUPPORTED0x8007276CK—vWindowssocketversion2VXeBHRfromWSAEINPROGRESS0x80072734Windowssocket1.
1Q·BHRfromWSAEPROCLIM0x80072753T|[gê\PbgsXbh"''l'BB':'MBT‰Cu‰"MBTInit"R[g—pB8WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
3.
2MBTExitWAGO-I/O-PRO32ElementsofDynamicLinkLibraryí"Modbus/TCP‰Cu‰I—B"–:MBTExit^Cv:FunctionDLL–:ModbusTCP.
DLL"K—p:Modbus/TCP-Protocolé:C:LONGMBTExit(void);VB:PublicDeclareFunctionMBTExitLib"MBT"()AsLongp‰[^:R"g:––è'l:HEX'l:R"g:S_OK0MBT‰Cu‰I—÷BMBT_EXIT_TIMEOUT_ERROR0xEF010001^CAEgG‰[MBT_UNKNOWN_THREAD_EXIT_ERROR0xEF010002–'mG‰[I—B':Modbus/TCP‰Cu‰g—pI—KR[BWAGO-I/O-SYSTEM7599APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
3.
3MBTConnectWAGO-I/O-PRO32ElementsofDynamicLinkLibraryí"Modbus/TCP@í§|[gJs·B"–:MBTConnect^Cv:FunctionDLL–:ModbusTCP.
DLL"K—p:Modbus/TCP-Protocolé:C:LONGMBTConnect(INLPCTSTRszHostAddress,INWORDport,INBOOLuseTCPorUDP,INDWORDrequestTimeout,OUTHANDLE*hSocket);VB:PublicDeclareFunctionMBTConnectLib"MBT"(ByValszHostAddressAsString,ByValportAsInteger,ByValuseTCPorUDPAsLong,ByValrequestTimeoutAsLong,hSocketAsLong)AsLongp‰[^:R"g:szHostAddressModbus/TCP@íIP-AhX(—á"172.
17.
5.
91")DNS–portModbus/TCP@íIP|[gi'í502juseTCPorUDPTCP(TRUE)UDP(FALSE)requestTimeout^CAEg(msec)hSocketRlNV"n"h‰–è'l:HEX'l:R"g:S_OK0'±m—MBT_NO_ENTRY_ADDABLE_ERROR0xEF010004‰Cu‰\Pbg—G‰HRfromWSANOTINITIALISED0x8007276DMBTInitR[HRfromWSAENETDOWN0x80072742lbg[NVXeG‰HRfromWSANO_RECOVERY0x80072AFB'v–"IG‰HRfromWSAHOST_NOT_FOUND0x80072AF9w'IPAhX@íDNS–10WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLLHRfromWSATRY_AGAIN0x80072AFADNST[o[G‰[·HRfromWSAEPROTONOSUPPORTWSAEAFNOSUPPORT0x8007273B0x8007273Fw'èTCPUDPvgRT|[gBHRfromWSAEMFILE0x80072728VXe±í—\Pbg——pHRfromWSAEADDRNOTAVAIL0x80072741[gAhX–·HRfromWSAECONNREFUSED0x8007274DHRfromWSAETIMEDOUT0x8007274CRlNV"^CAEg':±"WindowssocketIuWFNgBTCPvgRMODBUS/TCPfoCX|[gB±‰Cu‰UDPvgRà—pB'±m—foCX[hA‰CgsBWAGO-I/O-SYSTEM75911APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
3.
4MBTDisconnectWAGO-I/O-PRO32ElementsofDynamicLinkLibraryí"foCXf·B"–:MBTDisconnect^Cve:FunctionDLL–:ModbusTCP.
DLL"K—p:Modbus/TCP-Protocolé:C:LONGMBTDisconnect(INHANDLEhSocket);VB:PublicDeclareFunctionMBTDisonnectLib"MBT"(ByValhSocketAsLong)AsLongp‰[^:R"g:hSocketRlNV"n"h‰–è'l:HEX'l:R"g:S_OK0'fMBT_HANDLE_INVALID_ERROR0xEF010006RlNV"n"h‰–·.
HRfromWSANOTINITIALISED0x8007276DMBTInit"R[HRfromWSAENETDOWN0x80072742lbg[NVXeG‰':MBTDisconnectfoCXf·éB12WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
3.
5MBTReadRegistersWAGO-I/O-PRO32ElementsofDynamicLinkLibraryí"WX^f[^"o·B.
"–:MBTReadRegisters^Cv:FunctionDLL–:ModbusTCP.
DLL"K—p:Modbus/TCP-Protocolé:C:LONGMBTReadRegisters(INHANDLEhSocket,INBYTEtableType,INWORDdataStartAddress,INWORDnumWords,OUTLPBYTEpReadBuffer,OPTIONALINMBTReadCompletedfpReadCompletedCallbackOPTIONALINDWORDcallbackContext);VB:PublicDeclareFunctionMBTReadRegistersLib"MBT"(ByValhSocketAsLong,ByValtableTypeAsByte,ByValdataStartAddressAsInteger,ByValnumWordsAsInteger,pReadBufferAsAny,ByValfpReadCompletedCallbackAsLong,ByValcallbackContextAsLong)AsLongp‰[^:R"g:hSocketRlNV"n"h‰tableTypeModbus/TCPtablesType(MODBUS_TABLE_xxx)INPUTWX^yOUTPUTWX^'‰iFC3,FC4jdataStartAddress"oJn'unumWords"o"pReadBuffer"oWX^i"[·éGAAV"NiXR[NULLFpReadCompletedCallbackAV"NiX[ht@"NV"R[êéCR[obNt@"NV"V"NiXR[NULLftHg).
callbackContextAV"NiXR[obNt@"NV"ó'V"NiXR[0ftHg).
–è'l:HEX'l:R"g:S_OK0íI—WAGO-I/O-SYSTEM75913APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLLMBT_HANDLE_INVALID_ERROR0xEF010006RlNV"n"h‰–·.
MBT_NO_JOB_ADDABLE_ERROR0xEF010005‰Cu‰\Pbg—G‰["-MBT_EXIT_ERROR0xEF01000BMBTExitR[èWu''fêMBT_SOCKET_TIMEOUT_ERROR0xEF010008I/OModbus/TCPR}"h'—X|"XNGXg^CAEgHRfromWSANOTINITIALISED0x8007276DMBTInitR[HRfromWSAENETDOWN0x80072742lbg[NG‰HRfromWSAENETRESETWSAECONNABORTEDWSAEDISCON0x800727440x800727450x80072746foCX~ê·.
HRfromWSAEWOULDBLOCK0x80072733'—I/O·.
HRfromWSAEFAULT0x8007271E[hobt@—Li"[QHRfromWSAENOBUFS0x80072747'ìsVXeobt@s'':p‰[^fpReadCompletedCallback"AV"NiXV"NiXsB±p‰[^NULLV"NiXANULLAV"NiXsBAV"NiXI/O'ìAR[obNt@"NV"R[I/O'ì·B"AV"NiXR[pReadBuffer–ê‰DLLi"BTheModbus/TCPR}"hFC3outputWX^AR}"hFC4inputWX^"og—pB14WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
3.
6MBTReadCoilsWAGO-I/O-PRO32ElementsofDynamicLinkLibraryí—:ThisfunctionreadsdatafromCoils.
"–:MBTReadCoils^Cv:FunctionDLL–:ModbusTCP.
DLL"K—p:Modbus/TCP-Protocolé:C:LONGMBTReadCoils(INHANDLEhSocket,INBYTEtableTypeINWORDdataStartAddress,INWORDnumBits,OUTLPBYTEpReadBuffer,OPTIONALINMBTReadCompletedfpReadCompletedCallbackOPTIONALINDWORDcallbackContext);VB:PublicDeclareFunctionMBTReadCoilsLib"MBT"(ByValhSocketAsLong,ByValtableTypeAsByte,ByValdataStartAddressAsInteger,ByValnumBitsAsInteger,pReadBufferAsAny,ByValfpReadCompletedCallbackAsLong,ByValcallbackContextAsLong)AsLongp‰[^:R"g:hSocketRlNV"n"h‰tableTypeModbus/TCPtablesTyp(MODBUS_TABLE_xxx)Applicablehere:InputcoiloroutputcoildataStartAddress"oJn'unumBits"o"pReadBuffer"o'li"[·éGAAV"NiXR[NULLfpReadCompletedCallbackAV"NiX[ht@"NV"R[êéCR[obNt@"NV"V"NiXR[NULLftHg).
callbackContextAV"NiXR[obNt@"NV"ó'V"NiXR[0ftHg).
–è'l:HEX'l:R"g:S_OK0íI—.
WAGO-I/O-SYSTEM75915APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLLMBT_HANDLE_INVALID_ERROR0xEF010006RlNV"n"h‰–·.
MBT_NO_JOB_ADDABLE_ERROR0xEF010005‰Cu‰\Pbg—G‰["-MBT_EXIT_ERROR0xEF01000BMBTExitR[èWu''fMBT_SOCKET_TIMEOUT_ERROR0xEF010008I/OModbus/TCPR}"h'—X|"XNGXg^CAEgHRfromWSANOTINITIALISED0x8007276DMBTInitR[HRfromWSAENETDOWN0x80072742lbg[NG‰HRfromWSAENETRESETWSAECONNABORTEDWSAEDISCON0x800727440x800727450x80072746foCX~ê·.
HRfromWSAEWOULDBLOCK0x80072733'—I/O·.
HRfromWSAEFAULT0x8007271E[hobt@—Li"[QHRfromWSAENOBUFS0x80072747'ìsVXeobt@s'':p‰[^fpReadCompletedCallback"AV"NiXV"NiXsB±p‰[^NULLV"NiXANULLAV"NiXsBAV"NiXI/O'ìAR[obNt@"NV"R[I/O'ì·B"AV"NiXR[pReadBuffer–ê‰DLLi"BModbus/TCPR}"hFC1outputRCAR}"hFC2inputRC"og—p·B16WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
3.
7MBTReadExceptionStatusWAGO-I/O-PRO32ElementsofDynamicLinkLibraryí"—áOXe[^X"o·"–:MBTReadExceptionStatus^Cv:FunctionDLL–:ModbusTCP.
DLL"K—p:Modbus/TCP-Protocolé:C:LONGMBTReadExceptionStatus(INHANDLEhSocket,OUTLPBYTEpReadBuffer,OPTIONALINMBTReadCompletedfpReadCompletedCallbackOPTIONALINDWORDcallbackContext);VB:PublicDeclareFunctionMBTReadExceptionStatusLib"MBT"(ByValhSocketAsLong,pReadBufferAsAny,ByValfpReadCompletedCallbackAsLong,ByValcallbackContextAsLong)AsLongp‰[^:R"g:hSocketRlNV"n"h‰pReadBuffer"o'li"[·éGAAV"NiXR[NULLfpReadCompletedCallbackAV"NiX[ht@"NV"R[êéCR[obNt@"NV"V"NiXR[NULLftHg).
callbackContextAV"NiXR[obNt@"NV"ó'V"NiXR[0ftHg).
–è'l:HEX'l:R"g:S_OK0íI—.
MBT_HANDLE_INVALID_ERROR0xEF010006RlNV"n"h‰–·MBT_NO_JOB_ADDABLE_ERROR0xEF010005‰Cu‰\Pbg—G‰["-MBT_EXIT_ERROR0xEF01000BMBTExitR[èWu''fWAGO-I/O-SYSTEM75917APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLLMBT_SOCKET_TIMEOUT_ERROR0xEF010008I/OModbus/TCPR}"h'—X|"XNGXg^CAEgHRfromWSANOTINITIALISED0x8007276DMBTInitR[HRfromWSAENETDOWN0x80072742lbg[NG‰HRfromWSAENETRESETWSAECONNABORTEDWSAEDISCON0x800727440x800727450x80072746foCX~ê·.
HRfromWSAEWOULDBLOCK0x80072733'—I/O·.
HRfromWSAEFAULT0x8007271E[hobt@—Li"[QHRfromWSAENOBUFS0x80072747'ìsVXeobt@s'':p‰[^fpReadCompletedCallback"AV"NiXV"NiXsB±p‰[^NULLV"NiXANULLAV"NiXsBAV"NiXI/O'ìAR[obNt@"NV"R[I/O'ì·B"AV"NiXR[pReadBuffer–ê‰DLLi"BModbus/TCPR}"hFC7exceptionstatus"og—pB18WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
3.
8MBTReadCompletedWAGO-I/O-PRO32ElementsofDynamicLinkLibraryíR[obN"AV"NiX"o"oB"–:MBTReadCompleted^Cv:FunctionDLL–:ModbusTCP.
DLL"K—p:Modbus/TCP-Protocolé:C:voidMBTReadCompleted(INHANDLEhSocket,INDWORDcallbackContext,INLONGerrorCode,INBYTEtableType,INWORDdataStartAddress,INWORDnumRead,INWORDnumBytes,INLPBYTEpReadBuffer);p‰[^:R"g:hSocketRlNV"n"h‰callbackContext"AV"NiXR[ó'errorCodeG‰[R[htableTypeModbus/TCPtablesTyp(MOBUSTCP_TABLE_xxx)dataStartAddress"oJn'unumRead"o"numBytes"ooCg"pReadBuffer"o'li"[–è'l:HEX'l:R"g:none':WAGO-I/O-SYSTEM75919APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
3.
9MBTWriteRegistersWAGO-I/O-PRO32ElementsofDynamicLinkLibraryí"WX^f[^'·B"–:MBTWriteRegisters^Cv:FunctionDLL–:ModbusTCP.
DLL"K—p:Modbus/TCP-Protocolé:C:LONGMBTWriteRegisters(INHANDLEhSocket,INWORDdataStartAddress,INWORDnumWords,INLPBYTEpWriteBuffer,OPTIONALINMBTWriteCompletedfpWriteCompletedCallbackOPTIONALINDWORDcallbackContext);VB:PublicDeclareFunctionMBTWriteRegistersLib"MBT"(ByValhSocketAsLong,ByValdataStartAddressAsInteger,ByValnumWordsAsInteger,pWriteBufferAsAny,ByValfpWriteCompletedCallbackAsLong,ByValcallbackContextAsLong)AsLongp‰[^:R"g:hSocketRlNV"n"h‰dataStartAddress'JnAhXnumWords'"pWriteBuffer''li"[fpWriteCompletedCallbackAV"NiX‰Cgt@"NV"R[êéCR[obNt@"NV"V"NiXR[NULLftHg).
callbackContextAV"NiXR[obNt@"NV"ó'V"NiXR[0ftHg).
–è'l:HEX'l:R"g:S_OK0íI—.
MBT_HANDLE_INVALID_ERROR0xEF010006RlNV"n"h‰–·.
MBT_NO_JOB_ADDABLE_ERROR0xEF010005‰Cu‰\Pbg—G‰["-20WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLLMBT_EXIT_ERROR0xEF01000BMBTExitR[èWu''fMBT_SOCKET_TIMEOUT_ERROR0xEF010008I/OModbus/TCPR}"h'—X|"XNGXg^CAEgHRfromWSANOTINITIALISED0x8007276DMBTInitR[HRfromWSAENETDOWN0x80072742lbg[NG‰HRfromWSAENETRESETWSAECONNABORTEDWSAEDISCON0x800727440x800727450x80072746foCX~ê·.
HRfromWSAEWOULDBLOCK0x80072733'—I/O·.
HRfromWSAEFAULT0x8007271E‰Cgobt@—Li"[QHRfromWSAENOBUFS0x80072747'ìsVXeobt@s'':p‰[^fpWriteCompletedCallback"AV"NiXV"NiXsB±p‰[^NULLV"NiXANULLAV"NiXsBAV"NiXI/OAR[obNt@"NV"R[I/O'쉷B"AV"NiXR[pReadBuffer–ê‰DLLi"BModbus/TCPR}"hFC16outputWX^'g—pB.
WAGO-I/O-SYSTEM75921APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
3.
10MBTWriteCoilsWAGO-I/O-PRO32ElementsofDynamicLinkLibraryí"RCf[^'·"–:MBTWriteCoils^Cv:FunctionDLL–:ModbusTCP.
DLL"K—p:Modbus/TCP-Protocolé:C:LONGMBTWriteCoilss(INHANDLEhSocket,INWORDdataStartAddress,INWORDnumBits,INLPBYTEpWriteBuffer,OPTIONALINMBTWriteCompletedfpWriteCompletedCallbackOPTIONALINDWORDcallbackContext);VB:PublicDeclareFunctionMBTWriteCoilsLib"MBT"(ByValhSocketAsLong,ByValdataStartAddressAsInteger,ByValnumBitsAsInteger,pWriteBufferAsAny,ByValfpWriteCompletedCallbackAsLong,ByValcallbackContextAsLong)AsLongp‰[^:R"g:hSocketRlNV"n"h‰dataStartAddress'JnAhXnumBits'"pWriteBuffer''li"[fpWriteCompletedCallbackAV"NiX‰Cgt@"NV"R[êéCR[obNt@"NV"V"NiXR[NULLftHg).
callbackContextAV"NiXR[obNt@"NV"ó'V"NiXR[0ftHg).
–è'l:HEX'l:R"g:S_OK0íI—.
MBT_HANDLE_INVALID_ERROR0xEF010006RlNV"n"h‰–·.
MBT_NO_JOB_ADDABLE_ERROR0xEF010005‰Cu‰\Pbg—G‰["-22WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLLMBT_EXIT_ERROR0xEF01000BMBTExitR[èWu''fMBT_SOCKET_TIMEOUT_ERROR0xEF010008I/OModbus/TCPR}"h'—X|"XNGXg^CAEgHRfromWSANOTINITIALISED0x8007276DMBTInitR[HRfromWSAENETDOWN0x80072742lbg[NG‰HRfromWSAENETRESETWSAECONNABORTEDWSAEDISCON0x800727440x800727450x80072746foCX~ê·.
HRfromWSAEWOULDBLOCK0x80072733'—I/O·.
HRfromWSAEFAULT0x8007271E‰Cgobt@—Li"[QHRfromWSAENOBUFS0x80072747'ìsVXeobt@s'':p‰[^fpWriteCompletedCallback"AV"NiXV"NiXsB±p‰[^NULLV"NiXANULLAV"NiXsBAV"NiXI/OAR[obNt@"NV"R[I/O'쉷B"AV"NiXR[pReadBuffer–ê‰DLLi"BModbus/TCPR}"hFC15outputWX^'g—pBWAGO-I/O-SYSTEM75923APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
3.
11MBTWriteCompletedWAGO-I/O-PRO32ElementsofDynamicLinkLibraryíR[obN"AV"NiX'"oB"–:MBTWriteCompleted^Cv:FunctionDLL–:ModbusTCP.
DLL"K—p:Modbus/TCP-Protocolé:C:voidMBTWriteCompleted(INHANDLEhSocket,INDWORDcallbackContext,INLONGerrorCode,INBYTEtableType,INWORDdataStartAddress,INWORDnumWrite,INLPBYTEpWriteBuffer);p‰[^:R"g:hSocketRlNV"n"h‰callbackContext"AV"NiXR[ó'errorCodeG‰[R[htableTypeModbus/TCPtablesTyp(MOBUSTCP_TABLE_xxx)dataStartAddress'Jn'unumWrite'"pWriteBuffer''li"[–è'l:HEX'l:R"g:none':24WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
3.
12MBTSwapWordWAGO-I/O-PRO32ElementsofDynamicLinkLibraryí"[hoCg‰oCgXbvB"–:MBTSwapWord^Cv:FunctionDLL–:ModbusTCP.
DLL"K—p:Modbus/TCP-Protocolé:C:WORDMBTSwapWord(constWORDwData);VB:PublicDeclareFunctionMBTSwapWordLib"MBT"(ByValwDataAsInteger)AsIntegerp‰[^:R"g:wData[hf[^–è'l:R"g:±"Xbv'lB':WAGO-I/O-SYSTEM75925APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
3.
13MBTSwapDWordWAGO-I/O-PRO32ElementsofDynamicLinkLibraryí"_u[hPoCg–4oCg–A2oCg–3oCg–Xbv·B"–:MBTSwapDWord^Cv:FunctionDLL–:ModbusTCP.
DLL"K—p:Modbus/TCP-Protocolé:C:DWORDMBTSwapDWord(constDWORDdwData);VB:PublicDeclareFunctionMBTSwapDWordLib"MBT"(ByValdwDataAsLong)AsLongp‰[^:R"g:dwData_u[hf[^–è'l:R"g:±"Xbv'lB':26WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
3.
14MODBUSTCP_TABLE_xxxMODBUSTCP_TABLE_xxxQB'è`'lOutputRegisterMODBUSTCP_TABLE_OUTPUT_REGISTER4InputRegisterMODBUSTCP_TABLE_INPUT_REGISTER3OutputCoilMODBUSTCP_TABLE_OUTPUT_COIL0InputCoilMODBUSTCP_TABLE_INPUT_COIL1ExceptionStatusMODBUSTCP_TABLE_EXCEPTION_STATUS7WAGO-I/O-SYSTEM75927APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
4vO‰—áiVB,Cj2.
4.
1VBA2.
4.
1.
1‰àVisualBASICT"vvO‰1tH[btnReadCoil,btnWriteCoil,btnReadRegisterandbtnWriteRegisterR}"h{^"AdrCoil,edtReadCoil,edtWriteCoil,AdrRegister,edtReadRegister,edtWriteRegistereLXg{bNXBModbus/TCPDLL‰ú'èm[htH[I[v"ZbgAbvBANeBuAhXeLXg{bNXAdrCoilyAdrRegister"üêBR}"h{^"btnReadCoilybtnReadRegisterNbN·éeLXg{bNXedtReadCoilyedtReadRegister\BR}"h{^"btnWriteCoilyBtnWriteRegisterNbN·éeLXg{bNXedtWriteCoilyedtWriteRegisterlo—B±êCx"gvV[W{^"NbNCx"gè·BtH[m[hfêModbus/TCPDLLàI—B2.
4.
1.
2'è"DLL"é'è"ConstMODBUSTCP_TABLE_OUTPUT_REGISTER=4ConstMODBUSTCP_TABLE_INPUT_REGISTER=3ConstMODBUSTCP_TABLE_OUTPUT_COIL=0ConstMODBUSTCP_TABLE_INPUT_COIL=1ConstMODBUSTCP_TABLE_EXCEPTION_STATUS=7DLL"PublicDeclareFunctionMBTInitLib"MBT"()AsLongPublicDeclareFunctionMBTExitLib"MBT"()AsLongPublicDeclareFunctionMBTConnectLib"MBT"(ByValszHostAddressAsString,By-ValportAsInteger,ByValuseTCPorUDPAsLong,ByValrequestTimeoutAsLong,hSocketAsLong)AsLongPublicDeclareFunctionMBTDisconnectLib"MBT"(ByValhSocketAsLong)AsLongPublicDeclareFunctionMBTReadRegistersLib"MBT"(ByValhSocketAsLong,ByValtableTypeAsByte,ByValdataStartAddressAsInteger,ByValnumWordsAsInteger,pReadBufferAsAny,ByValfpReadCompletedCallbackAsLong,ByValcallbackContextAsLong)AsLongPublicDeclareFunctionMBTReadCoilsLib"MBT"(ByValhSocketAsLong,ByValta-bleTypeAsByte,ByValdataStartAddressAsInteger,ByValnumBitsAsInteger,pReadBufferAsAny,ByValfpReadCompletedCallbackAsLong,ByValcallbackContextAsLong)AsLongPublicDeclareFunctionMBTReadExceptionStatusLib"MBT"(ByValhSocketAsLong,pExceptionStatusAsByte,ByValfpReadCompletedCallbackAsLong,ByValcallback-ContextAsLong)AsLongPublicDeclareFunctionMBTWriteRegistersLib"MBT"(ByValhSocketAsLong,ByValdataStartAddressAsInteger,ByValnumWordsAsInteger,pWriteBufferAsAny,By-ValfpWriteCompletedCallbackAsLong,ByValcallbackContextAsLong)AsLongPublicDeclareFunctionMBTWriteCoilsLib"MBT"(ByValhSocketAsLong,ByVal28WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLLdataStartAddressAsInteger,ByValnumBitsAsInteger,pWriteBufferAsAny,ByValfpWriteCompletedCallbackAsLong,ByValcallbackContextAsLong)AsLongPublicDeclareFunctionMBTSwapWordLib"MBT"(ByValwDataAsInteger)AsIntegerPublicDeclareFunctionMBTSwapDWordLib"MBT"(ByValdwDataAsLong)AsLong2.
4.
1.
3"éCx"gvV[W\globalvariablesandconstantsConstg_MBusIPAsString="172.
17.
5.
91"Constg_PortAsLong=502Dimg_hSocketAsLongbtnReadCoilPrivateSubbtnReadCoil_Click()DiminpValAsByteDimadrAsIntegerinpVal=0adr=CInt(AdrCoil.
Text)ret=MBTReadCoils(g_hSocket,_MODBUSTCP_TABLE_OUTPUT_COIL,_adr,_1,_inpVal,_0,_0)edtReadCoil.
Text=inpValEndSubbtnReadRegisterPrivateSubbtnReadRegister_Click()DiminpValAsIntegerDimadrAsIntegerinpVal=0adr=CInt(AdrRegister.
Text)ret=MBTReadRegisters(g_hSocket,_MODBUSTCP_TABLE_OUTPUT_REGISTER,_adr,_1,_inpVal,_0,_0)inpVal=MBTSwapWord(inpVal)edtReadRegister.
Text=inpValEndSubbtnWriteCoilPrivateSubbtnWriteCoil_Click()DimoutValAsByteDimadrAsIntegeroutVal=CByte(edtWriteCoil.
Text)adr=CInt(AdrCoil.
Text)ret=MBTWriteCoils(g_hSocket,_adr,_1,_outVal,_0,_0)EndSubbtnWriteRegisterWAGO-I/O-SYSTEM75929APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLLPrivateSubbtnWriteRegister_Click()DimoutValAsIntegerDimadrAsIntegeroutVal=CInt(edtWriteRegister.
Text)outVal=MBTSwapWord(outVal)adr=CInt(AdrRegister.
Text)ret=MBTWriteRegisters(g_hSocket,_adr,_1,_outVal,_0,_0)EndSubformPrivateSubForm_Load()DimretAsLongMBTInitret=MBTConnect(g_MBusIP,g_Port,True,1000,g_hSocket)If(ret0)ThenMBTExitMsgBox"Couldn'tconnecttoMBDevice:0x"&Hex(ret)UnloadMeExitSubEndIfEndSubPrivateSubForm_Unload(CancelAsInteger)MBTDisconnect(g_hSocket)MBTExitEndSub30WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
4.
2C2.
4.
2.
1‰àCvO‰—áADLLMBTInit"‰úMBTConnect"ZbgAbvB'±÷A"üo—s"o"MBTWriteRegistersAMBTReadRegistersAMBTWriteCoilsAMBTReadCoils¨MBTReadExceptionStatusAV"NiXR[B'"o"V"NiXR[Bó'e@"\R[j^[\BvO‰MBTDisconnectèm[hfMBTExitDLLI—B2.
4.
2.
2C"^[tFCX#ifndef_MBT_H_#define_MBT_H_#ifdef__cplusplusextern"C"{#endif#defineMODBUSTCP_TABLE_OUTPUT_REGISTER4#defineMODBUSTCP_TABLE_INPUT_REGISTER3#defineMODBUSTCP_TABLE_OUTPUT_COIL0#defineMODBUSTCP_TABLE_INPUT_COIL1#defineMODBUSTCP_TABLE_EXCEPTION_STATUS7//TypeDefinitions|typedefvoid(WINAPI*MBTReadCompleted)(INHANDLEhSocket,//sockethandleINDWORDcallbackContext,//callbackcontext,handedoveratthecallINLONGerrorCode,//resultofthereadoperationINBYTEtableType,//typeofMODBUS/TCPtables(MODBUSTCP_TABLE_xxx)INWORDdataStartAddress,//startaddressoftheregistersorcoilstobe//readINWORDnumRead,//numberoftheregistersorcoilstobereadINWORDnumBytes,//numberofthebytestobereadINLPBYTEpReadBuffer//memorysectionwiththedatatobewritten);typedefvoid(WINAPI*MBTWriteCompleted)(INHANDLEhSocket,//sockethandleINDWORDcallbackContext,//callbackcontext,handedoveratthecallINLONGerrorCode,//resultofthewriteoperationINBYTEtableType,//typeofMODBUS/TCPtables(MODBUSTCP_TABLE_xxx)//outputregistersoroutputcoilsINWORDdataStartAddress,//startaddressoftheregistersorcoilstobeWAGO-I/O-SYSTEM75931APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL//writtenINWORDnumWrite,//numberoftheregistersorcoilstobewrittenINLPBYTEpWriteBuffer//memorysectionwiththedatatobewritten);//Prototypes|//initializestheMODBUS/TCPlibraryLONGWINAPIMBTInit();//terminatestheMODBUS/TCPlibraryLONGWINAPIMBTExit();//createsasocketandconnectsittothegivendeviceportLONGWINAPIMBTConnect(INLPCTSTRszHostAddress,//TCP/IPaddressofdeviceINWORDport,//TCPportindeviceforcommunicationINBOOLuseTCPorUDP,//TRUE-TCP;FALSE-UDPINDWORDrequestTimeout,//maximaltimeformanaginganI/Orequest(ms)OUTHANDLE*hSocket//handleoftheconnectedsocket);//abortstheconnectiontoadeviceandreleasesthesocketLONGWINAPIMBTDisconnect(INHANDLEhSocket//handleoftheconnectedsocket);//readfromaconnectedsocketLONGWINAPIMBTReadRegisters(INHANDLEhSocket,//handleoftheconnectedsocketINBYTEtableType,//Modbus/TCPTabellenTyp(MODBUSTCP_TABLE_xxx)//(here:inputregisteroroutputregisterINWORDdataStartAddress,//startaddressoftheregisterstobereadINWORDnumWords,//numberoftheregisterstobereadOUTLPBYTEpReadBuffer,//memorysectionfromwhichthedataareread//(NULLatasynchronouscall)OPTIONALINMBTReadCompletedfpReadCompletedCallback=NULL,//C-callbackfunction,calledaftertermination//ofasynchronousreading(NULLatsynchronous//call)OPTIONALINDWORDcallbackContext=0//context,handedovertotheasynchronous//(callbackfunction(0atsynchronouscall));//writetoaconnectedsocketLONGWINAPIMBTWriteRegisters(INHANDLEhSocket,//handleoftheconnectedsocketINWORDdataStartAddress,//startaddressoftheregisterstobewrittenINWORDnumWords,//numberoftheregisterstobewrittenINLPBYTEpWriteBuffer,//memorysectionfromwhichthedataarewritten//(NULLatasynchronouscall)OPTIONALINMBTWriteCompletedfpWriteCompletedCallback=NULL,//C-callbackfunction,calledaftertermination//ofasynchronouswriting(NULLatsynchronous//call)OPTIONALINDWORDcallbackContext=0//context,handedovertotheasynchronous//(callbackfunction(0atsynchronouscall)32WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL);//readfromaconnectedsocketLONGWINAPIMBTReadCoils(INHANDLEhSocket,//handleoftheconnectedsocketINBYTEtableType,//Modbus/TCPTabellenTyp(MODBUSTCP_TABLE_xxx)//(here:inputcoiloroutputcoilINWORDdataStartAddress,//startaddressofthecoilstobereadINWORDnumBits,//numberofthecoilstobereadOUTLPBYTEpReadBuffer,//memorysectionfromwhichthedataareread//(NULLatasynchronouscall)OPTIONALINMBTReadCompletedfpReadCompletedCallback=NULL,//C-callbackfunction,calledaftertermination//ofasynchronousreading(NULLatsynchronous//call)OPTIONALINDWORDcallbackContext=0//context,handedovertotheasynchronous//(callbackfunction(0atsynchronouscall));//writetoaconnectedsocketLONGWINAPIMBTWriteCoils(INHANDLEhSocket,//handleoftheconnectedsocketINWORDdataStartAddress,//startaddressofthecoilstobewrittenINWORDnumBits,//numberofthecoilstobewrittenINLPBYTEpWriteBuffer,//memorysectionfromwhichthedataarewritten//(NULLatasynchronouscall)OPTIONALINMBTWriteCompletedfpWriteCompletedCallback=NULL,//C-callbackfunction,calledaftertermination//ofasynchronouswriting(NULLatsynchronous//call)OPTIONALINDWORDcallbackContext=0//context,handedovertotheasynchronous//(callbackfunction(0atsynchronouscall));//readfromaconnectedsocketLONGWINAPIMBTReadExceptionStatus(INHANDLEhSocket,//handleoftheconnectedsocketOUTLPBYTEpExceptionStatus,//memorysectionfromwhichthedataareread//(NULLatasynchronouscall)OPTIONALINMBTReadCompletedfpReadCompletedCallback=NULL,//C-callbackfunction,calledaftertermination//ofasynchronousreading(NULLatsynchronous//call)OPTIONALINDWORDcallbackContext=0//context,handedovertotheasynchronous//(callbackfunction(0atsynchronouscall));WORDWINAPIMBTSwapWord(constWORDwData);DWORDWINAPIMBTSwapDWord(constDWORDdwData);#ifdef__cplusplus}#endif#endifWAGO-I/O-SYSTEM75933APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL2.
4.
2.
3vO‰#include#include#include#include#include"MBT.
h"#defineDEFAULT_PORT502#defineDEFAULT_SERVER_NAME_T("172.
17.
5.
90")#defineDEFAULT_PROTOCOLTRUE/*TCP*/#defineDEFAULT_REQUEST_TIMEOUT1000/*inms*/LONGret;charpWriteBuffer[]="Thisisasmalltestmessage.
\n";boolreceived;voidWINAPIrcb(INHANDLEhSocket,//sockethandleINDWORDcallbackContext,//callbackcontext,handedoveratthecallINLONGerrorCode,//resultofthereadoperationINBYTEtableType,//typeofMODBUS/TCPtables(MODBUSTCP_TABLE_xxx)INWORDdataStartAddress,//startaddressoftheregistersorcoilstobe//readINWORDnumRead,//numberoftheregistersorcoilstobereadINWORDnumBytes,//numberofthebytestobereadINLPBYTEpReadBuffer//memorysectionwiththedatatobewritten){inti;printf("\nreadcallbackcalled:\n""\tcontext:%lu\n""\terrorcode:%ld\n""\ttabletype:%d\n""\tdatastartaddress:%d\n""\tnumberofreadregisters/coils:%d\n""\tnumberofreadbytes:%d\n""\treadbytes:",callbackContext,errorCode,tableType,dataStartAddress,numRead,numBytes);if(errorCode==S_OK){for(i=0;i!
\n");scanf("%c",&ch);Synccallsif(ret==S_OK){printf("\n\n\n*Synccallsn\n");ret=MBTWriteRegisters(hSocket,0x0000,3,(LPBYTE)pWriteBuffer2,NULL,0);}if(ret==S_OK){ret=MBTReadRegisters(38WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLLhSocket,MODBUSTCP_TABLE_OUTPUT_REGISTER,0x0200,3,pReadBuffer,NULL,0);}if(ret==S_OK){printf("\nWrite/Readregisters:");for(i=0;i!
\n");scanf("%c",&ch);return0;}40BWAGO-I/O-SYSTEM759APIModbus/TCPDLL3DDeclarationofconstantsandfunctionsoftheDLL27Declarationofvariablesandevent-proceduresoftheform.
28Description.
27,30EExamples.
27FFunctions.
6IInstallation.
6Interface30MMBTConnect.
9MBTDisconnect.
11MBTExit8MBTInit7MBTReadCoils14MBTReadCompleted.
18MBTReadExceptionStatus16MBTReadRegisters.
12MBTSwapDWord.
25MBTSwapWord.
24MBTWriteCoils21MBTWriteCompleted.
23MBTWriteRegisters.
19Modbus/TCPDLL5MODBUSTCP_TABLE_xxx.
26OOverview.
5PProgram.
33VVBA2741WAGO-I/O-SYSTEM759APIModbus/TCPDLLWAGO-I/O-SYSTEM759APIModbus/TCPDLL
轻云互联成立于2018年的国人商家,广州轻云互联网络科技有限公司旗下品牌,主要从事VPS、虚拟主机等云计算产品业务,适合建站、新手上车的值得选择,香港三网直连(电信CN2GIA联通移动CN2直连);美国圣何塞(回程三网CN2GIA)线路,所有产品均采用KVM虚拟技术架构,高效售后保障,稳定多年,高性能可用,网络优质,为您的业务保驾护航。官方网站:点击进入广州轻云网络科技有限公司活动规则:1.用户购...
95idc是一家香港公司,主要产品香港GIA线路沙田CN2线路独服,美国CERA高防服务器,日本CN2直连服务器,即日起,购买香港/日本云主机,在今年3月份,95IDC推出来一款香港物理机/香港多ip站群服务器,BGP+CN2线路终身7折,月付350元起。不过今天,推荐一个价格更美的香港物理机,5个ip,BGP+CN2线路,月付299元起,有需要的,可以关注一下。95idc优惠码:优惠码:596J...
CloudCone针对中国农历新年推出了几款特别套餐, 其中2019年前注册的用户可以以13.5美元/年的价格购买一款1G内存特价套餐,以及另外提供了两款不限制注册时间的用户可购买年付套餐。CloudCone是Quadcone旗下成立于2017年的子品牌,提供VPS及独立服务器租用,也是较早提供按小时计费VPS的商家之一,支持使用PayPal或者支付宝等付款方式。下面列出几款特别套餐配置信息。CP...
browseui.dll为你推荐
1f20;BACKGROUND-COLOR:#4ae2f7">16-bit设置media支持ipad流量支付宝127.0.0.1DNS老是被修改为127.0.0.1,这是为什么?css选择器CSS中选择器包括 A,超文本标记选择器 B,类选择器 C,标签选择器 D,ID选择器迅雷雷鸟雷鸟手机怎么样routeaddroute add 添加路由的命令,内网和外网如何同时上chrome17谷歌浏览器和谷歌浏览器稳定版有什么区别winrar5.0winrar压缩3种格式分别有什么区别
网络域名 新网域名解析 免费域名跳转 便宜建站 permitrootlogin http500内部服务器错误 上海域名 idc是什么 域名接入 南通服务器 linux服务器维护 网站加速软件 沈阳主机托管 万网空间 lamp什么意思 云销售系统 石家庄服务器 腾讯云平台 windowssever2008 美国十大啦 更多