ntruchsess / arduino_uip

UIPEthernet: A plugin-replacement of the stock Arduino Ethernet library for ENC28J60 shields and breakout boards. Full support for persistent (streaming) TCP-connections and UDP (Client and Server each), ARP, ICMP, DHCP and DNS. Build around Adam Dunkels uIP Stack. Further developed version can be found on https://github.com/UIPEthernet/UIPEthernet
489 stars 212 forks source link

fixing errata 12 on master branch #172

Open samiralavi opened 7 years ago

sakugava commented 7 years ago

while (((eir = readReg(EIR)). Is it correct?

samiralavi commented 7 years ago

Yes it is, (((eir = readReg(EIR)) & (EIR_TXIF | EIR_TXERIF)) == 0) we have 3 separate conditions, first : (eir = readReg(EIR)) it puts the read result into eir and then eir is returned second : (EIR_TXIF | EIR_TXERIF) third : And of these two conditions (((eir = readReg(EIR)) & (EIR_TXIF | EIR_TXERIF)) == 0) Also we can change it to be more clear : (((eir = readReg(EIR)) & (EIR_TXIF | EIR_TXERIF)) == false) or (!((eir = readReg(EIR)) & (EIR_TXIF | EIR_TXERIF)))

samiralavi commented 7 years ago

I once had a problem that when I would connect a ENC28j60 board to raspberry pi directly, after some time the IC would be stuck. After a lot of search, I finally made it work, by adding this fix to master branch.

Benjamin-Langlois commented 4 years ago

while (((eir = readReg(EIR)) & (EIR_TXIF | EIR_TXERIF)) == 0)

always results in 0 because:

(EIR_TXIF | EIR_TXERIF) == (2 | 8) == 10

and (X & 10) == 0

Shouldn't it be && instead of &?