Unconfigured Ad Widget

Collapse

Who knows Python language? I need help.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • #16
    Frozenguy
    CGN/CGSSA Contributor
    CGN Contributor
    • Jan 2008
    • 6303

    So I have not been able to get it to work.

    How can I start rewriting this in c? Any breakdowns on how to translate it fast for a noob?

    Comment

    • #17
      Fizz
      Senior Member
      • Feb 2012
      • 1473

      Originally posted by Frozenguy
      So I have not been able to get it to work.

      How can I start rewriting this in c? Any breakdowns on how to translate it fast for a noob?
      While doable it won't be easy. IMO, you'd be better served by learning/debugging Python, than recreating the result in something you're familiar with. You might discover that you like Python, at least for certain purposes more than C. Also, I assume you mean something like C++ and not regular C.

      Anyway, you have a Python code that worked on one machine and not another. The easiest way to fix it will be to ID the differences and make the environments match (Python version, Operating System, etc.). However, the better solution IMO is to debug the code. This will mean you won't be version-locking yourself to old Python. You'll understand the code better and you'll be better suited to maintain the code in the future as things change.

      If you want a REALLY lazy solution, you might capture the old machine to a Virtual Machine on the new PC, and pass the serial interface to the VM. This would involve -0- coding at all and almost guaranteed to work. Doesn't do anything for you educationally, but gets the job done if there isn't some other limitation.

      Also, the Python community is very large and VERY helpful. Honestly if you were to post the root of the project (the main .py and all other files/subfolders) to something like Stack Exchange or Reddit I can almost guarantee someone will debug your code and return it to you, free of charge.

      Comment

      • #18
        pepsi2451
        Senior Member
        • Feb 2006
        • 1633

        Originally posted by Frozenguy
        Here is the error after typing in "COM1" instead of 0.



        I'm installing anaconda 2.7 right now to see if that can clear things up..
        I don't think the problem has anything to do with the python version. The Documentation for pyserial says "Changed in version 3.0: numbers as port argument are no longer supported" so I think its likely the other system had an older version on pyserial installed.

        Are you sure COM1 is the address you want? My motherboard has one COM port, COM12. If I run your code with COM12 it seems to work. After changing line 156 to:

        "sonar_port = FakeSonarPacket("COM12", 115200, 4)"

        and line 36 to:

        "data = self.packet_reader()"

        It opens the port then crashes after trying to read data that isn't there.

        To check what ports are available on your system you can run "python -m serial.tools.list_ports" from the windows command prompt or check under device manager.

        Since you seem to be emulating some kind of sonar device, are you running the software you are trying to communicate with on the same system or is it connected with an actual serial connection?

        Comment

        • #19
          oktavist
          Member
          • Aug 2015
          • 391

          If it was running on a previous machine, then you have the wrong version. Python versions are not compatible and you must use the compiler for the version that that the code was written for.
          Calguns Lurker

          Comment

          • #20
            rightsider
            Junior Member
            • Jul 2019
            • 31

            If you have control over the environment you're running you're script, I'd highly recommend using virtualenv to manage lib dependencies and keep them clean for your script as opposed to libs that are installed onto to the machine.

            Comment

            Working...
            UA-8071174-1