Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3320842
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:59:30+00:00 2026-05-17T22:59:30+00:00

I am hoping this is a simple stupid noob mistake that can be fixed

  • 0

I am hoping this is a simple stupid noob mistake that can be fixed with the addition of a single line of code somewhere.

I’m using pySerial to read in serial data from a USB port and print it out to standard output. I’m running Mac OSX 10.6. I open terminal and type “python”, then the following:

>>> import serial;
>>> ser = serial.Serial('/dev/tty.usbserial-XXX', 9600, timeout=1);
>>> while True:
>>>      if ser.inWaiting() > 0:
>>>            ser.readline();
>>> [done, I hit enter...]

This works beautifully. It starts outputting my serial data nicely, exactly as I’d expect it to. Great, I think, let me put this into its own script with command line arguments and then I can call it any time I want to:

import sys;
import serial;

serialPort = sys.argv[1]
baudRate = sys.argv[2]

ser = serial.Serial(serialPort, baudRate, timeout=1)

while True:
    if ser.inWaiting() > 0:
        ser.readline()

On the command line, I type “python myScript.py [my serial port] 9600” and sit back and wait for a beautiful flow of serial data – but nothing comes out. It just kinda hangs until I kill the process.

I thought, well maybe for some reason it’s not working – so I put some debugging prints into the code. I update my while loop to look like this:

 while True:
    print("looping...")
    print(ser.inWaiting());
    if ser.inWaiting() > 0:
        ser.readline()

I run it again, and I get a repeating output stream of “Looping…” and “0”. I think, well maybe there’s something wrong with my command line arguments – so I hard-coded the port and the baud rate into the script, same thing.

So, why would this be the case? Is my use of while True: somehow blocking the script from accepting serial data? Is there a better way to do this?

I’m a complete Python noob. I am writing this script in order to create a faster way to communicate between Adobe AIR and an Arduino board. I’m hoping there’s a magic bullet I can drop in here to make it work – is there?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:59:30+00:00Added an answer on May 17, 2026 at 10:59 pm

    Is it printing anything? I’d assume it would print:

    looping...
    <ser.inWaiting() val>
    

    And then nothing. Add a print statement so it looks like

    print ser.readline()
    

    and see if that works. I’m guessing that the interpreter is printing the returned strings when you do it as a command, but in a script the returned strings from readline() are getting discarded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple line, that I was hoping would count all checked checkboxes
I'm hoping this has a simple solution. I have a JavaScript code that displays
I'm hoping this question has a very simple answer. I can think of ways
I am hoping that this will have a pretty quick and simple answer. I
I'm hoping this is just a bug on Facebook's end that will be fixed
I am relatively new to Javascript so I'm hoping this is a simple mistake.
hey guys, how can I just achieve this simple layout? I'm hoping the answer
Hoping this is possible with Simple Html Dom, I'm scraping a page that looks
I'm hoping this is a simple question - I have the following helper code:
I'm hoping this is something simple and small that I'm missing, but currently, This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.