[EMAIL PROTECTED] wrote:
> Sorry i am late getting back on this.
> ord() is finally what is giving me what i wanted.
> the vendor told me that what was comming in was an ascii string
> representing hex characters. So i expected when i used the serial
> module
> that what i would be getting was some
Sorry i am late getting back on this.
ord() is finally what is giving me what i wanted.
the vendor told me that what was comming in was an ascii string
representing hex characters. So i expected when i used the serial
module
that what i would be getting was something along the lines of 4A, 3D,
etc.
On 2005-08-19, John Machin <[EMAIL PROTECTED]> wrote:
> The OP is reading raw output from a serial port. He's already said he's
> getting "funny ASCII characters". One gets the impression he thinks he
> needs to do bit-twiddling on *each* byte. Looks like he needs ord(), or
> (better) struct.un
Grant Edwards wrote:
> On 2005-08-18, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>>i have an ascii string comming in the serial port and i need to convert
>>it to something else, like an integer, or binary, or even a hex so i
>>can use the bitwise comparison on it.
Nephish, *WHY* do want t
thanks for your time.
i have started just doing a type(a) from idle a lot just so i can make
sure of what i am dealing with ( i do this a lot) before i build the
.py file. got tired of 'cannot concatonate str and init' stuff all the
time.
this has been a wild project. nothing like getting in way ov
On 18 Aug 2005 10:42:32 -0700, [EMAIL PROTECTED] wrote:
import serial
ser =3D serial.Serial('/dev/ttyS0', 2400, timeout=3D 10, bytesize=3D8, =
>stopbits=3D1)
a =3D ser.read(1)
print a
>^
In general,
print a
is not a good way to investigate what a is, because print uses st
all apologies, gentlemen, i feel like an idiot.
the ord() is what is returning what i need.
the manufacturer of the unit i am reading from
told me that it puts out a "string that represents a hex"
been thumping my head.
sorry for the confusion,
and thanks for your help
shawn
--
http://mail.pytho
Peter Hansen wrote:
> ASCII, however, they represent these three characters: "Foo". Your data
> looks like chunk when treated as ASCII, so it's probably just bytes.
Weird. I think I meant "junk" (not "chunk"), but obviously was writing
verbally, not visually...
-Peter
--
http://mail.python.o
[EMAIL PROTECTED] wrote:
import serial
ser = serial.Serial('/dev/ttyS0', 2400, timeout= 10, bytesize=8, stopbits=1)
a = ser.read(1)
print a
It sounds like you want to convert characters into their corresponding
integer values. To do this, use the ord() builtin function.
>>> ord
On 2005-08-18, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
import serial
ser = serial.Serial('/dev/ttyS0', 2400, timeout= 10, bytesize=8,
stopbits=1)
a = ser.read(1)
print a
> ^
That's not a hex number. Hex numbers are composed of '0-9A-F'
0F48A is a hex number. ^ is
>>> import serial
>>> ser = serial.Serial('/dev/ttyS0', 2400, timeout= 10, bytesize=8, stopbits=1)
>>> a = ser.read(1)
>>> print a
^
>>> ser.close()
>>> type(a)
>>> int(a, 16)
Traceback (innermost last):
File "", line 1, in ?
ValueError: invalid literal for int(): ^
so i run it again the same
On 2005-08-18, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> i have an ascii string comming in the serial port and i need to convert
> it to something else, like an integer, or binary, or even a hex so i
> can use the bitwise comparison on it.
But what do you mean by "integer", "binary", and "he
i have an ascii string comming in the serial port and i need to convert
it to something else, like an integer, or binary, or even a hex so i
can use the bitwise comparison on it.
thanks
--
http://mail.python.org/mailman/listinfo/python-list
On 2005-08-18, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> i got the bitwise part, i just cant seem to convert the
> incomming ascii into hex, binary, integer, or decimal.
So you've got an ASCII string in one format and you want to
convert into an ASCII string in a different format?
For exa
i got the bitwise part, i just cant seem to convert the incomming ascii
into hex, binary, integer, or decimal.
how do i do this, my serial port bytes just come in all weird looking
ascii characters
thanks
--
http://mail.python.org/mailman/listinfo/python-list
oh wait, i found it. i found how to do the conversions and thanks to
you the operators.
appreciate everything,
shawn
--
http://mail.python.org/mailman/listinfo/python-list
this is exactly what i need.
i have not previously had a need for this kind of thing, but i sure
need some
documentation for it now. is there a resource out there to find out how
to convert decimal number to a byte, a byte to a decimal and more about
the & operator?
i really appreciate this info. t
[EMAIL PROTECTED] wrote:
> yeah, i think i got that down, i need help with getting the hex to
> binary, then splitting the byte up to compare each bit against the bit
> in another byte.
The & operator does all 8 comparisons simultaneously. So if
the serial port byte is A, the reference byte is B
yeah, i think i got that down, i need help with getting the hex to
binary, then splitting the byte up to compare each bit against the bit
in another byte.
unless i am not understanding this stuff with the bitwise right. there
wasn't a lot in the python library reference about it.
thanks
--
http:/
Sounds like you want the bitwise and operator, &
>>> 2 & 3
2
>>> 32 & 16
0
>>> 31 & 12
12
etc.
[EMAIL PROTECTED] inquired:
> i have an interesting project at work going on. here is the challenge.
> i am using the serial module to read data from a serial input.
> it comes in as a hex. i need to m
i have an interesting project at work going on. here is the challenge.
i am using the serial module to read data from a serial input.
it comes in as a hex. i need to make it a binary and compare it bit by
bit to another byte. They have some weird way they set this up that i
have to compare these th
21 matches
Mail list logo