Maximizing Code Portability across Operating Systems and Hardware Platforms

Rx Blog

Back to RX Blog

Maximizing Code Portability across Operating Systems and Hardware Platforms

Kinman Lam
| March 3, 2015
Coder's Corner
Rx Networks High Precision GPS Technology location Pins

One of the core principles of Rx Networks location technologies is the ability to run on any hardware platform and operating system. Products such as our XYBRID RT (cellular and WiFi location lookup service) can be as simple as a HTTP GET request, while our GPStream PGPS A-GNSS solution interfaces with a GNSS chipset, schedules download of new data, generates Extended Ephemeris (EE) from seed data or Broadcast Ephemeris (BCE), and stores data locally on the device. While we can pass the responsibility of developing all this code to the customer, it is not attractive solution for our customers or ourselves as both parties must commit additional development and support resources to complete the integration.

The smartphone market is dominated by ARM based hardware running Android and iOS, while the wearable gadgets, M2M, and PND markets have a greater diversity of hardware and OS options. Having customers in all these industries provides a development challenge; is it possible to write software that can run on such a variety of hardware and software platforms?

Part of the solution is to develop software using the C programming language. Dennis Ritchie developed the C language and C was used to implement the Unix operating system in the early 1970s at Bell Labs.

C is a function oriented low-level programming language as opposed to an object oriented language like C++ or Java. In programming abstraction C lies in between Assembly and C++. Code written in C has a smaller footprint and is more portable while C does not directly support high level abstraction concepts like polymorphism and inheritance which makes code easier to extend and reuse. It is possible to develop an application with a combination of C and C++ code, but  while a device that has a C++ compiler, will definitely have a C compiler, the opposite may not be true, this is why C code is more portable on a larger variety of hardware and software platforms than C++.

Leveraging the function oriented nature of the C language the integration software is designed as an event driven state machine. The state machine is responsible for:

  1. Verifying and maintaining an accurate system time
  2. Obtaining a list of cellular and WiFi access points and using XYBRID RT to obtain a location
  3. Monitoring the data connectivity of the device and taking appropriate actions when a data connection is available
  4. Processing downloaded data and incoming Broadcast data from a GNSS chipset, and applying the PGPS algorithm to generate up to 14 days worth of Extended Ephemeris
  5. Supplying the GNSS chipset with AGNSS data to improve Time to First Fix (TTFF)

Each state has a set of procedures to verify and complete, before the state machine initiates to the next state. This allows for each possible state outcome to be unit tested and helps to ensure consistent behavior across all platforms.

The integration code has been commercially integrated on devices with hardware architectures such as ARM, MIPS and x86 and on operating systems such as Android, Linux, Windows, QNX and other proprietary OSes. Having one unified integration that runs and behaves consistently on all our customers platforms has helped to ensure a timely integration of Rx Networks location technologies while reducing the overall development and resources commitments.

In the next following articles we will cover more details of developing an event driven state machine and examples of how to structure and write hardware and OS portable code.