Coder Social home page Coder Social logo

Invalid Continuation Byte about pylogix HOT 5 CLOSED

ifTaylor avatar ifTaylor commented on July 17, 2024
Invalid Continuation Byte

from pylogix.

Comments (5)

dmroeder avatar dmroeder commented on July 17, 2024

Is this a standard STRING type, or a custom string? How many characters were you trying to write?

from pylogix.

ifTaylor avatar ifTaylor commented on July 17, 2024

Sorry for the delayed response. More on this.

With the 4-byte unsigned integer format specifier '<I', I am able to write any length of string as long as the character groups are short enough. For example I was able to write the word "short " 385 times. The PLC truncated it to "short short short short short short short short short short short short short shor".

There were two cases that caused an error state.
1.
When I took out the space between one of the shorts, "shortshort short short.....", I received...

File "C:\Python38-32\lib\site-packages\pylogix\eip.py", line 1571, in _make_standard_string
temp = pack('<I', len(string)).decode(self.StringEncoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 0: invalid continuation byte

  1. (I began the thread here)
    When I restarted my application which reads with the single-byte unsigned value format specifier '<B'.

File "C:\Python38-32\lib\site-packages\pylogix\eip.py", line 1496, in _parse_multi_read
value = str(s.decode(self.StringEncoding))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcc in position 84: invalid continuation byte

Relating to case 1. is when I wrote "shortshortshortshortshortshortshortshortshortshortshortshortshortshortshortshortshortshortshortshortshortshortshortshortshorts". Then restarted my application and could not read. (adding an "h" makes the write fail)

Is the controller able to hold the full value? I would have thought the data would have been truncated and lost, so the format is valid when it's time to read.

Moving forward I will just limit to the 82 characters studio5000 indicates.

from pylogix.

dmroeder avatar dmroeder commented on July 17, 2024

No problem.

So you were trying to write more characters than actually fit in the string? Obviously that won't work, but I probably shouldn't let you try. Thanks for the information, I'll do some testing.

from pylogix.

ifTaylor avatar ifTaylor commented on July 17, 2024

All interesting stuff. I'm just wondering how the plc is holding onto the bad string and if it's only during runtime of the plc.

from pylogix.

dmroeder avatar dmroeder commented on July 17, 2024

Fixed by @ifTaylor

from pylogix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.