Pyserial non-standard baud rate
John Nagle
nagle at animats.com
Fri Oct 2 00:38:16 EDT 2009
oyinbo55 wrote:
> On Oct 1, 11:36 am, "Richard Brodie" <R.Bro... at rl.ac.uk> wrote:
>> "oyinbo55" <oyinb... at gmail.com> wrote in message
>>
>> news:2feb36fc-106c-4d7c-a697-db59971dc910 at a7g2000yqo.googlegroups.com...
>>
>>> 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.
>
> 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
More information about the Python-list
mailing list