0

While coding a Raspberry Pi application I do use my PC most of the time since it is a little faster then the Pi.

Today I got the following message when a WiringPi specific code (wiringPiSetup();) got called:

piBoardRev: Unable to determine board revision from /proc/cpuinfo
 -> No hardware line
 ->  You may want to check:
 ->  http://www.raspberrypi.org/phpBB3/viewtopic.php?p=184410#p184410

I would like to skip Raspberry Pi specific code (such this WiringPi part) but execute the rest when running on a PC.

Actually how should I approach this issue?

KcFnMi
  • 5,516
  • 10
  • 62
  • 136
  • 3
    At this point, you're the only one who's seen your code, so you're the only one who can know what parts to cut. In general, you'll need to *mock* the parts that you can't run on your PC. – Jonathon Reinhart Jun 03 '16 at 01:10
  • Should I run Pi specific code in run time like a plugin? – KcFnMi Jun 03 '16 at 01:15
  • 1
    No, just write your own replacement library that mocks the functionality of the library you're replacing. – Jonathon Reinhart Jun 03 '16 at 01:39
  • I never touched the mocking area. Would you mind to give an introductory suggestion about which tools to use (portability across Linux/Windows is appreciated)? – KcFnMi Jun 03 '16 at 09:49

1 Answers1

1

My first solution would be to so include the pi specific code in something like

#ifdef __arm__
  /* pi specific stiff */
#endif

I don't have a PI at hand right now, so I'm not absolutely sure if the macro __arm__ is correct, but gcc and g++ should work, see sourceforge article on architecture defines.

This is a lot easier than mocking everything, but on the other hand the code is not even compiled on your PC, so not even compiler errors would show up here.

  • *"the code is not even compiled on your PC"* is kind of a risky assumption ... there are cross-compilers, you know ... in fact there are whole bundles of cross-compiler **and** emulators out there, its very possible to write, compile and run code for another platform on your PC, thats what i did for a living a few years ago – specializt Jun 03 '16 at 11:28