• Login
Community
  • Login

Python to Arduino connection problem

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 2 Posters 3.6k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    Michael Williams
    last edited by Mar 14, 2016, 5:33 PM

    I’m new to both Python and Notepad++ so my apologies in advance if this a simple fix. I’m using a simple sketch running on the Arduino that’s looping a counter and outputting a string through the serial port (COM3). In Python the script is monitoring that serial port for activity and printing the strings as they come in. If I run the script in VIDLE it works perfectly and I see the strings come across immediately. If I run it in the Notepad console I’ll get the Python initialization and then it stays blank for about 60 seconds and then I’ll see a burst of about 60 strings and then it halts. Another 60 seconds goes by then another burst. It seems like in Notepad the COM3 port is “clogged” then it just opens up for a brief second then shuts down again. Or maybe something else completed different. Anyone have an idea as to what;s happening here?

    Thanks

    C 1 Reply Last reply Mar 14, 2016, 5:53 PM Reply Quote 0
    • C
      Claudia Frank @Michael Williams
      last edited by Mar 14, 2016, 5:53 PM

      Hello @Michael-Williams,

      what do you mean by notepad++ console?
      How do you execute your python script?

      Cheers
      Claudia

      1 Reply Last reply Reply Quote 0
      • M
        Michael Williams
        last edited by Michael Williams Mar 14, 2016, 6:36 PM Mar 14, 2016, 6:35 PM

        Claudia,

        The NppExec plugin has a “Show Console” option where you’re provided a console screen in NotePad to view the script running. NppExec also has an Execute option where you can input the following:

        cd “$(CURRENT_DIRECTORY)”
        C:\Python27\python.exe “$(FILE_NAME)”

        Then you can assign a macro to run this Execute command on the active script.

        1 Reply Last reply Reply Quote 0
        • C
          Claudia Frank
          last edited by Mar 14, 2016, 7:02 PM

          Hello Michael,

          just for your information, nppexecs console is not really a console like the cmd.
          It tries to behave the same but it isn’t.
          Regarding your problem, I assume you have to call python with -u switch to get
          unbuffered results like

           C:\Python27\python.exe -u "$(FILE_NAME)"
          

          or you might override pythons sys.stdout with an unbuffered version. But I would give
          the -u switch the first try.

          Cheers
          Claudia

          1 Reply Last reply Reply Quote 0
          • M
            Michael Williams
            last edited by Mar 14, 2016, 7:30 PM

            Baddabing! The -u solved the problem. Thanks Claudia!

            1 Reply Last reply Reply Quote 0
            1 out of 5
            • First post
              1/5
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors