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

self.forward_open() #27

Closed
redmeters-sshah opened this issue Jun 30, 2017 · 65 comments
Closed

self.forward_open() #27

redmeters-sshah opened this issue Jun 30, 2017 · 65 comments

Comments

@redmeters-sshah
Copy link

Hey,
I am trying to run test_slc_only.py but I am getting an error in line
build_common_packet_format(DATA_ITEM['Unconnected'], ''.join(forward_open_msg),ADDRESS_ITEM['UCMM'],)):
Can you please help me in resolving it.

@ruscito
Copy link
Owner

ruscito commented Jun 30, 2017

could you post the error message and the source code?

@redmeters-sshah
Copy link
Author

I am trying to run the exact code which you have posted with the changed IP address.

@redmeters-sshah
Copy link
Author

capture

@ruscito
Copy link
Owner

ruscito commented Jul 5, 2017

It looks like you didn't connect with the PLC

@redmeters-sshah
Copy link
Author

So in "cip_base.py" code in forward_open function do i need to change Connection parameter from default to PLC?

@ruscito
Copy link
Owner

ruscito commented Jul 5, 2017 via email

@redmeters-sshah
Copy link
Author

Yes, I am able to ping to the IP address where PLC is connected.
So what can be the issue for this error?

@ruscito
Copy link
Owner

ruscito commented Jul 5, 2017 via email

@redmeters-sshah
Copy link
Author

I did not understood which log file you are talking about. As i am using the exact code of yours for now.
Can you please explain which log file you want me to execute again?
thanks

@ruscito
Copy link
Owner

ruscito commented Jul 5, 2017

In the directory were you are executing the script there is a file "SlcDriver.log" which contains debug information and the data packets exchanged. You need to delete this file, and execute the python script again. Once you do so the log file will be recreated with the latest debug information

@redmeters-sshah
Copy link
Author

Here is the new log file
image

@redmeters-sshah
Copy link
Author

image

@ruscito
Copy link
Owner

ruscito commented Jul 5, 2017

it looks like it fail during forward_open but i'm not sure from the image you posted. It is possible to get the entire log file

@redmeters-sshah
Copy link
Author

Should I send the images of log file?

@redmeters-sshah
Copy link
Author

here is the pdf version of the log file
doc.pdf

@ruscito
Copy link
Owner

ruscito commented Jul 7, 2017

As I suspected the forward_open failed. Which PLC model are you trying to connect and what's the tag you are trying to read?

@redmeters-sshah
Copy link
Author

PLC model is Micro820 and Tag I am trying to read is DV

@ruscito
Copy link
Owner

ruscito commented Jul 7, 2017

Harggg! I should ask this question at the beginning. Micro models are totally different beast :) So they respond as "Out of Connections" (0x0113 is the status I read from your log)
Anyhow to work you need to set the parameter "direct_connection" to True when you open the connection

c.open(172.16.2.167, direct_connection=True):

@redmeters-sshah
Copy link
Author

Thank you, it worked.
I am getting 22 as output, what does that signifies?

@ruscito
Copy link
Owner

ruscito commented Jul 7, 2017

it should be the value of your tag. Make sure to import "pycomm.ab_comm.clx" and not "pycomm.ab_comm.slc"

@redmeters-sshah
Copy link
Author

okay. thanks a lot for your help!

@ruscito
Copy link
Owner

ruscito commented Jul 7, 2017

No problem

@ruscito ruscito closed this as completed Jul 7, 2017
@redmeters-sshah
Copy link
Author

One last thing,
When i Interrupt the program i get the following as a result.
image
And can you explain me how to read data from log file?
image
We will get the readings of PLC on log file right?

@redmeters-sshah
Copy link
Author

redmeters-sshah commented Jul 7, 2017 via email

@ruscito
Copy link
Owner

ruscito commented Jul 7, 2017

For the first question:
the reason you are getting the error is because you interrupted the process with ctrl-c without close the connection. The example you are using is not the best "strategy", what you really want is to exit the reading/writing loop and then call the "close" method to clean-up the connection with the PLC (foward_close)

For the second question:
the log file is just debug purpose only; at the beginning in the example file we set the log level to "DEBUG", but if you set it to "WARNING" then the log file will contain only errors or warnings. There is are lots of information in the log file and the majority is protocol related that wrap around the value you are trying to read

@redmeters-sshah
Copy link
Author

So how to read value from log file?

@ruscito
Copy link
Owner

ruscito commented Jul 7, 2017

You don't! You read value returned by the read_tag() method and you write using the write_tag() method

@redmeters-sshah
Copy link
Author

redmeters-sshah commented Jul 10, 2017 via email

@redmeters-sshah
Copy link
Author

How to solve the error of forward_close returned False
image

@patrickjmcd
Copy link
Contributor

If you're trying using a micro820, you need to use the other example "test_clx_comm.py". As @ruscito mentioned, you'll need to make sure you're enabling the direct connection by using
c.open(172.16.2.167, direct_connection=True)

In that example you'll see the line
print(c.read_tag(['ControlWord']))

This should print out the value returned from c.read_tag() which is a tuple of (value, tag type).

Storing the value of read_tags() will allow you to access the 0-th member of the tuple to get the value.

@redmeters-sshah
Copy link
Author

redmeters-sshah commented Jul 13, 2017 via email

@patrickjmcd
Copy link
Contributor

It would really help us to see the exact code you're using.

@redmeters-sshah
Copy link
Author

redmeters-sshah commented Jul 13, 2017 via email

@patrickjmcd
Copy link
Contributor

patrickjmcd commented Jul 14, 2017 via email

@redmeters-sshah
Copy link
Author

image
I am using this code.
Thank you

@redmeters-sshah
Copy link
Author

redmeters-sshah commented Jul 17, 2017 via email

@patrickjmcd
Copy link
Contributor

patrickjmcd commented Jul 17, 2017 via email

@redmeters-sshah
Copy link
Author

Micro 820

@patrickjmcd
Copy link
Contributor

Please post the whole error message you get, including the command used to run the script

@redmeters-sshah
Copy link
Author

image

@patrickjmcd
Copy link
Contributor

Can you remove the while loop, so it just runs once and post that output?

@redmeters-sshah
Copy link
Author

image

@redmeters-sshah
Copy link
Author

Do i need to make any changes in Forward_open() ?

@redmeters-sshah
Copy link
Author

redmeters-sshah commented Jul 18, 2017 via email

@ruscito
Copy link
Owner

ruscito commented Jul 18, 2017

shah-s I do you have a tag "ControlWord" in your PLC program?

@redmeters-sshah
Copy link
Author

Tag i am trying to read from my PLC is DV. There is no ControlWord tag in my PLC.

@ruscito
Copy link
Owner

ruscito commented Jul 18, 2017

That's not in the code you posted!! Please post your code as is and a clean log file because the info you are giving are confusing and don't help

@redmeters-sshah
Copy link
Author

redmeters-sshah commented Jul 18, 2017 via email

@patrickjmcd
Copy link
Contributor

It would be really helpful if you posted the actual code, not just a screenshot of it. Plus, your screenshots didn't work.

surrounding text with a backticks (`) to format it as code

like this

@redmeters-sshah
Copy link
Author

redmeters-sshah commented Jul 18, 2017 via email

@redmeters-sshah
Copy link
Author

redmeters-sshah commented Jul 19, 2017 via email

@ruscito
Copy link
Owner

ruscito commented Jul 19, 2017

shah-s I'm still waiting for the clean log file

@redmeters-sshah
Copy link
Author

redmeters-sshah commented Jul 19, 2017 via email

@ruscito
Copy link
Owner

ruscito commented Jul 19, 2017

can't see any log file

@redmeters-sshah
Copy link
Author

I have attached log file. Sorry I forgot to attach it last time.

log.txt

@ruscito
Copy link
Owner

ruscito commented Jul 20, 2017

as you can see from the picture below

capture

the error is "Service not supported" which practically means that the controller dose not recognize the "ReadTag" request (service 4C). Unfortunately I don't have a Micro820 to play with so I can't help; however the "ReadTag" request looks good, so my best guess is with the controller configuration or maybe the tag not been exposed

@redmeters-sshah
Copy link
Author

So any advice to solve this error?

@redmeters-sshah
Copy link
Author

redmeters-sshah commented Jul 24, 2017 via email

@redmeters-sshah
Copy link
Author

Now I am getting error "unpack requires a string argument of length 2"
How to overcome this error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants