Variable not defined

Asked

Viewed 78 times

1

My code gives me an error in a definition of a variable but I think it is declared the variable bits_rx, this variable aims at the result of the conversion:

while(1):

while not radio.available(0):
    time.sleep(1 /100)

receivedMessage= []
radio.read(receivedMessage, radio.getDynamicPayloadSize())


string = ""

for n in receivedMessage:
    string += chr(n)
    ascii=convert_to_ascii(string)
    ascii_aux2=np.array(ascii)
    bits_rx=dec_to_bin(ascii)
    print("Bits(recebidos)=",' '.join('{:04b}'.format(n) for n in ascii))
    erros=np.sum(np.array((bits-bits_rx)!=0, dtype=int))
    print("Erros= ", erros)
  • What language is that? I believe it is Python then take a look at that answer: What’s wrong with the indentation of this python code?

  • yes it’s python, but bits_rx can be declared like this can’t?

  • yes, check the identation

  • I’ve been around the indentation and it always makes the same mistake!!

  • Has two while at the same indentation level there.

  • how can I re-edit and put the right code? as I have it in the Raspberry IDLE

  • Below the code in the question is tags and below the tags you have the edit option, or edit

  • Okay, thanks, I already put the code, the error continues to give me

  • Which error message is complete and the line?

  • I have already found the problem of being in error, it was one of the emitters that was damaged and hence give error, I appreciate the help provided in it.

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.