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 8215213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:42:32+00:00 2026-06-07T11:42:32+00:00

Playing with a MCU, I’m trying to communicate through a RS232 link to a

  • 0

Playing with a MCU, I’m trying to communicate through a RS232 link to a PC desktop.

I’ve made a test program really simple: send “Hello world!\n” every n ms.

Most relevant link connection parameters are:

  • Port: /dev/ttyUSB0
  • Baudrate: 57600 bps
  • 8 data bits
  • 1 bit stop
  • No parity and hardware control

To check that I receive data from MCU to PC, I set /dev/ttyUSB0 with:

%> stty -F /dev/ttyUSB0 57600 cooked

and then,

%> cat /dev/ttyUSB0
Hello world!
Hello world!
Hello world!
...

So, I receive data from the MCU properly.

But, here the problem, when I want use Python with pySerial module, data are absolutely wrong:

>>> s = serial.Serial('/dev/ttyUSB0', 57600)
>>> print s
Serial<id=0x195fed0, open=True>( 
    port='/dev/ttyUSB0', baudrate=57600, 
    bytesize=8, parity='N',  
    stopbits=1, timeout=None, 
    xonxoff=False, rtscts=False, 
    dsrdtr=False)

>>> s.read(14)
'\xc8\xe5\xec\xec\xef\xa0\xf7\xef\xf2\xec\xe4\xa1\x8a\x80'

At this point, I’ve changed “Hello world!\n” output string (MCU side) for this string: 0xde, 0xad, 0xbe, 0xef. And, what I get with pySerial is:

>>> s.read(4)
'\xde\xad\xbe\xef'

It works! I’ve changed another time, now for this: 0x00, 0x01, 0x02, 0x03, 0x80, 0x81, 0x82, 0x83. Result:

>>> s.read(8)
'\x80\x81\x82\x83\x80\x81\x82\x83' 

Conclusion: pySerial changes bytes value smaller than 128 for same value plus 128.

I don’t know why this is happening. I used pySerial module in other occasions (version 2.4) and all worked fine. I’ve tried with 2.5 and 2.6 versions in Ubuntu 11.10 and Ubuntu 10.04 but no works. Any clue?

PD: Be sympathetic with my English writing. I’m not proficient in English as I should be.

  • 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-06-07T11:42:33+00:00Added an answer on June 7, 2026 at 11:42 am

    Ok, my fault! PySerial works perfect. Revising code in MCU, I found one mistake unsetting a bit that should be set (I was sending 7-bit character length). Then, frame received was, obviously, partially well, partially wrong.

    Now, I can understand why pySerial show me bad results. Nevertheless, is a mystery for me how my PC reconstruct from 7-bit data, characters of 8-bit length. I was absolutely convinced that MCU’s code was fine because data from terminal was correct :S

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

Sidebar

Related Questions

Playing with jquery for the first time, and I'm trying to get a simple
While playing around with the emulator, I noticed that when trying to view a
Currently playing about with KnockoutJS. Just trying to update an observable array from a
I´m playing with MassTransit with a simple example and I don´t know what I´m
Im playing about with some very simple windows forms. I have an event handler
Just playing around with the now released Silverlight 2.0. I'm trying to put a
Been playing with nginx for about an hour trying to setup mass dynamic virtual
Playing around with Timers, and trying to make them behave right when app is
Playing with pointers in C is fun (not really). I have several arrays of
Playing around with Lucene. Trying to make my changes visible for other reading threads.

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.