Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To scrape a real PLC in realtime and use that data to create NEW updating server #250

Closed
MazoSergey opened this issue Dec 5, 2017 · 12 comments

Comments

@MazoSergey
Copy link

Versions

  • Python: 2.7
  • OS: Linux
  • Pymodbus: 1.3.2
  • Modbus Hardware (if used): RSIM

Description

I am trying to make a clone of a real PLC with a help of Scraper example, and then use that data to create MODBUS server... If i understand correct I have to: scrape a real PLC --> save the data to file --> create server --> load data from file to server. It looks like I do not understand how this staff works :( If it is possible please help me, may be some examples of this kind of data flow. Thank you!

Code and Logs

 # code and logs here.
@dhoomakethu
Copy link
Contributor

@MazoSergey what exactly is the problem ? Did you run the scraper example agains the PLC and encountered any error ?

@MazoSergey
Copy link
Author

@dhoomakethu thank you for support! Yes, I tried to run example, I've got a file (dump of data from PLC). Now I am trying to run "Modbus Simulator Example" with -c option, and getting "Configuration Error: Invalid Configuration" :(

@dhoomakethu
Copy link
Contributor

Could you upload the saved the configuration here please ?

@MazoSergey
Copy link
Author

For sure! Here it is:
conf.txt

@rahulraghu94
Copy link
Contributor

rahulraghu94 commented Dec 6, 2017

Hello @MazoSergey,

Could you please try this branch on your config file?
It contains a fix that worked. Please let us know :)

(modbus) [~/pymodbus/examples/contrib]$ python modbus-simulator.py -D -c ~/pymodbus/examples/contrib/conf.txt *[dev]
<class 'pymodbus.datastore.context.ModbusSlaveContext'>
INFO:pymodbus.server.async:Starting Modbus TCP Server on :5030
DEBUG:pymodbus.server.async:Starting in Main thread

@MazoSergey
Copy link
Author

Hello @rahulraghu94,
Thank you very much guys for your support. I tried to use an updated modbus-simulator. Now it is started, but it seems that simulator does not take correct date from map dump. I've make a dump of PLC with 400001 = 111, 400002 = 222, but in simulator i see only zeros :(

@rahulraghu94
Copy link
Contributor

Hello @MazoSergey , can you provide code excerpts, output and logs appended to the problem you're facing?

@dhoomakethu dhoomakethu added this to the 2.0.0 milestone Dec 23, 2017
@dhoomakethu dhoomakethu mentioned this issue Dec 23, 2017
12 tasks
@MazoSergey
Copy link
Author

Again thanks guys! Tomorrow i will be on the work and will provide all needed information...

@MazoSergey
Copy link
Author

MazoSergey commented Dec 26, 2017

Hello and sorry for delay guys. So I am trying to use files from #250-fix-scraper-simulator brunch: pymodbus/examples/contrib/modbus-scraper.py -o data -s 172.27.248.33 against MOD_RSim Version 8.20. After that I am executing pymodbus/examples/contrib/modbus-simulator.py -c data -D and trying to connect with ModScan32. But as the result I did success to connect to the simulator but all data is "0". Can you explain please what else i should to provide for you? Thank you very much!
scraper_log.txt
server_log.txt
data.txt

@MazoSergey
Copy link
Author

After I tried to scrape a real PLC I've got an error:

Unhandled error in Deferred

scraper_log (real_PLC).txt

@rahulraghu94
Copy link
Contributor

@MazoSergey , thanks for the information! I'll have a closer look ASAP and get back to you :)

@rahulraghu94
Copy link
Contributor

Hello @MazoSergey,

I'm using the config file you have uploaded here and am checking few of the values. They seem to be holding values. Are you using the message-parsers unser examples/contrib/message-parser.py to decode your message?

(modbus) [~/pymodbus/examples/contrib]$ ./message-parser.py -b -t -p tcp -m "0x0 0xc 0x0 0x0 0x0 0x13 0x1 0x3 0x10 0x0 0xa 0x0 0xa 0x0 0xa 0x0 0xa 0x0 0xa 0x0 0xa 0x0 0xa 0x0 0xa"                            *[#250-fix-scraper-simulator]
================================================================================
Decoding Message 000c00000013010310000a000a000a000a000a000a000a000a
================================================================================
ServerDecoder
--------------------------------------------------------------------------------
ClientDecoder
--------------------------------------------------------------------------------
name            = ReadHoldingRegistersResponse
protocol_id     = 0x0
unit_id         = 0x1
skip_encode     = 0x0
registers       =
                . [10, 10, 10, 10, 10, 10, 10, 10]
check           = 0x0
transaction_id  = 0xc
documentation   =
    This function code is used to read the contents of a contiguous block
    of holding registers in a remote device. The Request PDU specifies the
    starting register address and the number of registers. In the PDU
    Registers are addressed starting at zero. Therefore registers numbered
    1-16 are addressed as 0-15.

dhoomakethu pushed a commit that referenced this issue Jan 11, 2018
Fix scraper simulator example
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants