Message Value error

0

Good afternoon, I got an error message from operands coul not be broadcast together with shapes (256,) (268,) the image shows the error

Thecodeisasfollows:

importRPi.GPIOasGPIOfromlib_nrf24importNRF24importtimeimportspidevimportmathimportstringimportnumpyasnpdefdec_to_bin(ascii):binary=format(''.join('{:04b}'.format(x)forxinascii))bits=np.transpose(list(map(int,np.transpose(list(binary)))))returnbitsdefconvert_to_ascii(text):aux=format(''.join(str(ord(char))forcharintext))ascii=list(map(int,list(aux)))returnascii#===============InicializaçãoRadiodoNRF24L01=======================GPIO.setmode(GPIO.BCM)pipes=[[0xE8,0xE8,0xF0,0xF0,0xE1],[0xF0,0xF0,0xF0,0xF0,0xE1]]radio=NRF24(GPIO,spidev.SpiDev())radio.begin(0,17)radio.setCRCLength(NRF24.CRC_DISABLED)radio.setPayloadSize(32)radio.setChannel(0x76)radio.setDataRate(NRF24.BR_1MBPS)radio.setPALevel(NRF24.PA_MIN)radio.setAutoAck(False)radio.enableDynamicPayloads()radio.enableAckPayload()radio.openReadingPipe(1,pipes[1])radio.disableCRC()#radio.printDetails()radio.startListening()#========palavraareceber===================palavra="01234567890123456789012345678910"

#==============Texto inicio programa===================
print("\n")
print("====Inicio Envio Dados Sensor2======")
time.sleep(.1)
print("\n")
#=======Conversao (palavra)==================================================
ascii=convert_to_ascii(palavra)
ascii_aux=np.array(ascii)
erros=np.sum(np.array((np.array(ascii)-np.array(ascii_aux))!=0, dtype=int))
bits=dec_to_bin(ascii)
#print("Bits(palavra)=",' '.join('{:04b}'.format(x) for x in ascii))
##print('Bits(array)= ',format(','.join('{}'.format(x) for x in bits)))
#=======================Mensagem Recebida====================================
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("recebido", ascii_aux2)
##    print("palavra_", ascii_aux)
    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)
    
asked by anonymous 28.09.2017 / 16:04

0 answers