Re: question about binary and serial info

2005-08-21 Thread Steve Holden
[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

Re: question about binary and serial info

2005-08-21 Thread nephish
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.

Re: question about binary and serial info

2005-08-18 Thread Grant Edwards
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

Re: question about binary and serial info

2005-08-18 Thread John Machin
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

Re: question about binary and serial info

2005-08-18 Thread nephish
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

Re: question about binary and serial info

2005-08-18 Thread Bengt Richter
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

Re: question about binary and serial info

2005-08-18 Thread nephish
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

Re: question about binary and serial info

2005-08-18 Thread Peter Hansen
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

Re: question about binary and serial info

2005-08-18 Thread Peter Hansen
[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

Re: question about binary and serial info

2005-08-18 Thread Grant Edwards
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

Re: question about binary and serial info

2005-08-18 Thread nephish
>>> 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

Re: question about binary and serial info

2005-08-18 Thread Grant Edwards
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

Re: question about binary and serial info

2005-08-18 Thread nephish
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

Re: question about binary and serial info

2005-08-18 Thread Grant Edwards
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

Re: question about binary and serial info

2005-08-18 Thread nephish
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

Re: question about binary and serial info

2005-08-18 Thread nephish
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

Re: question about binary and serial info

2005-08-18 Thread nephish
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

Re: question about binary and serial info

2005-08-17 Thread [EMAIL PROTECTED]
[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

Re: question about binary and serial info

2005-08-17 Thread nephish
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:/

Re: question about binary and serial info

2005-08-17 Thread Jordan Rastrick
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

question about binary and serial info

2005-08-17 Thread nephish
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