1

I am porting a tool developped with Python from RPi2 to RPi3, it uses the /dev/ttyAMA0 port to communicate.

The problem is that in Raspberry 3 models, this is now used by the BlueTooth (no disabling it). The different RPis using the tool could be on Wheezy or Jessy, so no serial0 for me.

I need a simple method, like a command to compare hardware, or so, allowing the tool to know if it runs on RPi2 or 3.

Would some of you know any trick to achieve this ?

Thanks in advance.

Sogeking
  • 33
  • 1
  • 4
  • Maybe a useful starting point: http://raspberrypi.stackexchange.com/a/43432/5538 Although it doesn't mention how to do this specifically, there may be a way to do it using the same methodology if you dig. – goldilocks Sep 13 '16 at 13:11

3 Answers3

8

cat /proc/cpuinfo | grep Revision

RPi 2 boards will show board revisions a*1040, a*1041 or a*2042, while an RPi 3 board will give you a*2082. Here's a list of board revisions.

See also: Getting Your Raspberry Pi Revision Number Using Python.

Dmitry Grigoryev
  • 27,928
  • 6
  • 53
  • 144
0

I can't recommend using a board revision to determine capabilities in this way; any such method is unlikely to be forward compatible.

See How do I make serial work on the Raspberry Pi3 for a discussion on the serial ports and particularly /dev/serial0. Looks like the pi3's UART serial has been nerfed a bit and requires some clock help to behave...

BJ Black
  • 576
  • 3
  • 6
  • I do not need forward compatibility, and I cannot use serial0 because some boards are on Wheezy. The thing is these boards will be left alone and not touched. Thanks for your help. – Sogeking Sep 14 '16 at 08:46
0

You could try to check model, but a better solution is to use '/dev/serial0' which selects the appropriate port. Note serial is disabled by default on Pi3

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • As I said, some boards are on Wheezy and the alias serial0 does not exist here. But thanks – Sogeking Sep 14 '16 at 08:45
  • @Sogeking It works on Jessie. Wheezy does not work on Pi3. If '/dev/serial0' does not exist you know you are using an obsolete OS. Either way you would be better testing for the existence of the port you want to use rather than some proxy. – Milliways Sep 14 '16 at 10:36
  • I agree with you, but I have directives limiting me :/ – Sogeking Sep 14 '16 at 12:20