Pyserial non-standard baud rate

O

oyinbo55

Hello all: this is my first post. I hope I'm doing it right.
I have a digital multimeter that sends data through an RS232 interface
at 19230 baud. I would like to record and graph the output in Python.
Pyserial does not want me to set the baudrate at a non-standard value:
ValueError : Invalid baud rate : 19230

Using the standard 19200 baud results in gobbledegook from the
multimeter.

How can I connect to this device?

I am using Python 2.5.1 running on Ubuntu 4.2.3 using IDLE 1.2.2

Thanks
 
R

Richard Brodie

Using the standard 19200 baud results in gobbledegook from the
multimeter.

You aren't going to notice a 0.1% clock skew within 1 byte.
Forget about the difference between 19200 and 19230.

If you have a scope handy, see what the output waveform
looks like, and check the timings. If not play around with
the rates, parity etc., until you find something that works.
 
O

oyinbo55

You aren't going to notice a 0.1% clock skew within 1 byte.
Forget about the difference between 19200 and 19230.

If you have a scope handy, see what the output waveform
looks like, and check the timings. If not play around with
the rates, parity etc., until you find something that works.

Thank you, Richard, you are absolutely right. Looking back at the
documentation for the instrument, I found the following:

"The data format complies with JIS 7Bits-transmission code with a baud
rate of 19230. "

I had overlooked the JIS transmission code because I didn't know what
that meant. (It is the Japanese Industrial Standard). Changing my
script to display the data one character at a time, I found it was
sprinkled with escape characters that Japanese machines use to switch
from ASCII to Kanji characters and back.

Does Python have a module that will translate the data stream and
display normal ASCII characters? The escape codes appear to alter the
values of the characters in some systematic way.

Thanks again for your help.
 
J

John Nagle

oyinbo55 said:
Thank you, Richard, you are absolutely right. Looking back at the
documentation for the instrument, I found the following:

"The data format complies with JIS 7Bits-transmission code with a baud
rate of 19230. "

OK. First off, 19200 baud should work. 19230 is a number which
comes from devices that use a 4MHz crystal for the clock and divide
by 208. 4000000 / 208 = 19230.769, which is as close as you can get
to 19200 baud given a 4MHz timing source. Serial ports
can usually tolerate an error of about 1/4 a bit time, which is 2.5%.
Since you're running a little fast, I'd suggest sending 2 stop bits,
which guarantees the receiver can't gain on the transmitter during
long blocks sent at full speed.
I had overlooked the JIS transmission code because I didn't know what
that meant. (It is the Japanese Industrial Standard). Changing my
script to display the data one character at a time, I found it was
sprinkled with escape characters that Japanese machines use to switch
from ASCII to Kanji characters and back.

Does Python have a module that will translate the data stream and
display normal ASCII characters? The escape codes appear to alter the
values of the characters in some systematic way.

If you're really receiving content in Shift-JIS, you just need to
translate it into Unicode. Python can do that. See

http://www.velocityreviews.com/forums/t646242-251-shiftjis-to-unicode.html

Now you'll have Unicode strings that contain kanjii, which Python can process
just fine.

Printing kanjii in a terminal window is troublesome on some operating systems.
But it's possible to get everything working in Unicode, which will result in
kanjii text appearing.

Reading the Japanese may be a problem, although you can put the text through
Google Translate.

John Nagle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top