Giter Club home page Giter Club logo

Comments (4)

PowerBroker2 avatar PowerBroker2 commented on May 20, 2024

I can't understand what you're trying to say. Can you explain your question?

from pyserialtransfer.

Menginventor avatar Menginventor commented on May 20, 2024

Yes. So you need to replace every byte that equals to START_BYTE so you scan whole packet to see all byte but some how you prefre to see the last byte first.
If we got 5 bytes in our packet, we need to scan all index from 0 to 4. For each loop, index value should be

4
3
2
1
0

but your code . "for i in range(pay_len - 1, 0, -1):"
will produce

4
3
2
1

It not reaching zero, the first index of packet. At this point I wonder this is on purpose or not?

from pyserialtransfer.

PowerBroker2 avatar PowerBroker2 commented on May 20, 2024

Ah, I see. I vaguely remember writing that function but don't remember any specific reason why I skipped the first index. I think I need to change it to:

  def find_last(self, pay_len):
        '''
        Description:
        ------------
        Finds last instance of the value START_BYTE within the given
        packet array

        :param pay_len: int - number of bytes in the payload

        :return: int - location of the last instance of the value START_BYTE
                       within the given packet array
        '''

        if pay_len <= MAX_PACKET_SIZE:
            for i in range(pay_len - 1, -1, -1):
                if self.txBuff[i] == START_BYTE:
                    return i
        return -1

from pyserialtransfer.

Menginventor avatar Menginventor commented on May 20, 2024

I already change that part. It work fine with the rest of code. (I've test with serialTransfer on Arduino).
I really admire your work trust it's make my life a lot easier.
I found this piece of code while I try to modify your work to make easier version.
This my work https://github.com/Menginventor/SerialCom in case you might want to take a quick look.

from pyserialtransfer.

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.