GithubHelp home page GithubHelp logo

Comments (3)

Michael-Yongshi avatar Michael-Yongshi commented on June 3, 2024

my fix would be:

def debug_data(serial_data):
    if not debug is True:
        return

    if not serial_data is None:
        
        if debug_level > 0:
            data_len = len(serial_data)
            if data_len == 2 and serial_data[0] == "07" and serial_data[1] == "f3":
                print(
                    "Recieved an ack packet: {0} {1}".format(serial_data[0], serial_data[1])
                )
            else:
                print("Data length   : {0}".format(len(serial_data)))
                print("Ack           : {0} {1}".format(serial_data[0], serial_data[1]))
                print("Start         : {0} {1}".format(serial_data[2], serial_data[3]))
                print("Command       : {0} {1}".format(serial_data[4], serial_data[5]))
                print(
                    "Nr data bytes : {0} (integer {1})".format(
                        serial_data[6], int(serial_data[6], 16)
                    )
                )

                n = 1
                while n <= int(serial_data[6], 16):
                    print(
                        "Data byte {0}   : Hex: {1}, Int: {2}, Array #: {3}".format(
                            n, serial_data[n + 6], int(serial_data[n + 6], 16), n + 6
                        )
                    )
                    n += 1

                print("Checksum      : {0}".format(serial_data[-2]))
                print("End           : {0} {1}".format(serial_data[-2], serial_data[-1]))

        if debug_level > 1:
            n = 0
            while n < data_len:
                print("serial_data {0}   : {1}".format(n, serial_data[n]))
                n += 1

    else:
        print(f"serial_data ({serial_data}) is empty")`

from whr_930.

Mosibi avatar Mosibi commented on June 3, 2024

Thank you for this report. Would you like to make a pull request for it?

from whr_930.

Michael-Yongshi avatar Michael-Yongshi commented on June 3, 2024

See

#22

from whr_930.

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.