[Tutor] Re: sending hex data on port
vicki@stanfield.net
vicki@stanfield.net
Wed Jun 18 14:55:03 2003
On Wed, 18 Jun 2003 13:26:47 -0500 (EST),
vicki@stanfield.net wrote:
>
> I am working on a project which requires that I read
> data in from a file and send the hex equivalent out on
> the serial port. I have everything except how to send
> the data in hex format. I have looked through a lot of
> apps but most are really more complicated than I am
> ready for. If I simply try to do this:
>
> port.write(hex(18))
>
> It translates the 1 to hex and then the 8 to hex. I
> realize this is quite simplistic, but it is really all
> I need to do. If I put '18', it complains about not
> being able to convert a hex value to a hex value.
>
> Pardon my ignorance, but can someone please point me
in
> the right direction?
>
> --vicki
Okay, sorry to reply to my own post, but I am still
working on this. I tried something which I think is
close to what I need. I am using binascii.
port.write(binascii.a2b_hex("18"))
Is this what I am supposed to be using to translate dec
to hex?
--vicki