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

Library expects ads packets to be maximum 1 ethernet frame #9

Open
haakonnessjoen opened this issue Dec 19, 2013 · 5 comments
Open
Labels

Comments

@haakonnessjoen
Copy link
Contributor

The library expects a packet to never exceed one ethernet frame. This is not a limitation in ADS it self.

All packets are read to this variable:
dc->msgIn

Which is a stack variable of 1524 bytes.
This variable should instead be dynamically allocated heap according to the length specified in the ads read/write command.

@gass
Copy link
Owner

gass commented Dec 20, 2013

in the libads branch the maxdatalen will be 8192 bytes
https://github.com/gass/libads/blob/AdsRouter/src/ads.h#L43

Or we could just have a dynamically allocated datapointer (pointer to msgin).
What is the best option?

@haakonnessjoen
Copy link
Contributor Author

The best option would be to dynamically allocate the msgin pointer. If you read or write a big array of structs from ADS, the packet can get quite big.. Unless written specifically in the beckhoff manual, you should not limit it to a low number. I tried to read a struct of 69888 bytes when I found your 1524 byte limit. Which is far more than the 8192 limit you suggested.

@gass
Copy link
Owner

gass commented Dec 20, 2013

The data pointer present in the struct is not used.
Can you propose a change to the code?

@haakonnessjoen
Copy link
Contributor Author

I do not have the time to go through the code right now I am afraid. But I
would suppose that it should be as easy as defining msgin as a char pointer
instead of a char array of 1524 bytes. And then be sure to malloc/free it
between each use. As far as I know, you always know how large the packets
will be, before you attempt to read them. So just allocate it before
reading from the socket.

I could look at it after christmas at some point, if you do not want to
look at it.

On 20 December 2013 21:57, Luis Matos notifications@github.com wrote:

The data pointer present in the struct is not used.
Can you propose a change to the code?


Reply to this email directly or view it on GitHubhttps://github.com//issues/9#issuecomment-31041093
.

Håkon

@gass
Copy link
Owner

gass commented Dec 22, 2013

I need to merge the ads router code from Gerhard. If i finish it before, i'll do it.
Cheers and merry Christmas.

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

No branches or pull requests

2 participants