2

I had interfaced R305 biometric module with microcontrollers before using embedded C. But when I tried it using python, I am having error in sending hex array to it. Here is my code:

import serial
adrport = serial.Serial(port="/dev/tty0",baudrate=9600)
genimg = [0xEF,0x01,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x03,0x01,0x00,0x05]

also I tried it declaring like this:

genimg = "\xEF\x01\xFF\xFF\xFF\xFF\x01\x00\x03\x01\x00\x05"

I used to transfer the above mentioned array using the following function:

txd(genimg)
def txd(tx):
    adrport.write(bytearray(tx))

Also I tried using

adrport.write(bytes(tx))

It doesnot show any errors to post the traceback, but the biometric module is not responding.

Okay, I changed the serail port to "/ttyAMA0" & now I can see the data flowing.But it also includes both "[,]" along with commas","; Can anybody help.?

Finally got the answer,defined array as

genimg = "\xEF\x01\xFF\xFF\xFF\xFF\x01\x00\x03\x01\x00\x05"

and used this.

adrport.write(bytes(tx))

Note: I tried this combination earlier also, but got loop iteration error because of using same name for both array and function. My bad,sorry everyone -;)

  • Find this Q&A very useful in knowing my mistake [link](http://stackoverflow.com/questions/34149991/ser-write-hex-string-raspberry) – Kranthi Kumar Jan 25 '16 at 15:15

0 Answers0