Git Product home page Git Product logo

Comments (4)

PowerBroker2 avatar PowerBroker2 commented on May 18, 2024

Can you post your entire Python and Arduino programs along with a description of what your project is supposed to do?

from pyserialtransfer.

PowerBroker2 avatar PowerBroker2 commented on May 18, 2024

Note that the contents of the txBuff should be byte-sized and no larger. If you want to stuff larger values into txBuff, you will have to use a combination of msb(val), lsb(val), and byte_val(val, pos) to break down your value's pieces into individual bytes to be then stuffed into the txBuff.

You can also use Python's struct package to do byte stuffing as well (as found in the Python application Thunder Viewer):

    def stuff_float(self, val, start_pos):
        '''
        Description:
        ------------
        Insert a 32-bit floating point value into the (pySerialTransfer) TX
        buffer starting at the specified index
        
        :param val:       float - value to be inserted into TX buffer
        :param start_pos: int   - index of TX buffer where the first byte of
                                  the float is to be stored in
        
        :return start_pos: int - index of the last byte of the float in the TX
                                 buffer + 1
        '''
        
        val_bytes = struct.pack('f', val)
        
        self.transfer.txBuff[start_pos] = val_bytes[0]
        start_pos += 1
        self.transfer.txBuff[start_pos] = val_bytes[1]
        start_pos += 1
        self.transfer.txBuff[start_pos] = val_bytes[2]
        start_pos += 1
        self.transfer.txBuff[start_pos] = val_bytes[3]
        start_pos += 1
        
        return start_pos

from pyserialtransfer.

2447SN avatar 2447SN commented on May 18, 2024

Ok thanks I think that answers my question.

from pyserialtransfer.

PowerBroker2 avatar PowerBroker2 commented on May 18, 2024

No problem! Let me know if you still have questions

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.