3

My application check /sys/class/net/eth0/carrier for ethernet status;
it works great on RPI 3B but broken on RPI 3B+.

If I plug out the RJ45 cable from both RPI 3B/3B+ :
the RPI 3B will change the carrier status from 1 to 0
but RPI 3B+ won't change anything.

Is there any attribute that my application can check for RPI 3B+ ethernet status?

1

Is there any attribute that my application can check for RPI 3B+ ethernet status?

Check the output of ip link show eth0. It should include NO-CARRIER if it is disconnected.

I can't promise this is the case (I don't have a 3B+ to check it on) if the kernel does not have access to the correct information, which the sysfs output implies, but it is worth a try.

  • Thanks for reply. but I always got following information from 『ip link show eth0』(no matter I plug out the cable or not): 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 00:1f:d8:00:bc:1b brd ff:ff:ff:ff:ff:ff – Wally Oct 15 '18 at 6:53
1

OK, Found two workarounds instead one true answer.
If ethernet cable is connected before RPI 3B+ booted, /sys/class/net/eht0/carrier will be 1 forever. (RPI 3B won't have this issue)

But we have the following two workarounds:
1. connect ehternet cable after RPI 3B+ boot into system
2. simple use "sudo ifconfig eth0 down" first, then "sudo ifconfig eth0 up" again. the RPI 3B+ /sys/class/net/eht0/carrier will works.

I believe this might be a Linux kernel (I'm using 4.14.56-v7+) bug since we can simply down & up trick to workaround this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.