[Tutor] Re: sending hex data on port

Lloyd Kvam pythontutor@venix.com
Wed Jun 18 15:47:04 2003


To me hex is a way to represent an underlying set of bits
00011000 = 0x18
10001000 = 0x44

You are trying to write a hex 18 over a serial port.  Does that mean
you want to write a '1' followed by a '8'  That is a character one (hex 49)
followed by an 8 (hex 48)?

If you are trying to write some bits that have the hex value 18, then you
are probably want to write the character represented by 00011000.  Those
bits equal 24 in base 10.  The matching character is chr(24).

What module are you using?  Does it make sense to say port.write(chr(24))?


vicki@stanfield.net wrote:
> On Wed, 18 Jun 2003 12:20:07 -0700, Neil Schemenauer
> wrote:
> 
> 
>>I think you are confused about the difference between
>>numbers and
>>strings.  The hex() builtin requires an integer as an
>>argument.  '18' is
>>a string.  You really need to be more specific as to
>>what you want to
>>do.  '18' could be interpreted as a number in base 10
>>or in base 16 or
>>in lots of other ways.  For example, if the value you
>>have is '1829',
>>what are the characters you want to write to port?
>>
>>  Neil
> 
> 
> Yes, I am. I really just need to pass over the serial
> port a hex 18 (0x18) and then a hex 0B (0x0B) and then
> a hex 1D (0x1D). I am obtaining return values each time
> via the same serial connection. I appreciate your help. 
> 
> --vicki
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582