przemobe / micropy-ENC28J60

ENC28J60 Ethernet chip driver for MicroPython (RP2)
GNU General Public License v3.0
22 stars 7 forks source link

Question regarding the recieving and print of data #2

Closed ph1lj-6321 closed 2 years ago

ph1lj-6321 commented 2 years ago

Hi Looking at and testing your 'Packet reception' script - when I run this code (altered the SPI pins to suit), all I see is the following -

image

I'm testing it by continuously sending out a data stream from PacketSender

I'm using Port 7 After your line rxBuf = .......

I simply added print(rxBuff)

Can you provide any hints ?

I was hoping to see the data

no stuff is not good what I'm sending at 100ms intervals - somewhere in the Rx packet

przemobe commented 2 years ago

Hi,

To receipt any data you need to check if there is any data received by eth.GetRxPacketCnt(). Then read a data by rxLen = eth.ReceivePacket(rxBuf) to prealocated buffer rxBuf. Return value rxLen gives you information how many bytes was exactly received or an error code (negative number).

# prealocate buffer
rxBuf = bytearray(enc28j60.ENC28J60_ETH_RX_BUFFER_SIZE)

# check if any packet is received
while eth.GetRxPacketCnt():
    # read packet into rxBuf, get rxLen length
    rxLen = eth.ReceivePacket(rxBuf)
    # check if no rx error
    if rxLen >= 0:
        # print only received data, do not print the entire buffer
        print(rxBuf[:rxLen])
    else:
        print('rx error', rxLen)

It is not clear for me how are you sending the data to your device? A sender need to know MAC address or use broadcast MAC address.

przemobe commented 2 years ago

Closing -> responded and no activity.