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

Question: S7-200 #10

Closed
localleon opened this issue May 20, 2019 · 4 comments
Closed

Question: S7-200 #10

localleon opened this issue May 20, 2019 · 4 comments

Comments

@localleon
Copy link

Hey man,
i really want to use your awesome work... Im running an Siemens S7-200 with an CP243-1 as ethernet module and my end goal is to set a marker and therefor control an output. simple stuff...

Now to my problem. The connection handler asks for an rack and slot number which i don't seem to find. Do you have any tips for finding this number? Is it in my Project or CPU defined?

Any help is appreciated. Thx..

@robinson
Copy link
Owner

Hi there,

I have not tested with S7-200 but as far as I know S7-200 has no rack/slot . Therefore just put 0/0. Try to take some test and let me know the result. If you have any improvement please feel free to sharing. Cheers, R

@localleon
Copy link
Author

localleon commented May 21, 2019

Okay, so i just found my TSAP in a capture of the COTP Protocol. I currently just hardcoded it into the source to fix my issue. If i am able to resolve/understand the root cause i will provide you with more information and maybe an pull request.

Could you share some Sample Code for setting Merkers? My Endgoal is to set Merker 2.4 to 1. Some Code would really help me out because im now just fiddling through the function AGWriteMB to find this out.

// TCPClient
	handler := gos7.NewTCPClientHandler(tcpDevice, rack, slot)
	handler.Timeout = 10 * time.Second
	handler.IdleTimeout = 10 * time.Second
	handler.Logger = log.New(os.Stdout, "tcp: ", log.LstdFlags)
	// Connect manually so that multiple requests are handled in one connection session
	handler.Connect()
	defer handler.Close()
	//init client
	client := gos7.NewClient(handler)
	// read Variable
	start := 2
	log.Println("merkerTest Merker as Byte:", byte(start))
	fmt.Println()
	size := 1
	buffer := make([]byte, 255)
	//AGWriteMB to Parameters
	err := client.AGWriteMB(start, size, buffer)
	log.Println("write mb error:", err)
	//AGWriteMB(start int, size int, buffer []byte) (err error)

Any examples would be from great interest. Thanks for you help.

@localleon
Copy link
Author

The S7-200 is answering to both CPU and PLC Status Functions with an Error Code (CPU : Function not available 0). So these functions are maybe not supported on this model

@localleon
Copy link
Author

So the S7-200 wants a bit instead of a byte for their data. In your libary the datatype is hardcoded to byte. Maybe we could introduce a parameter for AGWriteMB to change the Type.

For my problems, i just hardcoded everything to use bits. Thanks for your work

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

2 participants