Golgi supports a number of embedded platforms through its Programmable Device Cloud. These include Arduino, Intel, MediaTek and Gainspan. If you’ve already started developing with Golgi you will have no doubt noticed another supported platform. Specifically, support for a platform known as “Other”. Of course, this doesn’t refer to some new board that you just haven’t heard of yet. It actually refers to an implementation that has all of Golgi’s functionality but lacks a network connectivity layer.

While this is a little more work than one of the supported platforms, it does allow developers to use the power of Golgi on a platform that we haven’t managed to build out support for yet. In this post we will discuss how to implement a network layer to allow developers to use Golgi on a 32-bit Linux system such as Raspberry Pi. And of course there will be full source code provided – see https://github.com/GolgiDevs/linux-extension-beta.


When building a network interface for Golgi you will need four components:

  1. A Golgi Network Interface.
  2. A Golgi Wrapper.
  3. A String class.
  4. A Serial class.
  5. Some Golgi fixup functions.

The Golgi Network Interface is a class (GolgiNetInterface) that defines how the Golgi layer can interact with the network. In our code the GolgiNetLinux class is derived from GolgiNetInterface. It implements the following methods:

bool connect(const char *host, int32_t port); // connect
bool connected(void);                                      // check the status of a connection
void service(void);                                            // not needed for Linux - base class implementation used 
void stop(void);                                                // equivalent to a disconnect
void write(const char *str);                              // write values to network
int32_t available(void);                                    // number of bytes available for reading
int32_t read(void);                                           // read a byte from network
int32_t read(void *dst, int32_t len);                // read len bytes from network to dst

These are the functions the Golgi application layer requires to interact with the network.

The Golgi Wrapper wraps Golgi and the Network layer. For the Linux implementation this includes initialising Golgi -via GolgiSetup – as well as wrapping a select function to indicate when the Golgi socket is available for reading/writing and calling the GolgiService – via GolgiSelect.

The String and Serial classes are used by the Golgi library to output debug information to a developer. They mimic String and Serial classes seen on platforms like Arduino.

Finally, the Golgi fixup functions include a function to return time in milliseconds and to return a random character from a specified range.

Check out the full code at our Github page – https://github.com/GolgiDevs/linux-extension-beta. You can use the code on any 32-bit Linux (tested Fedora 23) or Raspberry Pi (tested Raspbian) system.

If you have a platform that you would like to extend to get in touch at info@golgi.io and our engineers will be happy to offer any assistance we can.

Happy coding!

ShareShare on Facebook2Share on Google+2Tweet about this on TwitterShare on LinkedIn0
Back to Articles

Leave a Reply