• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 

Can not use ModBus by Socket,Why?

Started by sxbug, October 07, 2018, 06:16:23 am

Previous topic - Next topic

sxbug

Hi:
I just use ModBus DEMO to connect my plc and tested it again , found that there is something wrong with the DEMO you provided. I read PLC X0-X7 ,total 8 inputs, and I can read X6 =True (address = 6 )by poll mode. But I can NOT read it in 'read 'mode, all coils= false. Other parameters remain unchanged.

other test:

first input =0   count of inputs=7       X6=true
first input =1   count of inputs=6      X6=true
first input =2   count of inputs=5       X6=true
first input =3   count of inputs=4       X6=true
first input =4   count of inputs=3       X6=False
first input =5   count of inputs=2       X6=False

Why?

Thanks

sxbug

I had set deviceID=1, test above operation(I found any deviceID is same),  But only 'poll' mode read back data ,  the 'read' mode can not read back any data.

Roman Novgorodov

Hello

About timeout after last reply:
You can ignore this event if there are no active requests to device. We will fix this trouble in the future version.

About "poll" mode and single read:

Please take a look into ModbusDemo sources.
Poll button and read button call the same class methods. They differs by the last param (poll) only.
Please switch Log level into debug and make some requests.
And post here LOG file.
Maybe we will see what are you doing wrong.

Roman Novgorodov
DeepSoftware llc

DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

sxbug

[09:34:32.068]rec←â--†00 01 00 00 00 06 07 01 00 06 00 01      //read mode
[09:34:49.083]rec←â--†00 02 00 00 00 06 07 02 00 05 00 03      //poll mode
[09:34:51.099]rec←â--†00 03 00 00 00 06 07 02 00 05 00 03

Above is Modbus demo send to PLC msg




[09:37:58.941]sendâ†'â--‡00 01 00 00 00 06 07 01 00 06 00 01     //Demo send to PLC  'read'
[09:37:58.956]rec←â--†00 01 00 00 00 04 07 01 01 00                //PLC answer
[09:38:35.329]sendâ†'â--‡00 02 00 00 00 06 07 02 00 05 00 03    //Demo send to PLC  'poll'
[09:38:35.344]rec←â--†00 02 00 00 00 04 07 02 01 02               //PLC answer

Above is PLC send to ModBus prog msg

Hope to be helpful, I have been unable to create log files, so send you some communication data first. Thank you

sxbug

I  can't create a log file. What can I do?            Do you have a solution?
Thanks

Roman Novgorodov

Hello

In your case "poll mode" uses ReadInputs(...) method and
"read action" uses ReadCoils(...) method.

Therefore you get differ result.

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

sxbug

hi
  My idea is to use your ModBus DEMO program to read the PLC, if read back datas,  then to design my program.           Maybe I make a mistake ? I'll check again.            Thank you

     sxbug

sxbug

I can read X6 = True with a large number of readinput polls mode( count of inputs>3  ), but I can't read it with a small number of readinput polls. What's the problem?

sxbug

PLC‘s input :X0-X5=False   X6=True    X7-X12=False

sxbug

I tested read mode again to  read X6. The communication strings are all correct. Maybe there should be a problem with Modbus parsing. I'll send the debug data up and show you.

sxbug

Thread Start: Thread ID: 424. Process ModbusDemo.exe (7588)
Process Start: D:\Program Files (x86)\Embarcadero\Studio\19.0\lib\nrComm Lib\Demos\Modbus\ModbusDemo.exe. Base Address: $00400000. Process ModbusDemo.exe (7588)
Module Load: ModbusDemo.exe. Has Debug Info. Base Address: $00400000. Process ModbusDemo.exe (7588)
Module Load: ntdll.dll. No Debug Info. Base Address: $76ED0000. Process ModbusDemo.exe (7588)
Module Load: KERNEL32.dll. No Debug Info. Base Address: $76D20000. Process ModbusDemo.exe (7588)
Module Load: KERNELBASE.dll. No Debug Info. Base Address: $75EF0000. Process ModbusDemo.exe (7588)
Module Load: apphelp.dll. No Debug Info. Base Address: $62030000. Process ModbusDemo.exe (7588)
Thread Start: Thread ID: 10896. Process ModbusDemo.exe (7588)
Thread Start: Thread ID: 5836. Process ModbusDemo.exe (7588)
Module Load: SHELL32.dll. No Debug Info. Base Address: $75960000. Process ModbusDemo.exe (7588)
Module Load: WINSPOOL.DRV. No Debug Info. Base Address: $74030000. Process ModbusDemo.exe (7588)
Module Load: COMCTL32.dll. No Debug Info. Base Address: $71E60000. Process ModbusDemo.exe (7588)
Module Load: msvcrt.dll. No Debug Info. Base Address: $760F0000. Process ModbusDemo.exe (7588)
Module Load: msvcrt.dll. No Debug Info. Base Address: $00B20000. Process ModbusDemo.exe (7588)
Module Load: msvcrt.dll. No Debug Info. Base Address: $00BE0000. Process ModbusDemo.exe (7588)
Module Unload: msvcrt.dll. Process ModbusDemo.exe (7588)
Module Unload: msvcrt.dll. Process ModbusDemo.exe (7588)
Thread Start: Thread ID: 5932. Process ModbusDemo.exe (7588)
Module Load: CFGMGR32.dll. No Debug Info. Base Address: $75EB0000. Process ModbusDemo.exe (7588)
Module Load: combase.dll. No Debug Info. Base Address: $76320000. Process ModbusDemo.exe (7588)
Module Load: combase.dll. No Debug Info. Base Address: $00C20000. Process ModbusDemo.exe (7588)
Module Unload: combase.dll. Process ModbusDemo.exe (7588)
Module Load: ucrtbase.dll. No Debug Info. Base Address: $76650000. Process ModbusDemo.exe (7588)
Module Load: ucrtbase.dll. No Debug Info. Base Address: $00C20000. Process ModbusDemo.exe (7588)
Module Load: GDI32.dll. No Debug Info. Base Address: $75930000. Process ModbusDemo.exe (7588)
Module Unload: ucrtbase.dll. Process ModbusDemo.exe (7588)
Module Load: gdi32full.dll. No Debug Info. Base Address: $761B0000. Process ModbusDemo.exe (7588)
Module Load: SHCORE.dll. No Debug Info. Base Address: $75460000. Process ModbusDemo.exe (7588)
Module Load: RPCRT4.dll. No Debug Info. Base Address: $748B0000. Process ModbusDemo.exe (7588)
Module Load: msvcp_win.dll. No Debug Info. Base Address: $76780000. Process ModbusDemo.exe (7588)
Module Load: SspiCli.dll. No Debug Info. Base Address: $74540000. Process ModbusDemo.exe (7588)
Module Load: Windows.Storage.dll. No Debug Info. Base Address: $74E60000. Process ModbusDemo.exe (7588)
Module Load: CRYPTBASE.dll. No Debug Info. Base Address: $74530000. Process ModbusDemo.exe (7588)
Module Load: USER32.dll. No Debug Info. Base Address: $75630000. Process ModbusDemo.exe (7588)
Module Load: SECHOST.dll. No Debug Info. Base Address: $74620000. Process ModbusDemo.exe (7588)
Module Load: win32u.dll. No Debug Info. Base Address: $74570000. Process ModbusDemo.exe (7588)
Module Load: bcryptPrimitives.dll. No Debug Info. Base Address: $768A0000. Process ModbusDemo.exe (7588)
Module Load: ADVAPI32.dll. No Debug Info. Base Address: $74DE0000. Process ModbusDemo.exe (7588)
Module Load: AppCore.dll. No Debug Info. Base Address: $74560000. Process ModbusDemo.exe (7588)
Module Load: profapi.dll. No Debug Info. Base Address: $74590000. Process ModbusDemo.exe (7588)
Module Load: bcrypt.dll. No Debug Info. Base Address: $76E10000. Process ModbusDemo.exe (7588)
Module Load: POWRPROF.dll. No Debug Info. Base Address: $745C0000. Process ModbusDemo.exe (7588)
Module Load: PROPSYS.dll. No Debug Info. Base Address: $73B90000. Process ModbusDemo.exe (7588)
Module Load: IPHLPAPI.DLL. No Debug Info. Base Address: $74370000. Process ModbusDemo.exe (7588)
Module Load: SHLWAPI.dll. No Debug Info. Base Address: $76600000. Process ModbusDemo.exe (7588)
Module Load: OLEAUT32.dll. No Debug Info. Base Address: $746A0000. Process ModbusDemo.exe (7588)
Module Load: CRYPTSP.dll. No Debug Info. Base Address: $76B40000. Process ModbusDemo.exe (7588)
Module Load: ole32.dll. No Debug Info. Base Address: $757D0000. Process ModbusDemo.exe (7588)
Module Load: VERSION.dll. No Debug Info. Base Address: $74010000. Process ModbusDemo.exe (7588)
Module Load: NETAPI32.dll. No Debug Info. Base Address: $73DF0000. Process ModbusDemo.exe (7588)
Module Load: WSOCK32.dll. No Debug Info. Base Address: $74020000. Process ModbusDemo.exe (7588)
Module Load: WS2_32.dll. No Debug Info. Base Address: $765A0000. Process ModbusDemo.exe (7588)
Module Load: netutils.dll. No Debug Info. Base Address: $73DD0000. Process ModbusDemo.exe (7588)
Module Load: IMM32.dll. No Debug Info. Base Address: $76910000. Process ModbusDemo.exe (7588)
Module Load: MSCTF.dll. No Debug Info. Base Address: $754F0000. Process ModbusDemo.exe (7588)
Module Load: UxTheme.dll. No Debug Info. Base Address: $73350000. Process ModbusDemo.exe (7588)
Module Load: dwmapi.dll. No Debug Info. Base Address: $71E30000. Process ModbusDemo.exe (7588)
Module Load: CRYPT32.dll. No Debug Info. Base Address: $769A0000. Process ModbusDemo.exe (7588)
Module Load: MSASN1.dll. No Debug Info. Base Address: $76990000. Process ModbusDemo.exe (7588)
Module Load: WTSAPI32.dll. No Debug Info. Base Address: $73E70000. Process ModbusDemo.exe (7588)
Module Load: WINSTA.dll. No Debug Info. Base Address: $73E20000. Process ModbusDemo.exe (7588)
Module Load: SETUPAPI.dll. No Debug Info. Base Address: $74970000. Process ModbusDemo.exe (7588)
Module Load: DEVOBJ.dll. No Debug Info. Base Address: $74270000. Process ModbusDemo.exe (7588)
Module Load: WINTRUST.dll. No Debug Info. Base Address: $76940000. Process ModbusDemo.exe (7588)
Module Load: TextInputFramework.dll. No Debug Info. Base Address: $672E0000. Process ModbusDemo.exe (7588)
Module Load: CoreMessaging.dll. No Debug Info. Base Address: $674B0000. Process ModbusDemo.exe (7588)
Module Load: CoreUIComponents.dll. No Debug Info. Base Address: $66FD0000. Process ModbusDemo.exe (7588)
Module Load: NTMARTA.dll. No Debug Info. Base Address: $742E0000. Process ModbusDemo.exe (7588)
Module Load: WinTypes.dll. No Debug Info. Base Address: $6FBA0000. Process ModbusDemo.exe (7588)
Module Load: WinTypes.dll. No Debug Info. Base Address: $05110000. Process ModbusDemo.exe (7588)
Module Unload: WinTypes.dll. Process ModbusDemo.exe (7588)
Module Load: CLBCatQ.DLL. No Debug Info. Base Address: $76800000. Process ModbusDemo.exe (7588)
Module Load: MsctfUIManager.dll. No Debug Info. Base Address: $62FC0000. Process ModbusDemo.exe (7588)
Module Load: DUI70.dll. No Debug Info. Base Address: $62E50000. Process ModbusDemo.exe (7588)
Thread Start: Thread ID: 2452. Process ModbusDemo.exe (7588)
Module Load: DUser.dll. No Debug Info. Base Address: $62DD0000. Process ModbusDemo.exe (7588)
Thread Start: Thread ID: 1732. Process ModbusDemo.exe (7588)
Module Load: UIAutomationCore.DLL. No Debug Info. Base Address: $62BE0000. Process ModbusDemo.exe (7588)
Module Load: Bcp47Langs.dll. No Debug Info. Base Address: $67460000. Process ModbusDemo.exe (7588)
Thread Start: Thread ID: 3372. Process ModbusDemo.exe (7588)
Thread Start: Thread ID: 7228. Process ModbusDemo.exe (7588)
Thread Start: Thread ID: 3320. Process ModbusDemo.exe (7588)
Thread Start: Thread ID: 3460. Process ModbusDemo.exe (7588)
Module Load: sxs.dll. No Debug Info. Base Address: $73B00000. Process ModbusDemo.exe (7588)
Debug Output:
mincore\com\oleaut32\dispatch\ups.cpp(2125)\OLEAUT32.dll!746BDA18: (caller: 746BBCCF) ReturnHr(1) tid(994) 8002801D åº"没有注册ã€,

Process ModbusDemo.exe (7588)
Module Load: UIAnimation.dll. No Debug Info. Base Address: $62BA0000. Process ModbusDemo.exe (7588)
Module Load: OLEACC.dll. No Debug Info. Base Address: $62B40000. Process ModbusDemo.exe (7588)
Thread Start: Thread ID: 9280. Process ModbusDemo.exe (7588)
Module Load: XmlLite.dll. No Debug Info. Base Address: $72070000. Process ModbusDemo.exe (7588)
Module Load: DWrite.dll. No Debug Info. Base Address: $65B70000. Process ModbusDemo.exe (7588)
Module Unload: XmlLite.dll. Process ModbusDemo.exe (7588)
Module Load: MSWSOCK.dll. No Debug Info. Base Address: $73D70000. Process ModbusDemo.exe (7588)
Thread Start: Thread ID: 6056. Process ModbusDemo.exe (7588)
Debug Output: [2019/2/21 9:35:32 +276] nrComm Lib v9.52 Pro Windows  [10.0.17763]  Process ModbusDemo.exe (7588)
Debug Output: [2019/2/21 9:35:32 +282] nrSocket: 已开启: 192.168.0.6 : 502 server模式: 0 Process ModbusDemo.exe (7588)
Debug Output: [2019/2/21 9:35:32 +287] nrModbus: Medium Opened Process ModbusDemo.exe (7588)
Debug Output: [2019/2/21 9:35:32 +291] nrModbus: Slave = False TCP = True Process ModbusDemo.exe (7588)
Debug Output: [2019/2/21 9:35:36 +943] nrModbus: ReadInput 0006 count: 1 addr:01 Process ModbusDemo.exe (7588)
Debug Output: [2019/2/21 9:35:36 +947] nrModbus: Send request/reply !!!! ....  Process ModbusDemo.exe (7588)
Debug Output: [2019/2/21 9:35:36 +952] nrModbus: DoDataSend: 12 bytes Process ModbusDemo.exe (7588)
Debug Output: [2019/2/21 9:35:36 +960] nrSocket: Input data length: 10 [00 01 00 00 00 04 01 02 01 01 ] Process ModbusDemo.exe (7588)
Debug Output: [2019/2/21 9:35:36 +964] nrModbus: DataPacket is detected: Read input statuses Process ModbusDemo.exe (7588)
Debug Output: [2019/2/21 9:35:36 +969] nrModbus: Handle REPLY ... Process ModbusDemo.exe (7588)
Debug Output: [2019/2/21 9:35:36 +974] nrModbus: Modbus device #1 is connected. Process ModbusDemo.exe (7588)
Source Breakpoint at $00602664: D:\Program Files (x86)\Embarcadero\Studio\19.0\lib\nrComm Lib\Demos\Modbus\MainUnit.pas line 215. Process ModbusDemo.exe (7588)
Thread Exit: Thread ID: 3460. Process ModbusDemo.exe (7588)

sxbug

Hi
  Do you repeat the mistakes I found? Thank you