S7NetPlus / s7netplus

S7.NET+ -- A .NET library to connect to Siemens Step7 devices
MIT License
1.33k stars 588 forks source link

Problem with DB size bigger of 8200 byte #38

Closed frangoteam closed 8 years ago

frangoteam commented 8 years ago

Hi team, can you please let me know how we can read one DB with a size bigger of 8200 byte?

I read DB with ReadBytes(DataType.DataBlock, 1, 8200, 200); I saw that the problem is by "package.Add(Types.Word.ToByteArray((ushort) ((startByteAdr)*8)));"

Best Regards

oiisamiio commented 8 years ago

https://github.com/oiisamiio/s7netplus/pull/1

https://github.com/jobmeij/s7netplus/commit/f6246382a862040341d1f8626a2a6556fe28609d

frangoteam commented 8 years ago

Hi and tanks...maybe is better? package.Add((byte)(startByteAdr / 8191));

Best Regards

oiisamiio commented 8 years ago

Sorry your code looks dirty and will result in trouble.

an example: If you start read at address 8100 and set read 200 bytes like ReadBytes(DataType.DataBlock, 1, 8100, 200); data will be corrupt because we cant split actually streamaddress.

so we should check startaddress lower than 8191 and count + startaddress greater than 8191

Excuse my English...

Regards Sam

frangoteam commented 8 years ago

Hi Sam, What do you do if you have an array of 40000 bytes? after ~16200 you have again a overflow? (~24000 again)...?

Excuse my English... Regards Umberto

oiisamiio commented 8 years ago

Think so. How many bytes you want to read?

frangoteam commented 8 years ago

Hi Sam, a DB in a S7-300, S7-400, S7-1200 PLC can have 64K size. I think is a quality question...and i come up with the problem because i'm compared with this. i don't know the correct solution but your bug fixing is more wrong as my...i tested.

Best Regards umberto

2016-02-03 19:14 GMT+01:00 Sam notifications@github.com:

Think so. How many bytes you want to read?

— Reply to this email directly or view it on GitHub https://github.com/killnine/s7netplus/issues/38#issuecomment-179386049.